@pandacss/generator 0.23.0 → 0.24.0

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/dist/index.js CHANGED
@@ -82,7 +82,7 @@ var artifactsGenerated = (ctx) => {
82
82
  var configExists = (cmd) => import_outdent.outdent`
83
83
  \n
84
84
  It looks like you already have panda created\`.
85
-
85
+
86
86
  You can now run ${(0, import_logger.quote)(cmd, " panda --watch")}.
87
87
 
88
88
  `;
@@ -96,9 +96,9 @@ var thankYou = () => import_outdent.outdent`
96
96
  var codegenComplete = () => import_outdent.outdent`
97
97
 
98
98
  ${import_logger.colors.bold().cyan("Next steps:")}
99
-
99
+
100
100
  [1] Create a ${(0, import_logger.quote)("index.css")} file in your project that contains:
101
-
101
+
102
102
  @layer reset, base, tokens, recipes, utilities;
103
103
 
104
104
 
@@ -132,7 +132,7 @@ var getMessages = (ctx) => ({
132
132
  });
133
133
 
134
134
  // src/generator.ts
135
- var import_ts_pattern12 = require("ts-pattern");
135
+ var import_ts_pattern11 = require("ts-pattern");
136
136
 
137
137
  // src/artifacts/setup-artifacts.ts
138
138
  var import_outdent44 = __toESM(require("outdent"));
@@ -2832,7 +2832,7 @@ var selectors_d_ts_default = {
2832
2832
 
2833
2833
  // src/artifacts/generated/static-css.d.ts.json
2834
2834
  var static_css_d_ts_default = {
2835
- content: "interface CssRule {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: string[]\n }\n /**\n * The css conditions to generate utilities for.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n /**\n * Whether to generate responsive utilities.\n */\n responsive?: boolean\n}\n\nexport type RecipeRule =\n | '*'\n | ({\n conditions?: string[]\n responsive?: boolean\n } & { [variant: string]: boolean | string[] })\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n}\n"
2835
+ content: "interface WithConditions {\n /**\n * The css conditions to generate for the rule.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n responsive?: boolean\n}\n\nexport interface CssRule extends WithConditions {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: Array<string | number>\n }\n}\n\ninterface RecipeRuleVariants {\n [variant: string]: boolean | string[]\n}\n\nexport type RecipeRule = '*' | (RecipeRuleVariants & WithConditions)\nexport type PatternRule = '*' | CssRule\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n /**\n * The css patterns to generate.\n */\n patterns?: {\n [pattern: string]: PatternRule[]\n }\n}\n"
2836
2836
  };
2837
2837
 
2838
2838
  // src/artifacts/types/generated.ts
@@ -3297,11 +3297,11 @@ function setupJsxFactory(ctx) {
3297
3297
  function setupJsxHelpers(ctx) {
3298
3298
  if (!ctx.jsx.framework)
3299
3299
  return;
3300
- const helpers3 = generatedJsxHelpers(ctx);
3300
+ const helpers = generatedJsxHelpers(ctx);
3301
3301
  return {
3302
3302
  id: "jsx-helpers",
3303
3303
  dir: ctx.paths.jsx,
3304
- files: [{ file: ctx.file.ext("factory-helper"), code: helpers3.js }]
3304
+ files: [{ file: ctx.file.ext("factory-helper"), code: helpers.js }]
3305
3305
  };
3306
3306
  }
3307
3307
  function setupJsxPatterns(ctx, filters) {
@@ -3480,31 +3480,31 @@ var generateArtifacts = (ctx, ids) => {
3480
3480
  };
3481
3481
 
3482
3482
  // src/artifacts/css/global-css.ts
3483
- var generateGlobalCss = (ctx) => {
3483
+ var generateGlobalCss = (ctx, sheet) => {
3484
3484
  const { globalCss = {} } = ctx.config;
3485
- ctx.stylesheet.processGlobalCss({
3485
+ sheet.processGlobalCss({
3486
3486
  ":root": {
3487
3487
  "--made-with-panda": `'\u{1F43C}'`
3488
3488
  },
3489
3489
  "*, *::before, *::after, ::backdrop": {
3490
- "--blur": "/*!*/ /*!*/",
3491
- "--brightness": "/*!*/ /*!*/",
3492
- "--contrast": "/*!*/ /*!*/",
3493
- "--grayscale": "/*!*/ /*!*/",
3494
- "--hue-rotate": "/*!*/ /*!*/",
3495
- "--invert": "/*!*/ /*!*/",
3496
- "--saturate": "/*!*/ /*!*/",
3497
- "--sepia": "/*!*/ /*!*/",
3498
- "--drop-shadow": "/*!*/ /*!*/",
3499
- "--backdrop-blur": "/*!*/ /*!*/",
3500
- "--backdrop-brightness": "/*!*/ /*!*/",
3501
- "--backdrop-contrast": "/*!*/ /*!*/",
3502
- "--backdrop-grayscale": "/*!*/ /*!*/",
3503
- "--backdrop-hue-rotate": "/*!*/ /*!*/",
3504
- "--backdrop-invert": "/*!*/ /*!*/",
3505
- "--backdrop-opacity": "/*!*/ /*!*/",
3506
- "--backdrop-saturate": "/*!*/ /*!*/",
3507
- "--backdrop-sepia": "/*!*/ /*!*/",
3490
+ "--blur": "/*-*/ /*-*/",
3491
+ "--brightness": "/*-*/ /*-*/",
3492
+ "--contrast": "/*-*/ /*-*/",
3493
+ "--grayscale": "/*-*/ /*-*/",
3494
+ "--hue-rotate": "/*-*/ /*-*/",
3495
+ "--invert": "/*-*/ /*-*/",
3496
+ "--saturate": "/*-*/ /*-*/",
3497
+ "--sepia": "/*-*/ /*-*/",
3498
+ "--drop-shadow": "/*-*/ /*-*/",
3499
+ "--backdrop-blur": "/*-*/ /*-*/",
3500
+ "--backdrop-brightness": "/*-*/ /*-*/",
3501
+ "--backdrop-contrast": "/*-*/ /*-*/",
3502
+ "--backdrop-grayscale": "/*-*/ /*-*/",
3503
+ "--backdrop-hue-rotate": "/*-*/ /*-*/",
3504
+ "--backdrop-invert": "/*-*/ /*-*/",
3505
+ "--backdrop-opacity": "/*-*/ /*-*/",
3506
+ "--backdrop-saturate": "/*-*/ /*-*/",
3507
+ "--backdrop-sepia": "/*-*/ /*-*/",
3508
3508
  "--scroll-snap-strictness": "proximity",
3509
3509
  "--border-spacing-x": 0,
3510
3510
  "--border-spacing-y": 0,
@@ -3517,14 +3517,14 @@ var generateGlobalCss = (ctx) => {
3517
3517
  "--scale-y": 1
3518
3518
  }
3519
3519
  });
3520
- ctx.stylesheet.processGlobalCss(globalCss);
3520
+ sheet.processGlobalCss(globalCss);
3521
3521
  void ctx.hooks.callHook("generator:css", "global.css", "");
3522
3522
  };
3523
3523
 
3524
3524
  // src/artifacts/css/keyframe-css.ts
3525
3525
  var import_core2 = require("@pandacss/core");
3526
3526
  var import_postcss = __toESM(require("postcss"));
3527
- function generateKeyframeCss(ctx) {
3527
+ function generateKeyframeCss(ctx, sheet) {
3528
3528
  const { keyframes = {} } = ctx.config.theme ?? {};
3529
3529
  const root = import_postcss.default.root();
3530
3530
  for (const [name, definition] of Object.entries(keyframes)) {
@@ -3536,93 +3536,32 @@ function generateKeyframeCss(ctx) {
3536
3536
  })
3537
3537
  );
3538
3538
  }
3539
- ctx.layers.tokens.append(root);
3539
+ sheet.layers.tokens.append(root);
3540
3540
  void ctx.hooks.callHook("generator:css", "keyframes.css", "");
3541
3541
  }
3542
3542
 
3543
3543
  // src/artifacts/css/parser-css.ts
3544
3544
  var import_logger2 = require("@pandacss/logger");
3545
- var import_ts_pattern11 = require("ts-pattern");
3546
- var generateParserCss = (ctx, result) => {
3547
- const { patterns, recipes } = ctx;
3548
- result.css.forEach((css2) => {
3549
- css2.data.forEach((data) => {
3550
- ctx.stylesheet.processAtomic(data);
3551
- });
3552
- });
3553
- result.cva.forEach((cva) => {
3554
- cva.data.forEach((data) => {
3555
- ctx.stylesheet.processAtomicRecipe(data);
3556
- });
3557
- });
3558
- result.sva.forEach((sva) => {
3559
- sva.data.forEach((data) => {
3560
- ctx.stylesheet.processAtomicSlotRecipe(data);
3561
- });
3562
- });
3563
- result.jsx.forEach((jsx) => {
3564
- jsx.data.forEach((data) => {
3565
- ctx.stylesheet.processStyleProps(filterProps(ctx, data));
3566
- });
3567
- });
3568
- result.recipe.forEach((recipeSet, recipeName) => {
3569
- try {
3570
- for (const recipe of recipeSet) {
3571
- const recipeConfig = recipes.getConfig(recipeName);
3572
- if (!recipeConfig)
3573
- continue;
3574
- (0, import_ts_pattern11.match)(recipe).with({ type: "jsx-recipe" }, () => {
3575
- recipe.data.forEach((data) => {
3576
- const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3577
- ctx.stylesheet.processStyleProps(filterProps(ctx, styleProps));
3578
- ctx.stylesheet.processRecipe(recipeName, recipeConfig, recipeProps);
3579
- });
3580
- }).otherwise(() => {
3581
- recipe.data.forEach((data) => {
3582
- ctx.stylesheet.processRecipe(recipeName, recipeConfig, data);
3583
- });
3584
- });
3585
- }
3586
- } catch (error) {
3587
- import_logger2.logger.error("serializer:recipe", error);
3588
- }
3589
- });
3590
- result.pattern.forEach((patternSet, name) => {
3591
- try {
3592
- for (const pattern of patternSet) {
3593
- (0, import_ts_pattern11.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern11.P.string }, ({ name: jsxName }) => {
3594
- pattern.data.forEach((data) => {
3595
- const fnName = patterns.find(jsxName);
3596
- const styleProps = patterns.transform(fnName, data);
3597
- ctx.stylesheet.processStyleProps(filterProps(ctx, styleProps));
3598
- });
3599
- }).otherwise(() => {
3600
- pattern.data.forEach((data) => {
3601
- const styleProps = patterns.transform(name, data);
3602
- ctx.stylesheet.processAtomic(styleProps);
3603
- });
3604
- });
3605
- }
3606
- } catch (error) {
3607
- import_logger2.logger.error("serializer:pattern", error);
3608
- }
3609
- });
3610
- void ctx.hooks.callHook("parser:css", result.filePath ?? "", "");
3611
- };
3612
- var filterProps = (ctx, props) => {
3613
- const clone = {};
3614
- for (const [key, value] of Object.entries(props)) {
3615
- if (ctx.isValidProperty(key)) {
3616
- clone[key] = value;
3617
- }
3545
+ var generateParserCss = (ctx, decoder, filePath) => {
3546
+ if (!decoder)
3547
+ return "";
3548
+ const sheet = ctx.createSheet();
3549
+ const { minify, optimize } = ctx.config;
3550
+ sheet.processDecoder(decoder);
3551
+ try {
3552
+ const css2 = sheet.toCss({ minify, optimize });
3553
+ ctx.hooks.callHook("parser:css", filePath ?? "", css2);
3554
+ return css2;
3555
+ } catch (err) {
3556
+ import_logger2.logger.error("serializer:css", "Failed to serialize CSS: " + err);
3557
+ return "";
3618
3558
  }
3619
- return clone;
3620
3559
  };
3621
3560
 
3622
3561
  // src/artifacts/css/reset-css.ts
3623
3562
  var import_shared4 = require("@pandacss/shared");
3624
3563
  var css = String.raw;
3625
- function generateResetCss(ctx) {
3564
+ function generateResetCss(ctx, sheet) {
3626
3565
  const { preflight } = ctx.config;
3627
3566
  const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
3628
3567
  const selector = scope ? `${scope} ` : "";
@@ -3805,7 +3744,7 @@ function generateResetCss(ctx) {
3805
3744
  ${selector}input[type="search"],
3806
3745
  ${selector}input[type="password"] {
3807
3746
  -webkit-appearance: none;
3808
- -moz-appearance: none;
3747
+ -moz-appearance: none;
3809
3748
  }
3810
3749
 
3811
3750
  ${selector}input[type='search'] {
@@ -3840,57 +3779,26 @@ function generateResetCss(ctx) {
3840
3779
  outline: auto;
3841
3780
  }
3842
3781
  `;
3843
- ctx.layers.reset.append(output);
3782
+ sheet.layers.reset.append(output);
3844
3783
  void ctx.hooks.callHook("generator:css", "reset.css", "");
3845
3784
  }
3846
3785
 
3847
3786
  // src/artifacts/css/static-css.ts
3848
- var import_core3 = require("@pandacss/core");
3849
- var generateStaticCss = (ctx) => {
3850
- const { config, utility, recipes } = ctx;
3851
- const { staticCss = {}, theme = {} } = config;
3852
- staticCss.recipes = staticCss.recipes ?? {};
3853
- const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
3854
- Object.entries(recipeConfigs).forEach(([name, recipe]) => {
3855
- if (recipe.staticCss) {
3856
- staticCss.recipes[name] = recipe.staticCss;
3857
- }
3858
- });
3859
- const getResult = (0, import_core3.getStaticCss)(staticCss);
3860
- const results = getResult({
3861
- breakpoints: Object.keys(theme.breakpoints ?? {}),
3862
- getPropertyKeys: (prop) => {
3863
- const propConfig = utility.config[prop];
3864
- if (!propConfig)
3865
- return [];
3866
- const values = utility.getPropertyValues(propConfig);
3867
- if (!values)
3868
- return [];
3869
- return Object.keys(values);
3870
- },
3871
- getRecipeKeys: (recipe) => {
3872
- const recipeConfig = recipes.details.find((detail) => detail.baseName === recipe);
3873
- return Object.assign({ __base: recipeConfig?.config.base }, recipeConfig?.variantKeyMap ?? {});
3874
- }
3875
- });
3876
- results.css.forEach((css2) => {
3877
- ctx.stylesheet.processAtomic(css2);
3878
- });
3879
- results.recipes.forEach((result) => {
3880
- Object.entries(result).forEach(([name, value]) => {
3881
- const recipeConfig = recipes.getConfig(name);
3882
- if (!recipeConfig)
3883
- return;
3884
- ctx.stylesheet.processRecipe(name, recipeConfig, value);
3885
- });
3886
- });
3887
- void ctx.hooks.callHook("generator:css", "static.css", "");
3787
+ var generateStaticCss = (ctx, sheet) => {
3788
+ const { config, staticCss } = ctx;
3789
+ const engine = staticCss.process(ctx.config.staticCss ?? {}, sheet);
3790
+ if (!sheet) {
3791
+ const { optimize = true, minify } = config;
3792
+ const output = engine.sheet.toCss({ optimize, minify });
3793
+ void ctx.hooks.callHook("generator:css", "static.css", output);
3794
+ return output;
3795
+ }
3888
3796
  };
3889
3797
 
3890
3798
  // src/artifacts/css/token-css.ts
3891
- var import_core4 = require("@pandacss/core");
3799
+ var import_core3 = require("@pandacss/core");
3892
3800
  var import_postcss2 = __toESM(require("postcss"));
3893
- function generateTokenCss(ctx) {
3801
+ function generateTokenCss(ctx, sheet) {
3894
3802
  const {
3895
3803
  config: { cssVarRoot },
3896
3804
  conditions,
@@ -3903,25 +3811,25 @@ function generateTokenCss(ctx) {
3903
3811
  if (Object.keys(varsObj).length === 0)
3904
3812
  continue;
3905
3813
  if (key === "base") {
3906
- const { css: css3 } = (0, import_core4.toCss)({ [root]: varsObj });
3814
+ const { css: css3 } = (0, import_core3.toCss)({ [root]: varsObj });
3907
3815
  results.push(css3);
3908
3816
  } else {
3909
3817
  const keys = key.split(":");
3910
- const { css: css3 } = (0, import_core4.toCss)(varsObj);
3818
+ const { css: css3 } = (0, import_core3.toCss)(varsObj);
3911
3819
  const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
3912
- const parent = (0, import_core4.extractParentSelectors)(condition);
3820
+ const parent = (0, import_core3.extractParentSelectors)(condition);
3913
3821
  return parent ? `&${parent}` : condition;
3914
3822
  });
3915
3823
  const rule = getDeepestRule(root, mapped);
3916
3824
  if (!rule)
3917
3825
  continue;
3918
3826
  getDeepestNode(rule)?.append(css3);
3919
- results.push((0, import_core4.expandNestedCss)(rule.toString()));
3827
+ results.push((0, import_core3.expandNestedCss)(rule.toString()));
3920
3828
  }
3921
3829
  }
3922
3830
  let css2 = results.join("\n\n");
3923
3831
  css2 = "\n\n" + cleanupSelectors(css2, root);
3924
- ctx.layers.tokens.append(css2);
3832
+ sheet.layers.tokens.append(css2);
3925
3833
  void ctx.hooks.callHook("generator:css", "tokens.css", "");
3926
3834
  }
3927
3835
  function getDeepestRule(root, selectors) {
@@ -3971,11 +3879,7 @@ function cleanupSelectors(css2, varSelector) {
3971
3879
  }
3972
3880
 
3973
3881
  // src/engines/index.ts
3974
- var import_core5 = require("@pandacss/core");
3975
- var import_is_valid_prop3 = require("@pandacss/is-valid-prop");
3976
- var import_shared7 = require("@pandacss/shared");
3977
- var import_token_dictionary = require("@pandacss/token-dictionary");
3978
- var import_lil_fp = require("lil-fp");
3882
+ var import_core4 = require("@pandacss/core");
3979
3883
 
3980
3884
  // src/engines/file.ts
3981
3885
  var FileEngine = class {
@@ -4093,214 +3997,22 @@ var PathEngine = class {
4093
3997
  }
4094
3998
  };
4095
3999
 
4096
- // src/engines/pattern.ts
4097
- var import_shared6 = require("@pandacss/shared");
4098
- var helpers = { map: import_shared6.mapObject };
4099
- var Patterns = class {
4100
- patterns;
4101
- details;
4102
- constructor(config) {
4103
- this.patterns = config.patterns ?? {};
4104
- this.details = Object.entries(this.patterns).map(([name, pattern]) => this.createDetail(name, pattern));
4105
- }
4106
- createDetail(name, pattern) {
4107
- const names = this.getNames(name);
4108
- const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
4109
- return {
4110
- ...names,
4111
- props: Object.keys(pattern?.properties ?? {}),
4112
- blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
4113
- config: pattern,
4114
- type: "pattern",
4115
- match: (0, import_shared6.createRegex)(jsx),
4116
- jsx
4117
- };
4118
- }
4119
- get keys() {
4120
- return Object.keys(this.patterns);
4121
- }
4122
- getConfig(name) {
4123
- return this.patterns[name];
4124
- }
4125
- transform(name, data) {
4126
- return this.patterns[name]?.transform?.(data, helpers) ?? {};
4127
- }
4128
- getNames(name) {
4129
- const upperName = (0, import_shared6.capitalize)(name);
4130
- return {
4131
- upperName,
4132
- baseName: name,
4133
- dashName: (0, import_shared6.dashCase)(name),
4134
- styleFnName: `get${upperName}Style`,
4135
- jsxName: this.patterns[name]?.jsxName ?? upperName
4136
- };
4137
- }
4138
- find = (0, import_shared6.memo)((jsxName) => {
4139
- return this.details.find((node) => node.match.test(jsxName))?.baseName ?? (0, import_shared6.uncapitalize)(jsxName);
4140
- });
4141
- filter = (0, import_shared6.memo)((jsxName) => {
4142
- return this.details.filter((node) => node.match.test(jsxName));
4143
- });
4144
- isEmpty() {
4145
- return this.keys.length === 0;
4146
- }
4147
- saveOne(name, pattern) {
4148
- this.patterns[name] = pattern;
4149
- const detailIndex = this.details.findIndex((detail) => detail.baseName === name);
4150
- const updated = this.createDetail(name, pattern);
4151
- if (detailIndex > -1) {
4152
- this.details[detailIndex] = updated;
4153
- } else {
4154
- this.details.push(updated);
4155
- }
4156
- }
4157
- remove(name) {
4158
- delete this.patterns[name];
4159
- const detailIndex = this.details.findIndex((detail) => detail.baseName === name);
4160
- if (detailIndex > -1) {
4161
- this.details.splice(detailIndex, 1);
4162
- }
4163
- }
4164
- filterDetails(filters) {
4165
- const patternDiffs = filters?.affecteds?.patterns;
4166
- return patternDiffs ? this.details.filter((pattern) => patternDiffs.includes(pattern.dashName)) : this.details;
4167
- }
4168
- };
4169
-
4170
4000
  // src/engines/index.ts
4171
- var helpers2 = { map: import_shared7.mapObject };
4172
- var defaults = (config) => ({
4173
- cssVarRoot: ":where(:root, :host)",
4174
- jsxFactory: "styled",
4175
- jsxStyleProps: "all",
4176
- outExtension: "mjs",
4177
- shorthands: true,
4178
- syntax: "object-literal",
4179
- ...config,
4180
- layers: {
4181
- reset: "reset",
4182
- base: "base",
4183
- tokens: "tokens",
4184
- recipes: "recipes",
4185
- utilities: "utilities",
4186
- ...config.layers
4187
- }
4188
- });
4189
- var Context = class {
4001
+ var Context = class extends import_core4.CoreContext {
4190
4002
  constructor(conf) {
4003
+ super(conf);
4191
4004
  this.conf = conf;
4192
- const config = defaults(conf.config);
4193
- const theme = config.theme ?? {};
4194
- conf.config = config;
4195
- this.tokens = this.createTokenDictionary(theme);
4196
- this.utility = this.createUtility(config);
4197
- this.conditions = this.createConditions(config);
4198
- this.layers = this.createLayers(config.layers);
4199
- this.patterns = new Patterns(config);
4005
+ const config = conf.config;
4200
4006
  this.jsx = new JsxEngine(config);
4201
4007
  this.paths = new PathEngine(config);
4202
4008
  this.file = new FileEngine(config);
4203
- this.studio = { outdir: `${config.outdir}-studio`, ...conf.config.studio };
4204
- this.setupCompositions(theme);
4205
- this.setupProperties();
4206
- this.recipes = this.createRecipes(theme, this.baseSheetContext);
4207
- this.stylesheet = this.createSheet();
4208
4009
  }
4209
- studio;
4210
- // Engines
4211
- tokens;
4212
- utility;
4213
- recipes;
4214
- conditions;
4215
- patterns;
4216
- layers;
4217
4010
  jsx;
4218
4011
  paths;
4219
4012
  file;
4220
- stylesheet;
4221
- // Props
4222
- properties;
4223
- isValidProperty;
4224
- get config() {
4225
- return this.conf.config;
4226
- }
4227
- get hooks() {
4228
- return this.conf.hooks;
4229
- }
4230
- get isTemplateLiteralSyntax() {
4231
- return this.config.syntax === "template-literal";
4232
- }
4233
- get hash() {
4234
- return {
4235
- tokens: (0, import_lil_fp.isBool)(this.config.hash) ? this.config.hash : this.config.hash?.cssVar,
4236
- className: (0, import_lil_fp.isBool)(this.config.hash) ? this.config.hash : this.config.hash?.className
4237
- };
4238
- }
4239
- get prefix() {
4240
- return {
4241
- tokens: (0, import_lil_fp.isStr)(this.config.prefix) ? this.config.prefix : this.config.prefix?.cssVar,
4242
- className: (0, import_lil_fp.isStr)(this.config.prefix) ? this.config.prefix : this.config.prefix?.className
4243
- };
4244
- }
4245
- createTokenDictionary(theme) {
4246
- return new import_token_dictionary.TokenDictionary({
4247
- breakpoints: theme.breakpoints,
4248
- tokens: theme.tokens,
4249
- semanticTokens: theme.semanticTokens,
4250
- prefix: this.prefix.tokens,
4251
- hash: this.hash.tokens
4252
- });
4253
- }
4254
- createUtility(config) {
4255
- return new import_core5.Utility({
4256
- prefix: this.prefix.className,
4257
- tokens: this.tokens,
4258
- config: this.isTemplateLiteralSyntax ? {} : Object.assign({}, config.utilities),
4259
- separator: config.separator,
4260
- shorthands: config.shorthands,
4261
- strictTokens: config.strictTokens
4262
- });
4263
- }
4264
- createConditions(config) {
4265
- return new import_core5.Conditions({
4266
- conditions: config.conditions,
4267
- breakpoints: config.theme?.breakpoints
4268
- });
4269
- }
4270
- createLayers(layers) {
4271
- return new import_core5.Layers(layers);
4272
- }
4273
- setupCompositions(theme) {
4274
- const { textStyles, layerStyles } = theme;
4275
- const compositions = (0, import_shared7.compact)({ textStyle: textStyles, layerStyle: layerStyles });
4276
- (0, import_core5.assignCompositions)(compositions, { conditions: this.conditions, utility: this.utility });
4277
- }
4278
- setupProperties() {
4279
- this.properties = /* @__PURE__ */ new Set(["css", ...this.utility.keys(), ...this.conditions.keys()]);
4280
- this.isValidProperty = (0, import_shared7.memo)((key) => this.properties.has(key) || (0, import_is_valid_prop3.isCssProperty)(key));
4281
- }
4282
- get baseSheetContext() {
4283
- return {
4284
- conditions: this.conditions,
4285
- layers: this.layers,
4286
- utility: this.utility,
4287
- helpers: helpers2,
4288
- hash: this.hash.className
4289
- };
4290
- }
4291
- createSheet() {
4292
- return new import_core5.Stylesheet({
4293
- ...this.baseSheetContext,
4294
- recipes: this.recipes
4295
- });
4296
- }
4297
- createRecipes(theme, context) {
4298
- const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
4299
- return new import_core5.Recipes(recipeConfigs, context);
4300
- }
4301
4013
  };
4302
4014
 
4303
- // src/parser-options.ts
4015
+ // src/import-map.ts
4304
4016
  var getImportMap = (outdir, configImportMap) => {
4305
4017
  if (typeof configImportMap === "string") {
4306
4018
  return {
@@ -4318,14 +4030,16 @@ var getImportMap = (outdir, configImportMap) => {
4318
4030
  jsx: jsx ? [jsx] : [outdir, "jsx"]
4319
4031
  };
4320
4032
  };
4033
+
4034
+ // src/parser-options.ts
4321
4035
  var getParserOptions = (ctx) => {
4322
4036
  const { config, jsx, isValidProperty, patterns, recipes } = ctx;
4323
- const { tsconfig, tsOptions } = ctx.conf;
4324
- const compilerOptions = tsconfig?.compilerOptions ?? {};
4037
+ const compilerOptions = ctx.conf.tsconfig?.compilerOptions ?? {};
4325
4038
  const baseUrl = compilerOptions.baseUrl ?? "";
4326
4039
  const cwd = config.cwd;
4327
4040
  const relativeBaseUrl = baseUrl !== cwd ? baseUrl.replace(cwd, "").slice(1) : cwd;
4328
4041
  return {
4042
+ hash: ctx.hash,
4329
4043
  importMap: getImportMap(config.outdir.replace(relativeBaseUrl, ""), config.importMap),
4330
4044
  jsx: {
4331
4045
  framework: jsx.framework,
@@ -4334,13 +4048,14 @@ var getParserOptions = (ctx) => {
4334
4048
  isStyleProp: isValidProperty,
4335
4049
  nodes: [...patterns.details, ...recipes.details]
4336
4050
  },
4337
- isTemplateLiteralSyntax: ctx.isTemplateLiteralSyntax,
4338
- patternKeys: patterns.keys,
4339
- recipeKeys: recipes.keys,
4340
- getRecipesByJsxName: recipes.filter,
4341
- getPatternsByJsxName: patterns.filter,
4051
+ syntax: config.syntax,
4052
+ isValidProperty,
4053
+ recipes,
4054
+ patterns,
4055
+ encoder: ctx.encoder,
4342
4056
  compilerOptions,
4343
- tsOptions
4057
+ tsOptions: ctx.conf.tsOptions,
4058
+ join: (...paths) => paths.join("/")
4344
4059
  };
4345
4060
  };
4346
4061
 
@@ -4353,41 +4068,42 @@ var Generator = class extends Context {
4353
4068
  this.parserOptions = getParserOptions(this);
4354
4069
  this.messages = getMessages(this);
4355
4070
  }
4356
- getArtifacts(ids) {
4071
+ getArtifacts = (ids) => {
4357
4072
  return generateArtifacts(this, ids);
4358
- }
4359
- appendCss(type) {
4360
- (0, import_ts_pattern12.match)(type).with("preflight", () => generateResetCss(this)).with("tokens", () => generateTokenCss(this)).with("static", () => generateStaticCss(this)).with("global", () => generateGlobalCss(this)).with("keyframes", () => generateKeyframeCss(this)).otherwise(() => {
4073
+ };
4074
+ appendCssOfType = (type, sheet) => {
4075
+ (0, import_ts_pattern11.match)(type).with("preflight", () => generateResetCss(this, sheet)).with("tokens", () => generateTokenCss(this, sheet)).with("static", () => generateStaticCss(this, sheet)).with("global", () => generateGlobalCss(this, sheet)).with("keyframes", () => generateKeyframeCss(this, sheet)).otherwise(() => {
4361
4076
  throw new Error(`Unknown css artifact type <${type}>`);
4362
4077
  });
4363
- }
4364
- appendLayerParams() {
4365
- this.stylesheet.prepend(this.layers.params);
4366
- }
4367
- appendBaselineCss() {
4078
+ };
4079
+ appendLayerParams = (sheet) => {
4080
+ sheet.layers.root.prepend(sheet.layers.params);
4081
+ };
4082
+ appendBaselineCss = (sheet) => {
4368
4083
  if (this.config.preflight)
4369
- this.appendCss("preflight");
4084
+ this.appendCssOfType("preflight", sheet);
4370
4085
  if (!this.tokens.isEmpty)
4371
- this.appendCss("tokens");
4086
+ this.appendCssOfType("tokens", sheet);
4372
4087
  if (this.config.staticCss)
4373
- this.appendCss("static");
4374
- this.appendCss("global");
4088
+ this.appendCssOfType("static", sheet);
4089
+ this.appendCssOfType("global", sheet);
4375
4090
  if (this.config.theme?.keyframes)
4376
- this.appendCss("keyframes");
4377
- }
4378
- appendParserCss(...results) {
4379
- results.forEach((result) => {
4380
- if (!result)
4381
- return;
4382
- generateParserCss(this, result);
4383
- });
4384
- }
4385
- getCss() {
4386
- return this.stylesheet.toCss({
4091
+ this.appendCssOfType("keyframes", sheet);
4092
+ };
4093
+ appendParserCss = (sheet) => {
4094
+ const decoder = this.decoder.collect(this.encoder);
4095
+ sheet.processDecoder(decoder);
4096
+ };
4097
+ getParserCss = (decoder, filePath) => {
4098
+ return generateParserCss(this, decoder, filePath);
4099
+ };
4100
+ getCss = (stylesheet) => {
4101
+ const sheet = stylesheet ?? this.createSheet();
4102
+ return sheet.toCss({
4387
4103
  optimize: true,
4388
4104
  minify: this.config.minify
4389
4105
  });
4390
- }
4106
+ };
4391
4107
  };
4392
4108
  // Annotate the CommonJS export names for ESM import in node:
4393
4109
  0 && (module.exports = {