@tenphi/tasty 0.0.0-snapshot.047dfbb → 0.0.0-snapshot.04fb534

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.
Files changed (134) hide show
  1. package/README.md +452 -370
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config--0qoqt_P.js +60 -0
  6. package/dist/chunks/build-config--0qoqt_P.js.map +1 -0
  7. package/dist/{collector-J6LwZR0N.js → chunks/collector-zp5BrLF0.js} +68 -101
  8. package/dist/chunks/collector-zp5BrLF0.js.map +1 -0
  9. package/dist/chunks/config-engine-BaLq8HrX.js +272 -0
  10. package/dist/chunks/config-engine-BaLq8HrX.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-CfXZ3tU9.js +910 -0
  14. package/dist/chunks/css-definitions-CfXZ3tU9.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug--OC-WA-Q.js +502 -0
  18. package/dist/chunks/debug--OC-WA-Q.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DnZ6M1Iv.js +691 -0
  24. package/dist/chunks/react-runtime-DnZ6M1Iv.js.map +1 -0
  25. package/dist/chunks/runtime-engine-J9X_h-Pw.js +2435 -0
  26. package/dist/chunks/runtime-engine-J9X_h-Pw.js.map +1 -0
  27. package/dist/chunks/runtime-state-o_v3Bj7b.js +152 -0
  28. package/dist/chunks/runtime-state-o_v3Bj7b.js.map +1 -0
  29. package/dist/{merge-styles-CAdKaHxh.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D6lC3O3G.js +5626 -0
  32. package/dist/chunks/style-engine-D6lC3O3G.js.map +1 -0
  33. package/dist/{css-writer-IC7tdnIf.js → chunks/zero-engine-BnjoV04F.js} +95 -136
  34. package/dist/chunks/zero-engine-BnjoV04F.js.map +1 -0
  35. package/dist/{collector-CddJZDOr.d.ts → collector-D2OT6I2G.d.ts} +64 -8
  36. package/dist/{config-C3SKYuxY.d.ts → config-C4ftFxgI.d.ts} +514 -92
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-ByBYTH9l.d.ts → index-DxQNRj50.d.ts} +586 -400
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-CvUi7SOD.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +160 -86
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -32
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +9 -8
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/{index-C5owZ15q.d.ts → types-CYQIhUg1.d.ts} +874 -598
  78. package/dist/zero/babel.d.ts +12 -19
  79. package/dist/zero/babel.js +97 -156
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +76 -7
  82. package/dist/zero/index.js +25 -2
  83. package/dist/zero/index.js.map +1 -0
  84. package/dist/zero/next.d.ts +4 -5
  85. package/dist/zero/next.js +3 -38
  86. package/dist/zero/next.js.map +1 -1
  87. package/docs/README.md +20 -9
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +259 -0
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +617 -98
  92. package/docs/debug.md +28 -15
  93. package/docs/design-system.md +166 -33
  94. package/docs/dsl.md +637 -205
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +160 -69
  97. package/docs/llms.txt +31 -0
  98. package/docs/methodology.md +82 -51
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +57 -33
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +215 -50
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -118
  105. package/docs/styles.md +209 -41
  106. package/docs/tasty-static.md +289 -136
  107. package/harness/dev.harnesspm/rules/usage.md +12 -0
  108. package/harness/dev.harnesspm/scripts/render.mjs +441 -0
  109. package/harness/dev.harnesspm/scripts/styles.mjs +412 -0
  110. package/harness/plugin.json +20 -0
  111. package/package.json +148 -49
  112. package/tasty.config.ts +5 -0
  113. package/dist/async-storage-DKK-wTD4.js +0 -44
  114. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  115. package/dist/collector-J6LwZR0N.js.map +0 -1
  116. package/dist/config-C3F4Ogo1.js +0 -10993
  117. package/dist/config-C3F4Ogo1.js.map +0 -1
  118. package/dist/context-CA8YKeMn.js +0 -24
  119. package/dist/context-CA8YKeMn.js.map +0 -1
  120. package/dist/core-DxHmF6S9.js +0 -1598
  121. package/dist/core-DxHmF6S9.js.map +0 -1
  122. package/dist/css-writer-IC7tdnIf.js.map +0 -1
  123. package/dist/format-global-rules-DklyaXv-.js +0 -22
  124. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  125. package/dist/format-rules-DTLY39Hm.js +0 -143
  126. package/dist/format-rules-DTLY39Hm.js.map +0 -1
  127. package/dist/hydrate-8Zglgy_C.js +0 -45
  128. package/dist/hydrate-8Zglgy_C.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/keyframes-DgGkipNK.js +0 -595
  131. package/dist/keyframes-DgGkipNK.js.map +0 -1
  132. package/dist/merge-styles-CAdKaHxh.js.map +0 -1
  133. package/dist/resolve-recipes-BQNdunBd.js +0 -144
  134. package/dist/resolve-recipes-BQNdunBd.js.map +0 -1
@@ -1,21 +1,9 @@
1
- import { t as TastyConfig } from "../config-C3SKYuxY.js";
2
- import { PluginPass } from "@babel/core";
3
-
1
+ import { t as TastyZeroConfig } from "../babel-types-Dc5zghyE.js";
4
2
  //#region src/zero/babel.d.ts
5
3
  /**
6
- * Build-time configuration for zero-runtime mode.
7
- * Subset of TastyConfig excluding runtime-only DOM options
8
- * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
9
- * and overriding `devMode` default to `false`.
4
+ * Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
10
5
  */
11
- type TastyZeroConfig = Omit<TastyConfig, 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'> & {
12
- /**
13
- * Enable development mode features: source comments in generated CSS.
14
- * @default false
15
- */
16
- devMode?: boolean;
17
- };
18
- interface TastyZeroBabelOptions {
6
+ export interface TastyZeroBabelOptions {
19
7
  /** Output path for generated CSS (default: 'tasty.css') */
20
8
  output?: string;
21
9
  /**
@@ -72,9 +60,14 @@ interface TastyZeroBabelOptions {
72
60
  */
73
61
  mode?: 'file' | 'inject';
74
62
  }
75
- /** Clear the shared CSSWriter cache. Exposed for testing. */
76
- declare function clearWriterCache(): void;
77
- declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<PluginPass>;
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;
78
71
  //#endregion
79
- export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
72
+ export { type TastyZeroConfig, _default as default };
80
73
  //# sourceMappingURL=babel.d.ts.map
@@ -1,37 +1,23 @@
1
- import { i as getGlobalConfigTokens, t as configure, u as getGlobalStyles, v as resetConfig } from "../config-C3F4Ogo1.js";
2
- import { t as mergeStyles } from "../merge-styles-CAdKaHxh.js";
3
- import { t as resolveRecipes } from "../resolve-recipes-BQNdunBd.js";
4
- import { a as extractPropertiesFromStyles, c as setExtractorNamePrefix, i as extractKeyframesFromStyles, n as extractCounterStyleFromStyles, o as extractStylesForSelector, r as extractFontFaceFromStyles, s as extractStylesWithChunks, t as CSSWriter } from "../css-writer-IC7tdnIf.js";
1
+ import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
2
+ import "../chunks/css-definitions-CfXZ3tU9.js";
3
+ import { t as resolveRecipesWith } from "../chunks/config-engine-BaLq8HrX.js";
4
+ import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config--0qoqt_P.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-BnjoV04F.js";
6
+ import { t as loadConfigFile } from "../chunks/config-file-DlZXJMj8.js";
5
7
  import * as fs from "fs";
6
8
  import * as path from "path";
7
9
  import { declare } from "@babel/helper-plugin-utils";
8
10
  import * as t from "@babel/types";
9
- import { createJiti } from "jiti";
10
11
  //#region \0rolldown/runtime.js
11
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) {
12
13
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
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.");
14
15
  });
15
16
  //#endregion
17
+ //#region src/zero/writer-cache.ts
18
+ const writerCache = /* @__PURE__ */ new Map();
19
+ //#endregion
16
20
  //#region src/zero/babel.ts
17
- /**
18
- * Babel plugin for zero-runtime tasty static site generation.
19
- *
20
- * Transforms:
21
- * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
22
- * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
23
- * - `tastyStatic(selector, styles)` → removed entirely
24
- *
25
- * Usage:
26
- * ```javascript
27
- * // babel.config.js
28
- * module.exports = {
29
- * plugins: [
30
- * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
31
- * ]
32
- * };
33
- * ```
34
- */
35
21
  function mtime(filePath) {
36
22
  try {
37
23
  return fs.statSync(filePath).mtimeMs;
@@ -54,13 +40,8 @@ function clearRequireCacheTree(filePath) {
54
40
  }
55
41
  delete __require.cache[resolved];
56
42
  }
57
- const writerCache = /* @__PURE__ */ new Map();
58
- /** Clear the shared CSSWriter cache. Exposed for testing. */
59
- function clearWriterCache() {
60
- writerCache.clear();
61
- }
62
- var babel_default = declare((api, options) => {
63
- api.assertVersion(7);
43
+ const plugin = declare((api, options) => {
44
+ api.assertVersion("^7.0.0-0 || ^8.0.0-0");
64
45
  const mode = options.mode ?? "file";
65
46
  const outputPath = options.output || "tasty.css";
66
47
  const resolvedOutputPath = path.resolve(outputPath);
@@ -84,50 +65,54 @@ var babel_default = declare((api, options) => {
84
65
  const configOption = options.config;
85
66
  let resolvedConfig;
86
67
  if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
87
- else if (options.configFile) {
88
- const loaded = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
89
- resolvedConfig = loaded && typeof loaded === "object" && "default" in loaded ? loaded.default : loaded;
90
- } else resolvedConfig = {};
68
+ else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
69
+ else resolvedConfig = {};
91
70
  const devMode = resolvedConfig.devMode ?? false;
92
- if (cached) resetConfig();
71
+ resetZeroConfig();
93
72
  const finalConfig = {
94
73
  namePrefix: "ts",
95
74
  ...resolvedConfig
96
75
  };
97
- configure(finalConfig);
76
+ const config = configureZero(finalConfig);
98
77
  setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
99
78
  const newWriter = new CSSWriter(outputPath, { devMode });
100
79
  if (mode !== "inject") {
101
- const tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
80
+ for (const prop of extractConfigProperties(config.normalized.properties)) newWriter.add(`@property:${prop.name}`, prop.css);
81
+ const tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
102
82
  if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
103
- const globalStyles = getGlobalStyles();
104
- if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
105
- const css = extractCSSFromStyles(selector, styles);
106
- if (css) newWriter.add(`global:${selector}`, css);
107
- }
83
+ for (const [selector, styles] of Object.entries(config.normalized.globalStyles)) writeGlobalStyles(newWriter, selector, styles, config.normalized.keyframes);
108
84
  }
109
85
  writerCache.set(resolvedOutputPath, {
110
86
  writer: newWriter,
111
87
  configKey,
112
88
  registry: {},
113
- config: finalConfig
89
+ config
114
90
  });
115
91
  }
116
92
  const entry = writerCache.get(resolvedOutputPath);
93
+ entry.config = reapplyZeroConfig(entry.config);
117
94
  const cssWriter = entry.writer;
118
95
  const globalRegistry = entry.registry;
119
96
  const config = entry.config;
120
- const devMode = config.devMode ?? false;
121
- setExtractorNamePrefix(config.namePrefix ?? "ts");
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;
122
106
  let tokenCSS;
123
107
  let globalStylesCSS;
124
108
  if (mode === "inject") {
125
- tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
126
- const gs = getGlobalStyles();
127
- if (gs) {
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) {
128
113
  globalStylesCSS = /* @__PURE__ */ new Map();
129
114
  for (const [selector, styles] of Object.entries(gs)) {
130
- const css = extractCSSFromStyles(selector, styles);
115
+ const css = extractCSSFromStyles(selector, styles, config.normalized.keyframes);
131
116
  if (css) globalStylesCSS.set(selector, css);
132
117
  }
133
118
  if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
@@ -136,6 +121,8 @@ var babel_default = declare((api, options) => {
136
121
  return {
137
122
  name: "tasty-zero",
138
123
  pre() {
124
+ entry.config = reapplyZeroConfig(entry.config);
125
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
139
126
  this.staticStyleRegistry = {};
140
127
  this._fileAddedCSS = false;
141
128
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
@@ -143,16 +130,18 @@ var babel_default = declare((api, options) => {
143
130
  visitor: {
144
131
  ImportDeclaration(nodePath, state) {
145
132
  const source = nodePath.node.source.value;
146
- 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")));
147
- else if (injectImport) {
148
- let importPath = resolvedOutputPath;
149
- if (state.filename) {
150
- const sourceDir = path.dirname(state.filename);
151
- importPath = path.relative(sourceDir, resolvedOutputPath);
152
- if (!importPath.startsWith(".")) importPath = "./" + importPath;
153
- }
154
- nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
155
- } else nodePath.remove();
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
+ }
156
145
  },
157
146
  CallExpression(path, state) {
158
147
  const callee = path.node.callee;
@@ -161,9 +150,9 @@ var babel_default = declare((api, options) => {
161
150
  const args = path.node.arguments;
162
151
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
163
152
  const firstArg = args[0];
164
- if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
165
- else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
166
- else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
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);
167
156
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
168
157
  },
169
158
  VariableDeclarator(path, state) {
@@ -188,10 +177,15 @@ var babel_default = declare((api, options) => {
188
177
  },
189
178
  post() {
190
179
  if (mode === "inject") {
191
- if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
180
+ if (this._fileAddedCSS && (propertyCSS || tokenCSS || globalStylesCSS)) {
192
181
  const program = this.file.ast.program;
193
182
  let insertIndex = 0;
194
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
+ }
195
189
  if (tokenCSS) {
196
190
  const injectCall = createInjectCallAST(":root", tokenCSS);
197
191
  program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
@@ -209,55 +203,42 @@ var babel_default = declare((api, options) => {
209
203
  }
210
204
  };
211
205
  });
212
- /**
213
- * Check if an object expression looks like a StaticStyle object
214
- */
215
206
  function isStaticStyleObject(node) {
216
207
  const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
217
208
  const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
218
209
  return hasClassName && hasStyles;
219
210
  }
220
- /**
221
- * Extract styles object from a StaticStyle object expression
222
- */
223
211
  function extractStylesFromStaticStyleObject(node, path) {
224
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);
225
213
  return null;
226
214
  }
227
- /**
228
- * Extract className from a StaticStyle object expression
229
- */
230
215
  function extractClassNameFromStaticStyleObject(node) {
231
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;
232
217
  return null;
233
218
  }
234
- /**
235
- * Handle tastyStatic(styles) - returns StaticStyle object
236
- */
237
- 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) {
238
220
  const stylesArg = args[0];
239
221
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
240
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
222
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
223
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
241
224
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
242
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
225
+ const properties = extractPropertiesFromStyles(styles, propertyOptions);
243
226
  const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
244
227
  const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
245
- const chunks = extractStylesWithChunks(styles);
228
+ const functions = extractFunctionsFromStyles(styles, globalFunction);
229
+ const chunks = extractChunks(styles);
246
230
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
247
231
  const staticStyleObject = createStaticStyleAST(className, styles);
248
232
  if (mode === "inject") {
249
- const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
233
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
250
234
  path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
251
235
  } else {
252
- writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
236
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
253
237
  path.replaceWith(staticStyleObject);
254
238
  }
255
239
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
256
240
  }
257
- /**
258
- * Handle tastyStatic(base, styles) - extends base with additional styles
259
- */
260
- 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) {
261
242
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
262
243
  const baseArg = args[0];
263
244
  const stylesArg = args[1];
@@ -267,101 +248,94 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
267
248
  const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
268
249
  if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
269
250
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
270
- const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
251
+ const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
271
252
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
272
- const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
253
+ const properties = extractPropertiesFromStyles(mergedStyles, propertyOptions);
273
254
  const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
274
255
  const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
275
- const chunks = extractStylesWithChunks(mergedStyles);
256
+ const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
257
+ const chunks = extractChunks(mergedStyles);
276
258
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
277
259
  const staticStyleObject = createStaticStyleAST(className, mergedStyles);
278
260
  if (mode === "inject") {
279
- const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
261
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
280
262
  path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
281
263
  } else {
282
- writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
264
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
283
265
  path.replaceWith(staticStyleObject);
284
266
  }
285
267
  registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
286
268
  }
287
- /**
288
- * Handle tastyStatic(selector, styles) - removes the call entirely
289
- */
290
- 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) {
291
270
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
292
271
  const selectorArg = args[0];
293
272
  const stylesArg = args[1];
294
273
  if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
295
274
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
296
275
  const selector = selectorArg.value;
297
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
276
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
277
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
298
278
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
299
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
279
+ const properties = extractPropertiesFromStyles(styles, propertyOptions);
300
280
  const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
301
281
  const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
302
- const result = extractStylesForSelector(selector, styles);
303
- const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
282
+ const functions = extractFunctionsFromStyles(styles, globalFunction);
283
+ const css = renderSelectorCSS(selector, styles);
284
+ const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(css, nameMap) : css;
304
285
  if (mode === "inject") {
305
286
  const cssParts = [];
306
287
  for (const kf of keyframes) cssParts.push(kf.css);
307
288
  for (const prop of properties) cssParts.push(prop.css);
308
289
  for (const ff of fontFaces) cssParts.push(ff.css);
309
290
  for (const cs of counterStyles) cssParts.push(cs.css);
291
+ for (const fn of functions) cssParts.push(fn.css);
310
292
  cssParts.push(selectorCSS);
311
293
  const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
312
294
  const parent = path.parentPath;
313
295
  if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
314
296
  else path.replaceWith(injectCall);
315
297
  } else {
316
- writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, [], nameMap, sourceFile);
298
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, [], nameMap, sourceFile);
317
299
  cssWriter.add(selector, selectorCSS, sourceFile);
318
300
  const parent = path.parentPath;
319
301
  if (parent && t.isExpressionStatement(parent.node)) parent.remove();
320
302
  else path.replaceWith(t.identifier("undefined"));
321
303
  }
322
304
  }
323
- /**
324
- * Collect all extracted CSS parts into a single string (for inject mode).
325
- */
326
- function collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap) {
305
+ function collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap) {
327
306
  const parts = [];
328
307
  for (const kf of keyframes) parts.push(kf.css);
329
308
  for (const prop of properties) parts.push(prop.css);
330
309
  for (const ff of fontFaces) parts.push(ff.css);
331
310
  for (const cs of counterStyles) parts.push(cs.css);
311
+ for (const fn of functions) parts.push(fn.css);
332
312
  for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
333
313
  return parts.join("\n");
334
314
  }
335
- /**
336
- * Write all extracted CSS parts to a CSSWriter (for file mode).
337
- */
338
- function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, sourceFile) {
315
+ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, sourceFile) {
339
316
  for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
340
317
  for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
341
318
  for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
342
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);
343
321
  for (const chunk of chunks) {
344
322
  const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
345
323
  cssWriter.add(chunk.className, css, sourceFile);
346
324
  }
347
325
  }
348
- /**
349
- * Extract CSS for a selector from a styles/tokens object.
350
- * Returns undefined when there are no styles or no CSS output.
351
- */
352
- function extractCSSFromStyles(selector, styles) {
326
+ function extractCSSFromStyles(selector, styles, globalKeyframes) {
353
327
  if (!styles || Object.keys(styles).length === 0) return void 0;
354
- return extractStylesForSelector(selector, styles).css || void 0;
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);
355
335
  }
356
- /**
357
- * Create an `_$i(id, css)` call expression AST node for inject mode.
358
- */
359
336
  function createInjectCallAST(id, css) {
360
337
  return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
361
338
  }
362
- /**
363
- * Create a StaticStyle object AST node
364
- */
365
339
  function createStaticStyleAST(className, styles) {
366
340
  return t.objectExpression([
367
341
  t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
@@ -369,9 +343,6 @@ function createStaticStyleAST(className, styles) {
369
343
  t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
370
344
  ]);
371
345
  }
372
- /**
373
- * Register a StaticStyle in the registry if it's being assigned to a variable
374
- */
375
346
  function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
376
347
  const parent = path.parentPath;
377
348
  if (parent && t.isVariableDeclarator(parent.node)) {
@@ -389,14 +360,11 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
389
360
  }
390
361
  }
391
362
  }
392
- /**
393
- * Convert a JavaScript value to an AST node
394
- */
395
363
  function valueToAST(value) {
396
364
  if (value === null) return t.nullLiteral();
397
365
  if (value === void 0) return t.identifier("undefined");
398
366
  if (typeof value === "string") return t.stringLiteral(value);
399
- if (typeof value === "number") return t.numericLiteral(value);
367
+ if (typeof value === "number") return t.valueToNode(value);
400
368
  if (typeof value === "boolean") return t.booleanLiteral(value);
401
369
  if (Array.isArray(value)) return t.arrayExpression(value.map(valueToAST));
402
370
  if (typeof value === "object") {
@@ -405,10 +373,6 @@ function valueToAST(value) {
405
373
  }
406
374
  return t.identifier("undefined");
407
375
  }
408
- /**
409
- * Evaluate an ObjectExpression to a plain JavaScript object.
410
- * Only supports static values that can be determined at build time.
411
- */
412
376
  function evaluateObjectExpression(node, path) {
413
377
  const result = {};
414
378
  for (const prop of node.properties) {
@@ -418,13 +382,11 @@ function evaluateObjectExpression(node, path) {
418
382
  if (t.isIdentifier(prop.key)) key = prop.key.name;
419
383
  else if (t.isStringLiteral(prop.key)) key = prop.key.value;
420
384
  else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
421
- result[key] = evaluateExpression(prop.value, path);
385
+ const value = evaluateExpression(prop.value, path);
386
+ result[key] = value;
422
387
  }
423
388
  return result;
424
389
  }
425
- /**
426
- * Evaluate an expression to a JavaScript value.
427
- */
428
390
  function evaluateExpression(node, path) {
429
391
  if (t.isStringLiteral(node)) return node.value;
430
392
  if (t.isNumericLiteral(node)) return node.value;
@@ -447,28 +409,7 @@ function evaluateExpression(node, path) {
447
409
  }
448
410
  throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
449
411
  }
450
- /**
451
- * Replace animation names in CSS string.
452
- * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
453
- */
454
- function replaceAnimationNamesInCSS(css, nameMap) {
455
- if (nameMap.size === 0) return css;
456
- return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
457
- let newValue = value;
458
- for (const [original, replacement] of nameMap) {
459
- const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
460
- newValue = newValue.replace(pattern, replacement);
461
- }
462
- return `${prop}: ${newValue}`;
463
- });
464
- }
465
- /**
466
- * Escape special regex characters.
467
- */
468
- function escapeRegex(str) {
469
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
470
- }
471
412
  //#endregion
472
- export { clearWriterCache, babel_default as default };
413
+ export { plugin as default };
473
414
 
474
415
  //# sourceMappingURL=babel.js.map