@tenphi/tasty 0.0.0-snapshot.efb24cc → 0.0.0-snapshot.effc80a
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 +440 -367
- package/dist/babel-types-BKDTT4--.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-DHL8W6vf.js +60 -0
- package/dist/chunks/build-config-DHL8W6vf.js.map +1 -0
- package/dist/{ssr/collector.js → chunks/collector-P1lIDioe.js} +79 -104
- package/dist/chunks/collector-P1lIDioe.js.map +1 -0
- package/dist/chunks/config-engine-HlsfjR7T.js +272 -0
- package/dist/chunks/config-engine-HlsfjR7T.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/css-definitions-BE12wEJB.js +910 -0
- package/dist/chunks/css-definitions-BE12wEJB.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/{debug.js → chunks/debug-CWZkJJ7A.js} +196 -147
- package/dist/chunks/debug-CWZkJJ7A.js.map +1 -0
- package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
- package/dist/chunks/dsl-DYSJc1-T.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-BwKuG_3d.js +689 -0
- package/dist/chunks/react-runtime-BwKuG_3d.js.map +1 -0
- package/dist/chunks/runtime-engine-D2N-eiPD.js +2432 -0
- package/dist/chunks/runtime-engine-D2N-eiPD.js.map +1 -0
- package/dist/chunks/runtime-state-BJoTY_DP.js +152 -0
- package/dist/chunks/runtime-state-BJoTY_DP.js.map +1 -0
- package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +60 -56
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-CJoK33le.js +5521 -0
- package/dist/chunks/style-engine-CJoK33le.js.map +1 -0
- package/dist/chunks/zero-engine-BCqhSuwo.js +310 -0
- package/dist/chunks/zero-engine-BCqhSuwo.js.map +1 -0
- package/dist/collector-CTU-nl0g.d.ts +164 -0
- package/dist/config-CcxqSZI2.d.ts +1368 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +9 -27
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/index--GdqCPlp.d.ts +1962 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +11 -36
- package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.d.ts} +3 -4
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -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 +10 -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 +17 -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 +11 -8
- package/dist/ssr/astro-middleware.js +2 -14
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +33 -14
- package/dist/ssr/astro.js +163 -91
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +17 -4
- package/dist/ssr/index.js +6 -6
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +123 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -9
- package/dist/ssr/next.js +30 -45
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +90 -5
- package/dist/static/index.js +31 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.d.ts +1 -2
- package/dist/static/inject.js.map +1 -1
- package/dist/types-DJEM_BOJ.d.ts +1567 -0
- package/dist/zero/babel.d.ts +5 -19
- package/dist/zero/babel.js +104 -151
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +135 -3
- package/dist/zero/index.js +24 -3
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +3 -38
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +21 -10
- package/docs/adoption.md +69 -36
- package/docs/ai-agents.md +257 -0
- package/docs/comparison.md +77 -47
- package/docs/configuration.md +646 -85
- package/docs/debug.md +39 -24
- package/docs/design-system.md +154 -33
- package/docs/dsl.md +653 -196
- package/docs/getting-started.md +130 -50
- package/docs/injector.md +162 -71
- package/docs/methodology.md +106 -49
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +768 -0
- package/docs/plugins.md +333 -0
- package/docs/react-api.md +232 -45
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +310 -116
- package/docs/styles.md +182 -47
- package/docs/tasty-static.md +284 -130
- package/package.json +142 -35
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -285
- 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 -1157
- 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 -690
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js +0 -44
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.d.ts +0 -98
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js +0 -16
- 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 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -73
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js +0 -45
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/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 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js +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 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js +0 -266
- package/dist/zero/extractor.js.map +0 -1
- package/docs/PIPELINE.md +0 -519
package/dist/zero/babel.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as _$_babel_core0 from "@babel/core";
|
|
1
|
+
import { t as TastyZeroConfig } from "../babel-types-BKDTT4--.js";
|
|
3
2
|
import { PluginPass } from "@babel/core";
|
|
4
|
-
|
|
5
3
|
//#region src/zero/babel.d.ts
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Subset of TastyConfig excluding runtime-only DOM options
|
|
9
|
-
* (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
|
|
10
|
-
* and overriding `devMode` default to `false`.
|
|
5
|
+
* Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
|
|
11
6
|
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Enable development mode features: source comments in generated CSS.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
devMode?: boolean;
|
|
18
|
-
};
|
|
19
|
-
interface TastyZeroBabelOptions {
|
|
7
|
+
export interface TastyZeroBabelOptions {
|
|
20
8
|
/** Output path for generated CSS (default: 'tasty.css') */
|
|
21
9
|
output?: string;
|
|
22
10
|
/**
|
|
@@ -73,9 +61,7 @@ interface TastyZeroBabelOptions {
|
|
|
73
61
|
*/
|
|
74
62
|
mode?: 'file' | 'inject';
|
|
75
63
|
}
|
|
76
|
-
|
|
77
|
-
declare function clearWriterCache(): void;
|
|
78
|
-
declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _$_babel_core0.PluginObj<PluginPass>;
|
|
64
|
+
declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<PluginPass>;
|
|
79
65
|
//#endregion
|
|
80
|
-
export {
|
|
66
|
+
export { type TastyZeroConfig, _default as default };
|
|
81
67
|
//# sourceMappingURL=babel.d.ts.map
|
package/dist/zero/babel.js
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { extractCounterStyleFromStyles,
|
|
6
|
-
import {
|
|
1
|
+
import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
|
|
2
|
+
import "../chunks/css-definitions-BE12wEJB.js";
|
|
3
|
+
import { t as resolveRecipesWith } from "../chunks/config-engine-HlsfjR7T.js";
|
|
4
|
+
import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-DHL8W6vf.js";
|
|
5
|
+
import { a as extractCounterStyleFromStyles, c as extractKeyframesFromStyles, h as setExtractorNamePrefix, i as extractConfigProperties, l as extractPropertiesFromStyles, m as replaceAnimationNamesInCSS, o as extractFontFaceFromStyles, p as renderSelectorCSS, r as extractChunks, s as extractFunctionsFromStyles, t as CSSWriter, u as extractSelectorCSS } from "../chunks/zero-engine-BCqhSuwo.js";
|
|
6
|
+
import { t as loadConfigFile } from "../chunks/config-file-DlZXJMj8.js";
|
|
7
7
|
import * as fs from "fs";
|
|
8
8
|
import * as path from "path";
|
|
9
9
|
import { declare } from "@babel/helper-plugin-utils";
|
|
10
10
|
import * as t from "@babel/types";
|
|
11
|
-
|
|
11
|
+
//#region \0rolldown/runtime.js
|
|
12
|
+
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) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
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.");
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/zero/writer-cache.ts
|
|
18
|
+
const writerCache = /* @__PURE__ */ new Map();
|
|
19
|
+
//#endregion
|
|
12
20
|
//#region src/zero/babel.ts
|
|
13
|
-
/**
|
|
14
|
-
* Babel plugin for zero-runtime tasty static site generation.
|
|
15
|
-
*
|
|
16
|
-
* Transforms:
|
|
17
|
-
* - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
|
|
18
|
-
* - `tastyStatic(base, styles)` → StaticStyle object with merged styles
|
|
19
|
-
* - `tastyStatic(selector, styles)` → removed entirely
|
|
20
|
-
*
|
|
21
|
-
* Usage:
|
|
22
|
-
* ```javascript
|
|
23
|
-
* // babel.config.js
|
|
24
|
-
* module.exports = {
|
|
25
|
-
* plugins: [
|
|
26
|
-
* ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
|
|
27
|
-
* ]
|
|
28
|
-
* };
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
21
|
function mtime(filePath) {
|
|
32
22
|
try {
|
|
33
23
|
return fs.statSync(filePath).mtimeMs;
|
|
@@ -50,11 +40,6 @@ function clearRequireCacheTree(filePath) {
|
|
|
50
40
|
}
|
|
51
41
|
delete __require.cache[resolved];
|
|
52
42
|
}
|
|
53
|
-
const writerCache = /* @__PURE__ */ new Map();
|
|
54
|
-
/** Clear the shared CSSWriter cache. Exposed for testing. */
|
|
55
|
-
function clearWriterCache() {
|
|
56
|
-
writerCache.clear();
|
|
57
|
-
}
|
|
58
43
|
var babel_default = declare((api, options) => {
|
|
59
44
|
api.assertVersion(7);
|
|
60
45
|
const mode = options.mode ?? "file";
|
|
@@ -80,42 +65,54 @@ var babel_default = declare((api, options) => {
|
|
|
80
65
|
const configOption = options.config;
|
|
81
66
|
let resolvedConfig;
|
|
82
67
|
if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
|
|
83
|
-
else if (options.configFile) resolvedConfig =
|
|
68
|
+
else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
|
|
84
69
|
else resolvedConfig = {};
|
|
85
70
|
const devMode = resolvedConfig.devMode ?? false;
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
resetZeroConfig();
|
|
72
|
+
const finalConfig = {
|
|
73
|
+
namePrefix: "ts",
|
|
74
|
+
...resolvedConfig
|
|
75
|
+
};
|
|
76
|
+
const config = configureZero(finalConfig);
|
|
77
|
+
setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
|
|
88
78
|
const newWriter = new CSSWriter(outputPath, { devMode });
|
|
89
79
|
if (mode !== "inject") {
|
|
90
|
-
const
|
|
80
|
+
for (const prop of extractConfigProperties(config.normalized.properties)) newWriter.add(`@property:${prop.name}`, prop.css);
|
|
81
|
+
const tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
|
|
91
82
|
if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
|
|
92
|
-
const
|
|
93
|
-
if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
|
|
94
|
-
const css = extractCSSFromStyles(selector, styles);
|
|
95
|
-
if (css) newWriter.add(`global:${selector}`, css);
|
|
96
|
-
}
|
|
83
|
+
for (const [selector, styles] of Object.entries(config.normalized.globalStyles)) writeGlobalStyles(newWriter, selector, styles, config.normalized.keyframes);
|
|
97
84
|
}
|
|
98
85
|
writerCache.set(resolvedOutputPath, {
|
|
99
86
|
writer: newWriter,
|
|
100
87
|
configKey,
|
|
101
88
|
registry: {},
|
|
102
|
-
config
|
|
89
|
+
config
|
|
103
90
|
});
|
|
104
91
|
}
|
|
105
92
|
const entry = writerCache.get(resolvedOutputPath);
|
|
93
|
+
entry.config = reapplyZeroConfig(entry.config);
|
|
106
94
|
const cssWriter = entry.writer;
|
|
107
95
|
const globalRegistry = entry.registry;
|
|
108
96
|
const config = entry.config;
|
|
109
|
-
const
|
|
97
|
+
const sourceConfig = config.source;
|
|
98
|
+
const devMode = sourceConfig.devMode ?? false;
|
|
99
|
+
setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
|
|
100
|
+
const configProperties = extractConfigProperties(config.normalized.properties);
|
|
101
|
+
const propertyOptions = {
|
|
102
|
+
autoPropertyTypes: sourceConfig.autoPropertyTypes,
|
|
103
|
+
defined: new Set(configProperties.map((prop) => prop.name))
|
|
104
|
+
};
|
|
105
|
+
let propertyCSS;
|
|
110
106
|
let tokenCSS;
|
|
111
107
|
let globalStylesCSS;
|
|
112
108
|
if (mode === "inject") {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
propertyCSS = configProperties.map((prop) => prop.css).join("\n") || void 0;
|
|
110
|
+
tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
|
|
111
|
+
const gs = config.normalized.globalStyles;
|
|
112
|
+
if (Object.keys(gs).length > 0) {
|
|
116
113
|
globalStylesCSS = /* @__PURE__ */ new Map();
|
|
117
114
|
for (const [selector, styles] of Object.entries(gs)) {
|
|
118
|
-
const css = extractCSSFromStyles(selector, styles);
|
|
115
|
+
const css = extractCSSFromStyles(selector, styles, config.normalized.keyframes);
|
|
119
116
|
if (css) globalStylesCSS.set(selector, css);
|
|
120
117
|
}
|
|
121
118
|
if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
|
|
@@ -124,6 +121,8 @@ var babel_default = declare((api, options) => {
|
|
|
124
121
|
return {
|
|
125
122
|
name: "tasty-zero",
|
|
126
123
|
pre() {
|
|
124
|
+
entry.config = reapplyZeroConfig(entry.config);
|
|
125
|
+
setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
|
|
127
126
|
this.staticStyleRegistry = {};
|
|
128
127
|
this._fileAddedCSS = false;
|
|
129
128
|
if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
|
|
@@ -131,16 +130,18 @@ var babel_default = declare((api, options) => {
|
|
|
131
130
|
visitor: {
|
|
132
131
|
ImportDeclaration(nodePath, state) {
|
|
133
132
|
const source = nodePath.node.source.value;
|
|
134
|
-
if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static"))
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) {
|
|
134
|
+
if (mode === "inject") nodePath.replaceWith(t.importDeclaration([t.importSpecifier(t.identifier("_$i"), t.identifier("injectCSS"))], t.stringLiteral("@tenphi/tasty/static/inject")));
|
|
135
|
+
else if (injectImport) {
|
|
136
|
+
let importPath = resolvedOutputPath;
|
|
137
|
+
if (state.filename) {
|
|
138
|
+
const sourceDir = path.dirname(state.filename);
|
|
139
|
+
importPath = path.relative(sourceDir, resolvedOutputPath);
|
|
140
|
+
if (!importPath.startsWith(".")) importPath = "./" + importPath;
|
|
141
|
+
}
|
|
142
|
+
nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
|
|
143
|
+
} else nodePath.remove();
|
|
144
|
+
}
|
|
144
145
|
},
|
|
145
146
|
CallExpression(path, state) {
|
|
146
147
|
const callee = path.node.callee;
|
|
@@ -149,9 +150,9 @@ var babel_default = declare((api, options) => {
|
|
|
149
150
|
const args = path.node.arguments;
|
|
150
151
|
if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
|
|
151
152
|
const firstArg = args[0];
|
|
152
|
-
if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.
|
|
153
|
-
else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.
|
|
154
|
-
else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.
|
|
153
|
+
if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
|
|
154
|
+
else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
|
|
155
|
+
else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
|
|
155
156
|
else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
|
|
156
157
|
},
|
|
157
158
|
VariableDeclarator(path, state) {
|
|
@@ -176,10 +177,15 @@ var babel_default = declare((api, options) => {
|
|
|
176
177
|
},
|
|
177
178
|
post() {
|
|
178
179
|
if (mode === "inject") {
|
|
179
|
-
if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
|
|
180
|
+
if (this._fileAddedCSS && (propertyCSS || tokenCSS || globalStylesCSS)) {
|
|
180
181
|
const program = this.file.ast.program;
|
|
181
182
|
let insertIndex = 0;
|
|
182
183
|
for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
|
|
184
|
+
if (propertyCSS) {
|
|
185
|
+
const injectCall = createInjectCallAST("@property", propertyCSS);
|
|
186
|
+
program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
|
|
187
|
+
insertIndex++;
|
|
188
|
+
}
|
|
183
189
|
if (tokenCSS) {
|
|
184
190
|
const injectCall = createInjectCallAST(":root", tokenCSS);
|
|
185
191
|
program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
|
|
@@ -197,55 +203,42 @@ var babel_default = declare((api, options) => {
|
|
|
197
203
|
}
|
|
198
204
|
};
|
|
199
205
|
});
|
|
200
|
-
/**
|
|
201
|
-
* Check if an object expression looks like a StaticStyle object
|
|
202
|
-
*/
|
|
203
206
|
function isStaticStyleObject(node) {
|
|
204
207
|
const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
|
|
205
208
|
const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
|
|
206
209
|
return hasClassName && hasStyles;
|
|
207
210
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Extract styles object from a StaticStyle object expression
|
|
210
|
-
*/
|
|
211
211
|
function extractStylesFromStaticStyleObject(node, path) {
|
|
212
212
|
for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "styles" }) && t.isObjectExpression(prop.value)) return evaluateObjectExpression(prop.value, path);
|
|
213
213
|
return null;
|
|
214
214
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Extract className from a StaticStyle object expression
|
|
217
|
-
*/
|
|
218
215
|
function extractClassNameFromStaticStyleObject(node) {
|
|
219
216
|
for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "className" }) && t.isStringLiteral(prop.value)) return prop.value.value;
|
|
220
217
|
return null;
|
|
221
218
|
}
|
|
222
|
-
|
|
223
|
-
* Handle tastyStatic(styles) - returns StaticStyle object
|
|
224
|
-
*/
|
|
225
|
-
function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
219
|
+
function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
226
220
|
const stylesArg = args[0];
|
|
227
221
|
if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
|
|
228
|
-
const
|
|
222
|
+
const rawStyles = evaluateObjectExpression(stylesArg, path);
|
|
223
|
+
const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
|
|
229
224
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
230
|
-
const properties = extractPropertiesFromStyles(styles,
|
|
225
|
+
const properties = extractPropertiesFromStyles(styles, propertyOptions);
|
|
231
226
|
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
232
227
|
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
233
|
-
const
|
|
228
|
+
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
229
|
+
const chunks = extractChunks(styles);
|
|
234
230
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
235
231
|
const staticStyleObject = createStaticStyleAST(className, styles);
|
|
236
232
|
if (mode === "inject") {
|
|
237
|
-
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
|
|
233
|
+
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
|
|
238
234
|
path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
|
|
239
235
|
} else {
|
|
240
|
-
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
|
|
236
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
|
|
241
237
|
path.replaceWith(staticStyleObject);
|
|
242
238
|
}
|
|
243
239
|
registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
|
|
244
240
|
}
|
|
245
|
-
|
|
246
|
-
* Handle tastyStatic(base, styles) - extends base with additional styles
|
|
247
|
-
*/
|
|
248
|
-
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
241
|
+
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
249
242
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
|
|
250
243
|
const baseArg = args[0];
|
|
251
244
|
const stylesArg = args[1];
|
|
@@ -255,101 +248,94 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
|
|
|
255
248
|
const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
|
|
256
249
|
if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
|
|
257
250
|
const overrideStyles = evaluateObjectExpression(stylesArg, path);
|
|
258
|
-
const mergedStyles =
|
|
251
|
+
const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
|
|
259
252
|
const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
|
|
260
|
-
const properties = extractPropertiesFromStyles(mergedStyles,
|
|
253
|
+
const properties = extractPropertiesFromStyles(mergedStyles, propertyOptions);
|
|
261
254
|
const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
|
|
262
255
|
const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
|
|
263
|
-
const
|
|
256
|
+
const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
|
|
257
|
+
const chunks = extractChunks(mergedStyles);
|
|
264
258
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
265
259
|
const staticStyleObject = createStaticStyleAST(className, mergedStyles);
|
|
266
260
|
if (mode === "inject") {
|
|
267
|
-
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
|
|
261
|
+
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
|
|
268
262
|
path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
|
|
269
263
|
} else {
|
|
270
|
-
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
|
|
264
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
|
|
271
265
|
path.replaceWith(staticStyleObject);
|
|
272
266
|
}
|
|
273
267
|
registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
|
|
274
268
|
}
|
|
275
|
-
|
|
276
|
-
* Handle tastyStatic(selector, styles) - removes the call entirely
|
|
277
|
-
*/
|
|
278
|
-
function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
269
|
+
function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
279
270
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
|
|
280
271
|
const selectorArg = args[0];
|
|
281
272
|
const stylesArg = args[1];
|
|
282
273
|
if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
|
|
283
274
|
if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
|
|
284
275
|
const selector = selectorArg.value;
|
|
285
|
-
const
|
|
276
|
+
const rawStyles = evaluateObjectExpression(stylesArg, path);
|
|
277
|
+
const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
|
|
286
278
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
287
|
-
const properties = extractPropertiesFromStyles(styles,
|
|
279
|
+
const properties = extractPropertiesFromStyles(styles, propertyOptions);
|
|
288
280
|
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
289
281
|
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
290
|
-
const
|
|
291
|
-
const
|
|
282
|
+
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
283
|
+
const css = renderSelectorCSS(selector, styles);
|
|
284
|
+
const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(css, nameMap) : css;
|
|
292
285
|
if (mode === "inject") {
|
|
293
286
|
const cssParts = [];
|
|
294
287
|
for (const kf of keyframes) cssParts.push(kf.css);
|
|
295
288
|
for (const prop of properties) cssParts.push(prop.css);
|
|
296
289
|
for (const ff of fontFaces) cssParts.push(ff.css);
|
|
297
290
|
for (const cs of counterStyles) cssParts.push(cs.css);
|
|
291
|
+
for (const fn of functions) cssParts.push(fn.css);
|
|
298
292
|
cssParts.push(selectorCSS);
|
|
299
293
|
const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
|
|
300
294
|
const parent = path.parentPath;
|
|
301
295
|
if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
|
|
302
296
|
else path.replaceWith(injectCall);
|
|
303
297
|
} else {
|
|
304
|
-
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, [], nameMap, sourceFile);
|
|
298
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, [], nameMap, sourceFile);
|
|
305
299
|
cssWriter.add(selector, selectorCSS, sourceFile);
|
|
306
300
|
const parent = path.parentPath;
|
|
307
301
|
if (parent && t.isExpressionStatement(parent.node)) parent.remove();
|
|
308
302
|
else path.replaceWith(t.identifier("undefined"));
|
|
309
303
|
}
|
|
310
304
|
}
|
|
311
|
-
|
|
312
|
-
* Collect all extracted CSS parts into a single string (for inject mode).
|
|
313
|
-
*/
|
|
314
|
-
function collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap) {
|
|
305
|
+
function collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap) {
|
|
315
306
|
const parts = [];
|
|
316
307
|
for (const kf of keyframes) parts.push(kf.css);
|
|
317
308
|
for (const prop of properties) parts.push(prop.css);
|
|
318
309
|
for (const ff of fontFaces) parts.push(ff.css);
|
|
319
310
|
for (const cs of counterStyles) parts.push(cs.css);
|
|
311
|
+
for (const fn of functions) parts.push(fn.css);
|
|
320
312
|
for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
|
|
321
313
|
return parts.join("\n");
|
|
322
314
|
}
|
|
323
|
-
|
|
324
|
-
* Write all extracted CSS parts to a CSSWriter (for file mode).
|
|
325
|
-
*/
|
|
326
|
-
function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, sourceFile) {
|
|
315
|
+
function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, sourceFile) {
|
|
327
316
|
for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
|
|
328
317
|
for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
|
|
329
318
|
for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
|
|
330
319
|
for (const cs of counterStyles) cssWriter.add(cs.css, cs.css, sourceFile);
|
|
320
|
+
for (const fn of functions) cssWriter.add(fn.css, fn.css, sourceFile);
|
|
331
321
|
for (const chunk of chunks) {
|
|
332
322
|
const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
|
|
333
323
|
cssWriter.add(chunk.className, css, sourceFile);
|
|
334
324
|
}
|
|
335
325
|
}
|
|
336
|
-
|
|
337
|
-
* Extract CSS for a selector from a styles/tokens object.
|
|
338
|
-
* Returns undefined when there are no styles or no CSS output.
|
|
339
|
-
*/
|
|
340
|
-
function extractCSSFromStyles(selector, styles) {
|
|
326
|
+
function extractCSSFromStyles(selector, styles, globalKeyframes) {
|
|
341
327
|
if (!styles || Object.keys(styles).length === 0) return void 0;
|
|
342
|
-
return
|
|
328
|
+
return extractSelectorCSS(selector, styles, globalKeyframes) || void 0;
|
|
329
|
+
}
|
|
330
|
+
function writeGlobalStyles(cssWriter, selector, styles, globalKeyframes) {
|
|
331
|
+
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
332
|
+
for (const kf of keyframes) cssWriter.add(kf.css, kf.css);
|
|
333
|
+
const css = replaceAnimationNamesInCSS(renderSelectorCSS(selector, styles), nameMap);
|
|
334
|
+
if (css) cssWriter.add(`global:${selector}`, css);
|
|
343
335
|
}
|
|
344
|
-
/**
|
|
345
|
-
* Create an `_$i(id, css)` call expression AST node for inject mode.
|
|
346
|
-
*/
|
|
347
336
|
function createInjectCallAST(id, css) {
|
|
348
337
|
return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
|
|
349
338
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Create a StaticStyle object AST node
|
|
352
|
-
*/
|
|
353
339
|
function createStaticStyleAST(className, styles) {
|
|
354
340
|
return t.objectExpression([
|
|
355
341
|
t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
|
|
@@ -357,9 +343,6 @@ function createStaticStyleAST(className, styles) {
|
|
|
357
343
|
t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
|
|
358
344
|
]);
|
|
359
345
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Register a StaticStyle in the registry if it's being assigned to a variable
|
|
362
|
-
*/
|
|
363
346
|
function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
|
|
364
347
|
const parent = path.parentPath;
|
|
365
348
|
if (parent && t.isVariableDeclarator(parent.node)) {
|
|
@@ -377,9 +360,6 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
|
|
|
377
360
|
}
|
|
378
361
|
}
|
|
379
362
|
}
|
|
380
|
-
/**
|
|
381
|
-
* Convert a JavaScript value to an AST node
|
|
382
|
-
*/
|
|
383
363
|
function valueToAST(value) {
|
|
384
364
|
if (value === null) return t.nullLiteral();
|
|
385
365
|
if (value === void 0) return t.identifier("undefined");
|
|
@@ -393,10 +373,6 @@ function valueToAST(value) {
|
|
|
393
373
|
}
|
|
394
374
|
return t.identifier("undefined");
|
|
395
375
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Evaluate an ObjectExpression to a plain JavaScript object.
|
|
398
|
-
* Only supports static values that can be determined at build time.
|
|
399
|
-
*/
|
|
400
376
|
function evaluateObjectExpression(node, path) {
|
|
401
377
|
const result = {};
|
|
402
378
|
for (const prop of node.properties) {
|
|
@@ -406,13 +382,11 @@ function evaluateObjectExpression(node, path) {
|
|
|
406
382
|
if (t.isIdentifier(prop.key)) key = prop.key.name;
|
|
407
383
|
else if (t.isStringLiteral(prop.key)) key = prop.key.value;
|
|
408
384
|
else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
|
|
409
|
-
|
|
385
|
+
const value = evaluateExpression(prop.value, path);
|
|
386
|
+
result[key] = value;
|
|
410
387
|
}
|
|
411
388
|
return result;
|
|
412
389
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Evaluate an expression to a JavaScript value.
|
|
415
|
-
*/
|
|
416
390
|
function evaluateExpression(node, path) {
|
|
417
391
|
if (t.isStringLiteral(node)) return node.value;
|
|
418
392
|
if (t.isNumericLiteral(node)) return node.value;
|
|
@@ -435,28 +409,7 @@ function evaluateExpression(node, path) {
|
|
|
435
409
|
}
|
|
436
410
|
throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
|
|
437
411
|
}
|
|
438
|
-
/**
|
|
439
|
-
* Replace animation names in CSS string.
|
|
440
|
-
* Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
|
|
441
|
-
*/
|
|
442
|
-
function replaceAnimationNamesInCSS(css, nameMap) {
|
|
443
|
-
if (nameMap.size === 0) return css;
|
|
444
|
-
return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
|
|
445
|
-
let newValue = value;
|
|
446
|
-
for (const [original, replacement] of nameMap) {
|
|
447
|
-
const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
|
|
448
|
-
newValue = newValue.replace(pattern, replacement);
|
|
449
|
-
}
|
|
450
|
-
return `${prop}: ${newValue}`;
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Escape special regex characters.
|
|
455
|
-
*/
|
|
456
|
-
function escapeRegex(str) {
|
|
457
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
458
|
-
}
|
|
459
412
|
//#endregion
|
|
460
|
-
export {
|
|
413
|
+
export { babel_default as default };
|
|
461
414
|
|
|
462
415
|
//# sourceMappingURL=babel.js.map
|