@tenphi/tasty 0.0.0-snapshot.1f1c00a → 0.0.0-snapshot.1feecc6
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 +403 -380
- package/dist/babel-types-Dc5zghyE.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-D9Iq8QQm.js +60 -0
- package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
- package/dist/chunks/{collector-D2ARGT2L.js → collector-Cb8ah2JF.js} +8 -6
- package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
- package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-CMYFZYQh.js} +5 -5
- package/dist/chunks/config-engine-CMYFZYQh.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-DotDkIXt.js → css-definitions-B4aWBkH3.js} +130 -96
- package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
- package/dist/chunks/{debug-D8pg9RGI.js → debug-D2Pu7Xhy.js} +6 -6
- package/dist/chunks/{debug-D8pg9RGI.js.map → debug-D2Pu7Xhy.js.map} +1 -1
- package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
- package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
- package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-DHiopXCu.js} +193 -64
- package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
- package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-NGCofNXy.js} +72 -53
- package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
- package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-lZjMbvwV.js} +28 -3
- package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
- package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-DnkV_4Jg.js} +488 -146
- package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
- package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-DcwaCvFs.js} +62 -27
- package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
- package/dist/{collector-w4mBj5gd.d.ts → collector-D2OT6I2G.d.ts} +2 -2
- package/dist/{config-CZWCzBr6.d.ts → config-C4ftFxgI.d.ts} +41 -23
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +7 -7
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-G9JuwM9p.d.ts → index-DxQNRj50.d.ts} +65 -21
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -8
- package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +3 -22
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +13 -18
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-JEY8PVYP.d.ts → types-CYQIhUg1.d.ts} +10 -8
- package/dist/zero/babel.d.ts +73 -2
- package/dist/zero/babel.js +51 -48
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +59 -3
- package/dist/zero/index.js +25 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +2 -1
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +43 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +187 -69
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +262 -116
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +41 -40
- package/docs/methodology.md +46 -21
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +22 -19
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +74 -11
- package/docs/runtime-benchmarks.md +11 -11
- package/docs/ssr.md +92 -66
- package/docs/styles.md +85 -19
- package/docs/tasty-static.md +175 -57
- package/package.json +45 -32
- package/tasty.config.ts +1 -0
- package/dist/babel-rZcEwPLM.d.ts +0 -82
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/build-config-CL4eRu2z.js +0 -42
- package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
- package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
- package/dist/chunks/config-engine-DEmmPPdp.js.map +0 -1
- package/dist/chunks/css-definitions-DotDkIXt.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
- package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
- package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
- package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
- package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
|
@@ -157,10 +157,9 @@ declare const DIRECTIONS: string[];
|
|
|
157
157
|
*/
|
|
158
158
|
declare function getGlobalParser(): StyleParser;
|
|
159
159
|
/**
|
|
160
|
-
* Get the current global predefined tokens.
|
|
161
|
-
* Returns null if no tokens are configured.
|
|
160
|
+
* Get the current global predefined tokens, including built-in defaults.
|
|
162
161
|
*/
|
|
163
|
-
declare function getGlobalPredefinedTokens(): Record<string, string
|
|
162
|
+
declare function getGlobalPredefinedTokens(): Record<string, string>;
|
|
164
163
|
/**
|
|
165
164
|
*
|
|
166
165
|
* @param {String} value
|
|
@@ -236,7 +235,7 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
236
235
|
/**
|
|
237
236
|
* Set the background color of the element. Shortcut for `background-color` with enhanced support for Tasty color tokens and syntaxes.
|
|
238
237
|
*
|
|
239
|
-
*
|
|
238
|
+
* To paint one color over another, use a compound color: `#surface+#dark.04` is `#dark` at 4% opacity over `#surface`, as one background color.
|
|
240
239
|
*
|
|
241
240
|
* Examples:
|
|
242
241
|
* - `fill="#purple.10"` // purple background with 10% opacity
|
|
@@ -246,8 +245,11 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
246
245
|
* - `fill="hsl(200 100% 50%)"` // HSL color
|
|
247
246
|
* - `fill="okhsl(200 100% 50%)"` // perceptually uniform OKHSL color
|
|
248
247
|
* - `fill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
249
|
-
* - `fill="#
|
|
250
|
-
* - `fill=
|
|
248
|
+
* - `fill="#surface+#dark.04"` // `#dark` at 4% opacity over `#surface`, as one color
|
|
249
|
+
* - `fill="#dark 4%, #surface"` // deprecated: two colors mixed with a comma, the same color as `#surface+#dark.04`
|
|
250
|
+
* - `fill="#surface #dark.04"` // deprecated: the second color as an overlay layer
|
|
251
|
+
*
|
|
252
|
+
* `fill={false}` sets no fill. `fill={true}` names no color and is ignored.
|
|
251
253
|
*/
|
|
252
254
|
fill?: ColorValue | boolean;
|
|
253
255
|
/**
|
|
@@ -500,7 +502,7 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
500
502
|
* Corner modifiers: `top-left`, `top-right`, `bottom-right`, `bottom-left` — a single corner
|
|
501
503
|
*
|
|
502
504
|
* Examples:
|
|
503
|
-
* - `radius="2r"` // border-radius:
|
|
505
|
+
* - `radius="2r"` // border-radius: 12px
|
|
504
506
|
* - `radius={true}` // default radius (1r)
|
|
505
507
|
* - `radius="round"` // fully rounded (9999rem)
|
|
506
508
|
* - `radius="leaf"` // asymmetric leaf shape
|
|
@@ -1564,4 +1566,4 @@ interface RawCSSResult {
|
|
|
1564
1566
|
}
|
|
1565
1567
|
//#endregion
|
|
1566
1568
|
export { TastyNamedColors as $, resetStyleBatch as A, getGlobalPredefinedStates as B, SheetInfo as C, StyleParser as Ct, QueuedWrite as D, StyleDetailsPart as Dt, StyleUsage as E, StyleDetails as Et, parseStateKey as F, NoType as G, ConditionNode as H, AtRuleContext as I, Selector as J, NotSelector as K, ParsedAdvancedState as L, StyleResult as M, renderStyles as N, flushStyles as O, UnitHandler as Ot, ParseStateKeyOptions as P, SuffixForSelector as Q, StateParserContext as R, RuleInfo as S, stringifyStyles as St, StyleRule as T, ProcessedStyle as Tt, ConfigTokenValue as U, setGlobalPredefinedStates as V, ConfigTokens as W, StylesInterface as X, Styles as Y, StylesWithoutSelectors as Z, KeyframesSteps as _, getGlobalParser as _t, FontFaceInput as a, ParsedColor as at, RawCSSResult as b, parseColor as bt, GCConfig as c, StyleHandler as ct, InjectOptions as d, StyleHandlerResult as dt, TastyPresetNames as et, InjectResult as f, StyleMap as ft, KeyframesResult as g, filterMods as gt, KeyframesInfo as h, StyleValueStateMap as ht, FontFaceDescriptors as i, DIRECTIONS as it, RenderResult as j, hasPendingStyleWrites as k, CSSProperties as kt, GCOptions as l, StyleHandlerDefinition as lt, KeyframesCacheEntry as m, StyleValue as mt, CounterStyleDescriptors as n, CSSMap as nt, FunctionDefinition as o, RawStyleHandler as ot, InjectionMode as p, StylePropValue as pt, RecipeStyles as q, DisposeFunction as r, CUSTOM_UNITS as rt, FunctionParameter as s, ResolvedStyleValue as st, CacheMetrics as t, AnyStyleHandler as tt, GlobalInjectResult as u, StyleHandlerProps as ut, PropertyDefinition as v, getGlobalPredefinedTokens as vt, StyleInjectorConfig as w, ParserOptions as wt, RootRegistry as x, parseStyle as xt, PropertyOptions as y, normalizeColorTokenValue as yt, createStateParserContext as z };
|
|
1567
|
-
//# sourceMappingURL=types-
|
|
1569
|
+
//# sourceMappingURL=types-CYQIhUg1.d.ts.map
|
package/dist/zero/babel.d.ts
CHANGED
|
@@ -1,2 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as TastyZeroConfig } from "../babel-types-Dc5zghyE.js";
|
|
2
|
+
//#region src/zero/babel.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
|
|
5
|
+
*/
|
|
6
|
+
export interface TastyZeroBabelOptions {
|
|
7
|
+
/** Output path for generated CSS (default: 'tasty.css') */
|
|
8
|
+
output?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Tasty configuration for build-time processing.
|
|
11
|
+
* Can be a static object or a factory function that returns fresh config.
|
|
12
|
+
* A factory is called on each plugin invocation, enabling hot reload
|
|
13
|
+
* of config values that depend on external files (e.g. theme tokens).
|
|
14
|
+
*/
|
|
15
|
+
config?: TastyZeroConfig | (() => TastyZeroConfig);
|
|
16
|
+
/**
|
|
17
|
+
* Absolute path to a TypeScript/JavaScript module that default-exports
|
|
18
|
+
* a `TastyZeroConfig` object. The module is loaded via jiti on each
|
|
19
|
+
* plugin invocation, enabling hot reload when the file changes.
|
|
20
|
+
*
|
|
21
|
+
* This option is JSON-serializable and is the primary way Turbopack
|
|
22
|
+
* passes config to the Babel plugin (since Turbopack loader options
|
|
23
|
+
* must be plain primitives/objects/arrays).
|
|
24
|
+
*
|
|
25
|
+
* When both `config` and `configFile` are set, `config` takes precedence.
|
|
26
|
+
*
|
|
27
|
+
* @example '/absolute/path/to/tasty-zero.config.ts'
|
|
28
|
+
*/
|
|
29
|
+
configFile?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Absolute file paths whose content affects the generated CSS.
|
|
32
|
+
* When any of these files change, babel-loader invalidates its cache
|
|
33
|
+
* and re-runs the plugin with fresh config values.
|
|
34
|
+
*
|
|
35
|
+
* Typically includes theme files that define Glaze palettes or token values.
|
|
36
|
+
* Paths must be absolute (resolved by the Next.js wrapper).
|
|
37
|
+
*/
|
|
38
|
+
configDeps?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Automatically replace `@tenphi/tasty/static` imports with an import
|
|
41
|
+
* of the generated CSS file. This eliminates the need for users to
|
|
42
|
+
* manually import the CSS in their app entry point.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
injectImport?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Output mode for extracted CSS.
|
|
49
|
+
*
|
|
50
|
+
* - `'file'` (default): CSS is written to a single output file and
|
|
51
|
+
* the `@tenphi/tasty/static` import is rewritten to import that file.
|
|
52
|
+
* - `'inject'`: CSS is embedded inline in the JS output and injected
|
|
53
|
+
* at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
|
|
54
|
+
* No CSS file is written. Each `tastyStatic` call becomes
|
|
55
|
+
* self-contained. Best for reusable components and extensions.
|
|
56
|
+
*
|
|
57
|
+
* When `mode` is `'inject'`, `output` and `injectImport` are ignored.
|
|
58
|
+
*
|
|
59
|
+
* @default 'file'
|
|
60
|
+
*/
|
|
61
|
+
mode?: 'file' | 'inject';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The plugin's call signature, written out rather than inferred from
|
|
65
|
+
* `declare()` so the published declaration names no Babel types: Babel 7's
|
|
66
|
+
* come from `@types/babel__core`, Babel 8 ships its own, and the two name the
|
|
67
|
+
* plugin object differently.
|
|
68
|
+
*/
|
|
69
|
+
type TastyZeroBabelPlugin = (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => object;
|
|
70
|
+
declare const _default: TastyZeroBabelPlugin;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { type TastyZeroConfig, _default as default };
|
|
73
|
+
//# sourceMappingURL=babel.d.ts.map
|
package/dist/zero/babel.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
|
|
2
|
-
import "../chunks/css-definitions-
|
|
3
|
-
import { t as resolveRecipesWith } from "../chunks/config-engine-
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
2
|
+
import "../chunks/css-definitions-B4aWBkH3.js";
|
|
3
|
+
import { t as resolveRecipesWith } from "../chunks/config-engine-CMYFZYQh.js";
|
|
4
|
+
import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-D9Iq8QQm.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-DcwaCvFs.js";
|
|
6
|
+
import { t as loadConfigFile } from "../chunks/config-file-DlZXJMj8.js";
|
|
6
7
|
import * as fs from "fs";
|
|
7
8
|
import * as path from "path";
|
|
8
9
|
import { declare } from "@babel/helper-plugin-utils";
|
|
9
10
|
import * as t from "@babel/types";
|
|
10
|
-
import { createJiti } from "jiti";
|
|
11
11
|
//#region \0rolldown/runtime.js
|
|
12
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
13
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
@@ -40,8 +40,8 @@ function clearRequireCacheTree(filePath) {
|
|
|
40
40
|
}
|
|
41
41
|
delete __require.cache[resolved];
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
api.assertVersion(7);
|
|
43
|
+
const plugin = declare((api, options) => {
|
|
44
|
+
api.assertVersion("^7.0.0-0 || ^8.0.0-0");
|
|
45
45
|
const mode = options.mode ?? "file";
|
|
46
46
|
const outputPath = options.output || "tasty.css";
|
|
47
47
|
const resolvedOutputPath = path.resolve(outputPath);
|
|
@@ -65,10 +65,8 @@ var babel_default = declare((api, options) => {
|
|
|
65
65
|
const configOption = options.config;
|
|
66
66
|
let resolvedConfig;
|
|
67
67
|
if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
|
|
68
|
-
else if (options.configFile)
|
|
69
|
-
|
|
70
|
-
resolvedConfig = loaded && typeof loaded === "object" && "default" in loaded ? loaded.default : loaded;
|
|
71
|
-
} else resolvedConfig = {};
|
|
68
|
+
else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
|
|
69
|
+
else resolvedConfig = {};
|
|
72
70
|
const devMode = resolvedConfig.devMode ?? false;
|
|
73
71
|
resetZeroConfig();
|
|
74
72
|
const finalConfig = {
|
|
@@ -79,12 +77,10 @@ var babel_default = declare((api, options) => {
|
|
|
79
77
|
setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
|
|
80
78
|
const newWriter = new CSSWriter(outputPath, { devMode });
|
|
81
79
|
if (mode !== "inject") {
|
|
80
|
+
for (const prop of extractConfigProperties(config.normalized.properties)) newWriter.add(`@property:${prop.name}`, prop.css);
|
|
82
81
|
const tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
|
|
83
82
|
if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
|
|
84
|
-
for (const [selector, styles] of Object.entries(config.normalized.globalStyles))
|
|
85
|
-
const css = extractCSSFromStyles(selector, styles);
|
|
86
|
-
if (css) newWriter.add(`global:${selector}`, css);
|
|
87
|
-
}
|
|
83
|
+
for (const [selector, styles] of Object.entries(config.normalized.globalStyles)) writeGlobalStyles(newWriter, selector, styles, config.normalized.keyframes);
|
|
88
84
|
}
|
|
89
85
|
writerCache.set(resolvedOutputPath, {
|
|
90
86
|
writer: newWriter,
|
|
@@ -94,21 +90,29 @@ var babel_default = declare((api, options) => {
|
|
|
94
90
|
});
|
|
95
91
|
}
|
|
96
92
|
const entry = writerCache.get(resolvedOutputPath);
|
|
93
|
+
entry.config = reapplyZeroConfig(entry.config);
|
|
97
94
|
const cssWriter = entry.writer;
|
|
98
95
|
const globalRegistry = entry.registry;
|
|
99
96
|
const config = entry.config;
|
|
100
97
|
const sourceConfig = config.source;
|
|
101
98
|
const devMode = sourceConfig.devMode ?? false;
|
|
102
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;
|
|
103
106
|
let tokenCSS;
|
|
104
107
|
let globalStylesCSS;
|
|
105
108
|
if (mode === "inject") {
|
|
109
|
+
propertyCSS = configProperties.map((prop) => prop.css).join("\n") || void 0;
|
|
106
110
|
tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
|
|
107
111
|
const gs = config.normalized.globalStyles;
|
|
108
112
|
if (Object.keys(gs).length > 0) {
|
|
109
113
|
globalStylesCSS = /* @__PURE__ */ new Map();
|
|
110
114
|
for (const [selector, styles] of Object.entries(gs)) {
|
|
111
|
-
const css = extractCSSFromStyles(selector, styles);
|
|
115
|
+
const css = extractCSSFromStyles(selector, styles, config.normalized.keyframes);
|
|
112
116
|
if (css) globalStylesCSS.set(selector, css);
|
|
113
117
|
}
|
|
114
118
|
if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
|
|
@@ -117,6 +121,8 @@ var babel_default = declare((api, options) => {
|
|
|
117
121
|
return {
|
|
118
122
|
name: "tasty-zero",
|
|
119
123
|
pre() {
|
|
124
|
+
entry.config = reapplyZeroConfig(entry.config);
|
|
125
|
+
setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
|
|
120
126
|
this.staticStyleRegistry = {};
|
|
121
127
|
this._fileAddedCSS = false;
|
|
122
128
|
if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
|
|
@@ -144,9 +150,9 @@ var babel_default = declare((api, options) => {
|
|
|
144
150
|
const args = path.node.arguments;
|
|
145
151
|
if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
|
|
146
152
|
const firstArg = args[0];
|
|
147
|
-
if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.normalized.keyframes,
|
|
148
|
-
else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes,
|
|
149
|
-
else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes,
|
|
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);
|
|
150
156
|
else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
|
|
151
157
|
},
|
|
152
158
|
VariableDeclarator(path, state) {
|
|
@@ -171,10 +177,15 @@ var babel_default = declare((api, options) => {
|
|
|
171
177
|
},
|
|
172
178
|
post() {
|
|
173
179
|
if (mode === "inject") {
|
|
174
|
-
if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
|
|
180
|
+
if (this._fileAddedCSS && (propertyCSS || tokenCSS || globalStylesCSS)) {
|
|
175
181
|
const program = this.file.ast.program;
|
|
176
182
|
let insertIndex = 0;
|
|
177
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
|
+
}
|
|
178
189
|
if (tokenCSS) {
|
|
179
190
|
const injectCall = createInjectCallAST(":root", tokenCSS);
|
|
180
191
|
program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
|
|
@@ -205,17 +216,17 @@ function extractClassNameFromStaticStyleObject(node) {
|
|
|
205
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;
|
|
206
217
|
return null;
|
|
207
218
|
}
|
|
208
|
-
function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes,
|
|
219
|
+
function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
209
220
|
const stylesArg = args[0];
|
|
210
221
|
if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
|
|
211
222
|
const rawStyles = evaluateObjectExpression(stylesArg, path);
|
|
212
223
|
const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
|
|
213
224
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
214
|
-
const properties = extractPropertiesFromStyles(styles,
|
|
225
|
+
const properties = extractPropertiesFromStyles(styles, propertyOptions);
|
|
215
226
|
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
216
227
|
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
217
228
|
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
218
|
-
const chunks =
|
|
229
|
+
const chunks = extractChunks(styles);
|
|
219
230
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
220
231
|
const staticStyleObject = createStaticStyleAST(className, styles);
|
|
221
232
|
if (mode === "inject") {
|
|
@@ -227,7 +238,7 @@ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, gl
|
|
|
227
238
|
}
|
|
228
239
|
registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
|
|
229
240
|
}
|
|
230
|
-
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes,
|
|
241
|
+
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
231
242
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
|
|
232
243
|
const baseArg = args[0];
|
|
233
244
|
const stylesArg = args[1];
|
|
@@ -239,11 +250,11 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
|
|
|
239
250
|
const overrideStyles = evaluateObjectExpression(stylesArg, path);
|
|
240
251
|
const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
|
|
241
252
|
const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
|
|
242
|
-
const properties = extractPropertiesFromStyles(mergedStyles,
|
|
253
|
+
const properties = extractPropertiesFromStyles(mergedStyles, propertyOptions);
|
|
243
254
|
const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
|
|
244
255
|
const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
|
|
245
256
|
const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
|
|
246
|
-
const chunks =
|
|
257
|
+
const chunks = extractChunks(mergedStyles);
|
|
247
258
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
248
259
|
const staticStyleObject = createStaticStyleAST(className, mergedStyles);
|
|
249
260
|
if (mode === "inject") {
|
|
@@ -255,7 +266,7 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
|
|
|
255
266
|
}
|
|
256
267
|
registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
|
|
257
268
|
}
|
|
258
|
-
function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes,
|
|
269
|
+
function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
|
|
259
270
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
|
|
260
271
|
const selectorArg = args[0];
|
|
261
272
|
const stylesArg = args[1];
|
|
@@ -265,12 +276,12 @@ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyfr
|
|
|
265
276
|
const rawStyles = evaluateObjectExpression(stylesArg, path);
|
|
266
277
|
const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
|
|
267
278
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
268
|
-
const properties = extractPropertiesFromStyles(styles,
|
|
279
|
+
const properties = extractPropertiesFromStyles(styles, propertyOptions);
|
|
269
280
|
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
270
281
|
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
271
282
|
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
272
|
-
const
|
|
273
|
-
const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(
|
|
283
|
+
const css = renderSelectorCSS(selector, styles);
|
|
284
|
+
const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(css, nameMap) : css;
|
|
274
285
|
if (mode === "inject") {
|
|
275
286
|
const cssParts = [];
|
|
276
287
|
for (const kf of keyframes) cssParts.push(kf.css);
|
|
@@ -312,9 +323,15 @@ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterSt
|
|
|
312
323
|
cssWriter.add(chunk.className, css, sourceFile);
|
|
313
324
|
}
|
|
314
325
|
}
|
|
315
|
-
function extractCSSFromStyles(selector, styles) {
|
|
326
|
+
function extractCSSFromStyles(selector, styles, globalKeyframes) {
|
|
316
327
|
if (!styles || Object.keys(styles).length === 0) return void 0;
|
|
317
|
-
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);
|
|
318
335
|
}
|
|
319
336
|
function createInjectCallAST(id, css) {
|
|
320
337
|
return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
|
|
@@ -347,7 +364,7 @@ function valueToAST(value) {
|
|
|
347
364
|
if (value === null) return t.nullLiteral();
|
|
348
365
|
if (value === void 0) return t.identifier("undefined");
|
|
349
366
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
350
|
-
if (typeof value === "number") return t.
|
|
367
|
+
if (typeof value === "number") return t.valueToNode(value);
|
|
351
368
|
if (typeof value === "boolean") return t.booleanLiteral(value);
|
|
352
369
|
if (Array.isArray(value)) return t.arrayExpression(value.map(valueToAST));
|
|
353
370
|
if (typeof value === "object") {
|
|
@@ -392,21 +409,7 @@ function evaluateExpression(node, path) {
|
|
|
392
409
|
}
|
|
393
410
|
throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
|
|
394
411
|
}
|
|
395
|
-
function replaceAnimationNamesInCSS(css, nameMap) {
|
|
396
|
-
if (nameMap.size === 0) return css;
|
|
397
|
-
return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
|
|
398
|
-
let newValue = value;
|
|
399
|
-
for (const [original, replacement] of nameMap) {
|
|
400
|
-
const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
|
|
401
|
-
newValue = newValue.replace(pattern, replacement);
|
|
402
|
-
}
|
|
403
|
-
return `${prop}: ${newValue}`;
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
function escapeRegex(str) {
|
|
407
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
408
|
-
}
|
|
409
412
|
//#endregion
|
|
410
|
-
export {
|
|
413
|
+
export { plugin as default };
|
|
411
414
|
|
|
412
415
|
//# sourceMappingURL=babel.js.map
|