@tenphi/tasty 0.0.0-snapshot.dffd134 → 0.0.0-snapshot.e01a0ee

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 (129) hide show
  1. package/README.md +436 -394
  2. package/dist/babel-types-BKDTT4--.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-DlxpZKk_.js +60 -0
  6. package/dist/chunks/build-config-DlxpZKk_.js.map +1 -0
  7. package/dist/{collector-UWhVKseF.js → chunks/collector-B4-yqFEs.js} +25 -119
  8. package/dist/chunks/collector-B4-yqFEs.js.map +1 -0
  9. package/dist/chunks/config-engine-DJsb5WYu.js +272 -0
  10. package/dist/chunks/config-engine-DJsb5WYu.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-DW1TGGiy.js +910 -0
  14. package/dist/chunks/css-definitions-DW1TGGiy.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-DMMwe1rY.js +502 -0
  18. package/dist/chunks/debug-DMMwe1rY.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.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-DhPtFlZs.js +689 -0
  24. package/dist/chunks/react-runtime-DhPtFlZs.js.map +1 -0
  25. package/dist/chunks/runtime-engine-BlrVXv8l.js +2432 -0
  26. package/dist/chunks/runtime-engine-BlrVXv8l.js.map +1 -0
  27. package/dist/chunks/runtime-state-BLyMRYFF.js +152 -0
  28. package/dist/chunks/runtime-state-BLyMRYFF.js.map +1 -0
  29. package/dist/{merge-styles-CVCZ4hgD.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-of5Xbc27.js +5571 -0
  32. package/dist/chunks/style-engine-of5Xbc27.js.map +1 -0
  33. package/dist/{css-writer-DEkJuPH6.js → chunks/zero-engine-D2jPSpWA.js} +65 -145
  34. package/dist/chunks/zero-engine-D2jPSpWA.js.map +1 -0
  35. package/dist/{collector-BPzZezAG.d.ts → collector-CTU-nl0g.d.ts} +23 -4
  36. package/dist/{config-D2INrjr_.d.ts → config-CcxqSZI2.d.ts} +274 -78
  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-BAAbdfRs.d.ts → index--GdqCPlp.d.ts} +366 -257
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -867
  43. package/dist/{merge-styles-NEvqayL_.d.ts → merge-styles-DSkVc6CD.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 +3 -2
  54. package/dist/ssr/astro-middleware-static.js +0 -11
  55. package/dist/ssr/astro-middleware-static.js.map +1 -1
  56. package/dist/ssr/astro-middleware.d.ts +3 -2
  57. package/dist/ssr/astro-middleware.js +0 -12
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -6
  60. package/dist/ssr/astro.js +157 -93
  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 -25
  65. package/dist/ssr/index.js +5 -5
  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 -43
  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-l_NdJSUS.d.ts → types-DJEM_BOJ.d.ts} +751 -590
  78. package/dist/zero/babel.d.ts +67 -2
  79. package/dist/zero/babel.js +77 -140
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +62 -8
  82. package/dist/zero/index.js +24 -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 +16 -8
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +122 -85
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +435 -108
  92. package/docs/debug.md +21 -8
  93. package/docs/design-system.md +152 -31
  94. package/docs/dsl.md +497 -211
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +117 -68
  97. package/docs/methodology.md +81 -50
  98. package/docs/migration-v3.md +52 -52
  99. package/docs/pipeline.md +55 -31
  100. package/docs/plugins.md +59 -75
  101. package/docs/react-api.md +139 -53
  102. package/docs/runtime-benchmarks.md +388 -0
  103. package/docs/ssr.md +285 -101
  104. package/docs/styles.md +128 -33
  105. package/docs/tasty-static.md +272 -135
  106. package/package.json +119 -39
  107. package/dist/async-storage-DKK-wTD4.js +0 -44
  108. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  109. package/dist/babel-HlEpSZrj.d.ts +0 -83
  110. package/dist/collector-UWhVKseF.js.map +0 -1
  111. package/dist/config-BCuFlC1I.js +0 -12180
  112. package/dist/config-BCuFlC1I.js.map +0 -1
  113. package/dist/context-CA8YKeMn.js +0 -24
  114. package/dist/context-CA8YKeMn.js.map +0 -1
  115. package/dist/core-CbMYIizf.js +0 -1550
  116. package/dist/core-CbMYIizf.js.map +0 -1
  117. package/dist/css-writer-DEkJuPH6.js.map +0 -1
  118. package/dist/format-global-rules-DklyaXv-.js +0 -22
  119. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  120. package/dist/format-rules-D2J4PbR5.js +0 -143
  121. package/dist/format-rules-D2J4PbR5.js.map +0 -1
  122. package/dist/hydrate-lZeNoz_w.js +0 -37
  123. package/dist/hydrate-lZeNoz_w.js.map +0 -1
  124. package/dist/index.js.map +0 -1
  125. package/dist/keyframes-BUMyAa-Q.js +0 -424
  126. package/dist/keyframes-BUMyAa-Q.js.map +0 -1
  127. package/dist/merge-styles-CVCZ4hgD.js.map +0 -1
  128. package/dist/resolve-recipes-BnMC1WW1.js +0 -144
  129. package/dist/resolve-recipes-BnMC1WW1.js.map +0 -1
@@ -1,2 +1,67 @@
1
- import { n as _default, r as TastyZeroConfig, t as TastyZeroBabelOptions } from "../babel-HlEpSZrj.js";
2
- export { TastyZeroBabelOptions, type TastyZeroConfig, _default as default };
1
+ import { t as TastyZeroConfig } from "../babel-types-BKDTT4--.js";
2
+ import { PluginPass } from "@babel/core";
3
+ //#region src/zero/babel.d.ts
4
+ /**
5
+ * Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
6
+ */
7
+ export interface TastyZeroBabelOptions {
8
+ /** Output path for generated CSS (default: 'tasty.css') */
9
+ output?: string;
10
+ /**
11
+ * Tasty configuration for build-time processing.
12
+ * Can be a static object or a factory function that returns fresh config.
13
+ * A factory is called on each plugin invocation, enabling hot reload
14
+ * of config values that depend on external files (e.g. theme tokens).
15
+ */
16
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
17
+ /**
18
+ * Absolute path to a TypeScript/JavaScript module that default-exports
19
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
20
+ * plugin invocation, enabling hot reload when the file changes.
21
+ *
22
+ * This option is JSON-serializable and is the primary way Turbopack
23
+ * passes config to the Babel plugin (since Turbopack loader options
24
+ * must be plain primitives/objects/arrays).
25
+ *
26
+ * When both `config` and `configFile` are set, `config` takes precedence.
27
+ *
28
+ * @example '/absolute/path/to/tasty-zero.config.ts'
29
+ */
30
+ configFile?: string;
31
+ /**
32
+ * Absolute file paths whose content affects the generated CSS.
33
+ * When any of these files change, babel-loader invalidates its cache
34
+ * and re-runs the plugin with fresh config values.
35
+ *
36
+ * Typically includes theme files that define Glaze palettes or token values.
37
+ * Paths must be absolute (resolved by the Next.js wrapper).
38
+ */
39
+ configDeps?: string[];
40
+ /**
41
+ * Automatically replace `@tenphi/tasty/static` imports with an import
42
+ * of the generated CSS file. This eliminates the need for users to
43
+ * manually import the CSS in their app entry point.
44
+ *
45
+ * @default true
46
+ */
47
+ injectImport?: boolean;
48
+ /**
49
+ * Output mode for extracted CSS.
50
+ *
51
+ * - `'file'` (default): CSS is written to a single output file and
52
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
53
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
54
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
55
+ * No CSS file is written. Each `tastyStatic` call becomes
56
+ * self-contained. Best for reusable components and extensions.
57
+ *
58
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
59
+ *
60
+ * @default 'file'
61
+ */
62
+ mode?: 'file' | 'inject';
63
+ }
64
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<PluginPass>;
65
+ //#endregion
66
+ export { type TastyZeroConfig, _default as default };
67
+ //# sourceMappingURL=babel.d.ts.map
@@ -1,12 +1,13 @@
1
- import { b as resetConfig, d as getGlobalStyles, i as getGlobalConfigTokens, s as getGlobalFunctions, t as configure } from "../config-BCuFlC1I.js";
2
- import { t as mergeStyles } from "../merge-styles-CVCZ4hgD.js";
3
- import { t as resolveRecipes } from "../resolve-recipes-BnMC1WW1.js";
4
- import { a as extractFunctionsFromStyles, c as extractStylesForSelector, i as extractFontFaceFromStyles, l as extractStylesWithChunks, o as extractKeyframesFromStyles, r as extractCounterStyleFromStyles, s as extractPropertiesFromStyles, t as CSSWriter, u as setExtractorNamePrefix } from "../css-writer-DEkJuPH6.js";
1
+ import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
2
+ import "../chunks/css-definitions-DW1TGGiy.js";
3
+ import { t as resolveRecipesWith } from "../chunks/config-engine-DJsb5WYu.js";
4
+ import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-DlxpZKk_.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-D2jPSpWA.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);
@@ -17,24 +18,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
17
18
  const writerCache = /* @__PURE__ */ new Map();
18
19
  //#endregion
19
20
  //#region src/zero/babel.ts
20
- /**
21
- * Babel plugin for zero-runtime tasty static site generation.
22
- *
23
- * Transforms:
24
- * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
25
- * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
26
- * - `tastyStatic(selector, styles)` → removed entirely
27
- *
28
- * Usage:
29
- * ```javascript
30
- * // babel.config.js
31
- * module.exports = {
32
- * plugins: [
33
- * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
34
- * ]
35
- * };
36
- * ```
37
- */
38
21
  function mtime(filePath) {
39
22
  try {
40
23
  return fs.statSync(filePath).mtimeMs;
@@ -82,50 +65,54 @@ var babel_default = declare((api, options) => {
82
65
  const configOption = options.config;
83
66
  let resolvedConfig;
84
67
  if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
85
- else if (options.configFile) {
86
- const loaded = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
87
- resolvedConfig = loaded && typeof loaded === "object" && "default" in loaded ? loaded.default : loaded;
88
- } else resolvedConfig = {};
68
+ else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
69
+ else resolvedConfig = {};
89
70
  const devMode = resolvedConfig.devMode ?? false;
90
- if (cached) resetConfig();
71
+ resetZeroConfig();
91
72
  const finalConfig = {
92
73
  namePrefix: "ts",
93
74
  ...resolvedConfig
94
75
  };
95
- configure(finalConfig);
76
+ const config = configureZero(finalConfig);
96
77
  setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
97
78
  const newWriter = new CSSWriter(outputPath, { devMode });
98
79
  if (mode !== "inject") {
99
- 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);
100
82
  if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
101
- const globalStyles = getGlobalStyles();
102
- if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
103
- const css = extractCSSFromStyles(selector, styles);
104
- if (css) newWriter.add(`global:${selector}`, css);
105
- }
83
+ for (const [selector, styles] of Object.entries(config.normalized.globalStyles)) writeGlobalStyles(newWriter, selector, styles, config.normalized.keyframes);
106
84
  }
107
85
  writerCache.set(resolvedOutputPath, {
108
86
  writer: newWriter,
109
87
  configKey,
110
88
  registry: {},
111
- config: finalConfig
89
+ config
112
90
  });
113
91
  }
114
92
  const entry = writerCache.get(resolvedOutputPath);
93
+ entry.config = reapplyZeroConfig(entry.config);
115
94
  const cssWriter = entry.writer;
116
95
  const globalRegistry = entry.registry;
117
96
  const config = entry.config;
118
- const devMode = config.devMode ?? false;
119
- 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;
120
106
  let tokenCSS;
121
107
  let globalStylesCSS;
122
108
  if (mode === "inject") {
123
- tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
124
- const gs = getGlobalStyles();
125
- 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) {
126
113
  globalStylesCSS = /* @__PURE__ */ new Map();
127
114
  for (const [selector, styles] of Object.entries(gs)) {
128
- const css = extractCSSFromStyles(selector, styles);
115
+ const css = extractCSSFromStyles(selector, styles, config.normalized.keyframes);
129
116
  if (css) globalStylesCSS.set(selector, css);
130
117
  }
131
118
  if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
@@ -134,6 +121,8 @@ var babel_default = declare((api, options) => {
134
121
  return {
135
122
  name: "tasty-zero",
136
123
  pre() {
124
+ entry.config = reapplyZeroConfig(entry.config);
125
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
137
126
  this.staticStyleRegistry = {};
138
127
  this._fileAddedCSS = false;
139
128
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
@@ -141,16 +130,18 @@ var babel_default = declare((api, options) => {
141
130
  visitor: {
142
131
  ImportDeclaration(nodePath, state) {
143
132
  const source = nodePath.node.source.value;
144
- 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")));
145
- else if (injectImport) {
146
- let importPath = resolvedOutputPath;
147
- if (state.filename) {
148
- const sourceDir = path.dirname(state.filename);
149
- importPath = path.relative(sourceDir, resolvedOutputPath);
150
- if (!importPath.startsWith(".")) importPath = "./" + importPath;
151
- }
152
- nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
153
- } 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
+ }
154
145
  },
155
146
  CallExpression(path, state) {
156
147
  const callee = path.node.callee;
@@ -159,9 +150,9 @@ var babel_default = declare((api, options) => {
159
150
  const args = path.node.arguments;
160
151
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
161
152
  const firstArg = args[0];
162
- if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
163
- else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
164
- else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
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);
165
156
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
166
157
  },
167
158
  VariableDeclarator(path, state) {
@@ -186,10 +177,15 @@ var babel_default = declare((api, options) => {
186
177
  },
187
178
  post() {
188
179
  if (mode === "inject") {
189
- if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
180
+ if (this._fileAddedCSS && (propertyCSS || tokenCSS || globalStylesCSS)) {
190
181
  const program = this.file.ast.program;
191
182
  let insertIndex = 0;
192
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
+ }
193
189
  if (tokenCSS) {
194
190
  const injectCall = createInjectCallAST(":root", tokenCSS);
195
191
  program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
@@ -207,41 +203,30 @@ var babel_default = declare((api, options) => {
207
203
  }
208
204
  };
209
205
  });
210
- /**
211
- * Check if an object expression looks like a StaticStyle object
212
- */
213
206
  function isStaticStyleObject(node) {
214
207
  const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
215
208
  const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
216
209
  return hasClassName && hasStyles;
217
210
  }
218
- /**
219
- * Extract styles object from a StaticStyle object expression
220
- */
221
211
  function extractStylesFromStaticStyleObject(node, path) {
222
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);
223
213
  return null;
224
214
  }
225
- /**
226
- * Extract className from a StaticStyle object expression
227
- */
228
215
  function extractClassNameFromStaticStyleObject(node) {
229
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;
230
217
  return null;
231
218
  }
232
- /**
233
- * Handle tastyStatic(styles) - returns StaticStyle object
234
- */
235
- function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle, globalFunction) {
219
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
236
220
  const stylesArg = args[0];
237
221
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
238
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
222
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
223
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
239
224
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
240
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
225
+ const properties = extractPropertiesFromStyles(styles, propertyOptions);
241
226
  const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
242
227
  const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
243
228
  const functions = extractFunctionsFromStyles(styles, globalFunction);
244
- const chunks = extractStylesWithChunks(styles);
229
+ const chunks = extractChunks(styles);
245
230
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
246
231
  const staticStyleObject = createStaticStyleAST(className, styles);
247
232
  if (mode === "inject") {
@@ -253,10 +238,7 @@ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, gl
253
238
  }
254
239
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
255
240
  }
256
- /**
257
- * Handle tastyStatic(base, styles) - extends base with additional styles
258
- */
259
- function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle, globalFunction) {
241
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
260
242
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
261
243
  const baseArg = args[0];
262
244
  const stylesArg = args[1];
@@ -266,13 +248,13 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
266
248
  const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
267
249
  if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
268
250
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
269
- const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
251
+ const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
270
252
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
271
- const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
253
+ const properties = extractPropertiesFromStyles(mergedStyles, propertyOptions);
272
254
  const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
273
255
  const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
274
256
  const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
275
- const chunks = extractStylesWithChunks(mergedStyles);
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") {
@@ -284,24 +266,22 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode,
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, globalFunction) {
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
282
  const functions = extractFunctionsFromStyles(styles, globalFunction);
303
- const result = extractStylesForSelector(selector, styles);
304
- const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
283
+ const css = renderSelectorCSS(selector, styles);
284
+ const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(css, nameMap) : css;
305
285
  if (mode === "inject") {
306
286
  const cssParts = [];
307
287
  for (const kf of keyframes) cssParts.push(kf.css);
@@ -322,9 +302,6 @@ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyfr
322
302
  else path.replaceWith(t.identifier("undefined"));
323
303
  }
324
304
  }
325
- /**
326
- * Collect all extracted CSS parts into a single string (for inject mode).
327
- */
328
305
  function collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap) {
329
306
  const parts = [];
330
307
  for (const kf of keyframes) parts.push(kf.css);
@@ -335,9 +312,6 @@ function collectAllCSS(keyframes, properties, fontFaces, counterStyles, function
335
312
  for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
336
313
  return parts.join("\n");
337
314
  }
338
- /**
339
- * Write all extracted CSS parts to a CSSWriter (for file mode).
340
- */
341
315
  function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, sourceFile) {
342
316
  for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
343
317
  for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
@@ -349,23 +323,19 @@ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterSt
349
323
  cssWriter.add(chunk.className, css, sourceFile);
350
324
  }
351
325
  }
352
- /**
353
- * Extract CSS for a selector from a styles/tokens object.
354
- * Returns undefined when there are no styles or no CSS output.
355
- */
356
- function extractCSSFromStyles(selector, styles) {
326
+ function extractCSSFromStyles(selector, styles, globalKeyframes) {
357
327
  if (!styles || Object.keys(styles).length === 0) return void 0;
358
- 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);
359
335
  }
360
- /**
361
- * Create an `_$i(id, css)` call expression AST node for inject mode.
362
- */
363
336
  function createInjectCallAST(id, css) {
364
337
  return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
365
338
  }
366
- /**
367
- * Create a StaticStyle object AST node
368
- */
369
339
  function createStaticStyleAST(className, styles) {
370
340
  return t.objectExpression([
371
341
  t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
@@ -373,9 +343,6 @@ function createStaticStyleAST(className, styles) {
373
343
  t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
374
344
  ]);
375
345
  }
376
- /**
377
- * Register a StaticStyle in the registry if it's being assigned to a variable
378
- */
379
346
  function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
380
347
  const parent = path.parentPath;
381
348
  if (parent && t.isVariableDeclarator(parent.node)) {
@@ -393,9 +360,6 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
393
360
  }
394
361
  }
395
362
  }
396
- /**
397
- * Convert a JavaScript value to an AST node
398
- */
399
363
  function valueToAST(value) {
400
364
  if (value === null) return t.nullLiteral();
401
365
  if (value === void 0) return t.identifier("undefined");
@@ -409,10 +373,6 @@ function valueToAST(value) {
409
373
  }
410
374
  return t.identifier("undefined");
411
375
  }
412
- /**
413
- * Evaluate an ObjectExpression to a plain JavaScript object.
414
- * Only supports static values that can be determined at build time.
415
- */
416
376
  function evaluateObjectExpression(node, path) {
417
377
  const result = {};
418
378
  for (const prop of node.properties) {
@@ -422,13 +382,11 @@ function evaluateObjectExpression(node, path) {
422
382
  if (t.isIdentifier(prop.key)) key = prop.key.name;
423
383
  else if (t.isStringLiteral(prop.key)) key = prop.key.value;
424
384
  else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
425
- result[key] = evaluateExpression(prop.value, path);
385
+ const value = evaluateExpression(prop.value, path);
386
+ result[key] = value;
426
387
  }
427
388
  return result;
428
389
  }
429
- /**
430
- * Evaluate an expression to a JavaScript value.
431
- */
432
390
  function evaluateExpression(node, path) {
433
391
  if (t.isStringLiteral(node)) return node.value;
434
392
  if (t.isNumericLiteral(node)) return node.value;
@@ -451,27 +409,6 @@ function evaluateExpression(node, path) {
451
409
  }
452
410
  throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
453
411
  }
454
- /**
455
- * Replace animation names in CSS string.
456
- * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
457
- */
458
- function replaceAnimationNamesInCSS(css, nameMap) {
459
- if (nameMap.size === 0) return css;
460
- return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
461
- let newValue = value;
462
- for (const [original, replacement] of nameMap) {
463
- const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
464
- newValue = newValue.replace(pattern, replacement);
465
- }
466
- return `${prop}: ${newValue}`;
467
- });
468
- }
469
- /**
470
- * Escape special regex characters.
471
- */
472
- function escapeRegex(str) {
473
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
474
- }
475
412
  //#endregion
476
413
  export { babel_default as default };
477
414