@pandacss/generator 0.0.0-dev-20230614113002 → 0.0.0-dev-20230614152938

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.d.ts CHANGED
@@ -3,9 +3,9 @@ import * as _pandacss_core from '@pandacss/core';
3
3
  import * as _pandacss_token_dictionary from '@pandacss/token-dictionary';
4
4
  import * as _pandacss_types_dist_config from '@pandacss/types/dist/config';
5
5
  import * as _pandacss_types from '@pandacss/types';
6
- import { LoadConfigResult } from '@pandacss/types';
6
+ import { ConfigResultWithHooks } from '@pandacss/types';
7
7
 
8
- declare const getEngine: (conf: LoadConfigResult) => {
8
+ declare const getEngine: (conf: ConfigResultWithHooks) => {
9
9
  patterns: {
10
10
  transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
11
11
  nodes: {
@@ -76,6 +76,7 @@ declare const getEngine: (conf: LoadConfigResult) => {
76
76
  conditions: _pandacss_core.Conditions;
77
77
  createSheetContext: () => _pandacss_core.StylesheetContext;
78
78
  createSheet: (options?: Pick<_pandacss_core.StylesheetOptions, "content"> | undefined) => _pandacss_core.Stylesheet;
79
+ hooks: _pandacss_types.PandaHookable;
79
80
  path: string;
80
81
  config: _pandacss_types_dist_shared.UnwrapExtend<_pandacss_types.RequiredBy<_pandacss_types.Config, "include" | "outdir" | "cwd">>;
81
82
  dependencies: string[];
@@ -120,7 +121,7 @@ declare namespace messages {
120
121
  };
121
122
  }
122
123
 
123
- declare const createGenerator: (conf: LoadConfigResult) => {
124
+ declare const createGenerator: (conf: ConfigResultWithHooks) => {
124
125
  config: _pandacss_types_dist_shared.UnwrapExtend<_pandacss_types.RequiredBy<_pandacss_types.Config, "include" | "outdir" | "cwd">>;
125
126
  path: string;
126
127
  conditions: _pandacss_core.Conditions;
@@ -172,6 +173,7 @@ declare const createGenerator: (conf: LoadConfigResult) => {
172
173
  getFnName: (jsx: string) => string;
173
174
  isEmpty: () => boolean;
174
175
  };
176
+ hooks: _pandacss_types.PandaHookable;
175
177
  createSheet: (options?: Pick<_pandacss_core.StylesheetOptions, "content"> | undefined) => _pandacss_core.Stylesheet;
176
178
  properties: string[];
177
179
  getArtifacts: () => _pandacss_types.Artifact[];
package/dist/index.js CHANGED
@@ -170,7 +170,9 @@ var generateGlobalCss = (ctx) => {
170
170
  }
171
171
  });
172
172
  sheet.processGlobalCss(globalCss);
173
- return sheet.toCss({ optimize });
173
+ const output = sheet.toCss({ optimize });
174
+ ctx.hooks.callHook("generator:css", "global.css", output);
175
+ return output;
174
176
  };
175
177
 
176
178
  // src/artifacts/css/keyframe-css.ts
@@ -193,14 +195,16 @@ function generateKeyframeCss(ctx) {
193
195
  params: "tokens",
194
196
  nodes: root.nodes
195
197
  });
196
- return rule.toString();
198
+ const output = rule.toString();
199
+ ctx.hooks.callHook("generator:css", "keyframes.css", output);
200
+ return output;
197
201
  }
198
202
 
199
203
  // src/artifacts/css/reset-css.ts
200
204
  var css = String.raw;
201
- function generateResetCss(scope = "") {
205
+ function generateResetCss(ctx, scope = "") {
202
206
  const selector = scope ? `${scope} ` : "";
203
- return css`
207
+ const output = css`
204
208
  @layer reset {
205
209
  ${selector}* {
206
210
  margin: 0;
@@ -393,6 +397,8 @@ function generateResetCss(scope = "") {
393
397
  }
394
398
  }
395
399
  `;
400
+ ctx.hooks.callHook("generator:css", "reset.css", output);
401
+ return output;
396
402
  }
397
403
 
398
404
  // src/artifacts/css/static-css.ts
@@ -418,7 +424,9 @@ var generateStaticCss = (ctx) => {
418
424
  sheet.processRecipe(recipeConfig, value);
419
425
  });
420
426
  });
421
- return sheet.toCss({ optimize });
427
+ const output = sheet.toCss({ optimize });
428
+ ctx.hooks.callHook("generator:css", "static.css", output);
429
+ return output;
422
430
  };
423
431
 
424
432
  // src/artifacts/css/token-css.ts
@@ -454,10 +462,12 @@ function generateTokenCss(ctx) {
454
462
  }
455
463
  }
456
464
  const css2 = results.join("\n\n");
457
- return `@layer tokens {
465
+ const output = `@layer tokens {
458
466
  ${(0, import_core3.prettifyCss)(cleanupSelectors(css2, root))}
459
467
  }
460
468
  `;
469
+ ctx.hooks.callHook("generator:css", "tokens.css", output);
470
+ return output;
461
471
  }
462
472
  function getDeepestRule(root, selectors) {
463
473
  const rule = import_postcss2.default.rule({ selector: "" });
@@ -2051,7 +2061,7 @@ var recipe_d_ts_default = {
2051
2061
 
2052
2062
  // src/artifacts/generated/pattern.d.ts.json
2053
2063
  var pattern_d_ts_default = {
2054
- content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternConfig<T = PatternProperty> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties: T extends Record<string, PatternProperty> ? T : Record<string, PatternProperty>\n /**\n * The css object this pattern will generate.\n */\n transform?: (\n props: T extends Record<infer Keys, PatternProperty> ? Record<Keys, any> : Record<string, PatternProperty>,\n helpers: PatternHelpers,\n ) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2064
+ content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\ntype PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2055
2065
  };
2056
2066
 
2057
2067
  // src/artifacts/generated/parts.d.ts.json
@@ -2401,7 +2411,7 @@ function setupResetCss(ctx) {
2401
2411
  if (!preflight)
2402
2412
  return;
2403
2413
  const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
2404
- const code = generateResetCss(scope);
2414
+ const code = generateResetCss(ctx, scope);
2405
2415
  return { files: [{ file: "reset.css", code }] };
2406
2416
  }
2407
2417
  function setupGlobalCss(ctx) {
@@ -2458,7 +2468,7 @@ var generateFlattenedCss = (ctx) => (options) => {
2458
2468
  content: resolve ? [
2459
2469
  generateGlobalCss(ctx),
2460
2470
  staticCss && generateStaticCss(ctx),
2461
- preflight && generateResetCss(),
2471
+ preflight && generateResetCss(ctx),
2462
2472
  !ctx.tokens.isEmpty && generateTokenCss(ctx),
2463
2473
  keyframes && generateKeyframeCss(ctx)
2464
2474
  ].filter(Boolean).join("\n\n") : unresolved
@@ -2535,7 +2545,9 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
2535
2545
  }),
2536
2546
  (0, import_func.tryCatch)(
2537
2547
  ({ sheet, result: result2, config: { minify, optimize } }) => {
2538
- return !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
2548
+ const css2 = !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
2549
+ ctx.hooks.callHook("parser:css", result2.filePath ?? "", css2);
2550
+ return css2;
2539
2551
  },
2540
2552
  (err) => {
2541
2553
  import_logger2.logger.error("serializer:css", "Failed to serialize CSS: " + err);
package/dist/index.mjs CHANGED
@@ -139,7 +139,9 @@ var generateGlobalCss = (ctx) => {
139
139
  }
140
140
  });
141
141
  sheet.processGlobalCss(globalCss);
142
- return sheet.toCss({ optimize });
142
+ const output = sheet.toCss({ optimize });
143
+ ctx.hooks.callHook("generator:css", "global.css", output);
144
+ return output;
143
145
  };
144
146
 
145
147
  // src/artifacts/css/keyframe-css.ts
@@ -162,14 +164,16 @@ function generateKeyframeCss(ctx) {
162
164
  params: "tokens",
163
165
  nodes: root.nodes
164
166
  });
165
- return rule.toString();
167
+ const output = rule.toString();
168
+ ctx.hooks.callHook("generator:css", "keyframes.css", output);
169
+ return output;
166
170
  }
167
171
 
168
172
  // src/artifacts/css/reset-css.ts
169
173
  var css = String.raw;
170
- function generateResetCss(scope = "") {
174
+ function generateResetCss(ctx, scope = "") {
171
175
  const selector = scope ? `${scope} ` : "";
172
- return css`
176
+ const output = css`
173
177
  @layer reset {
174
178
  ${selector}* {
175
179
  margin: 0;
@@ -362,6 +366,8 @@ function generateResetCss(scope = "") {
362
366
  }
363
367
  }
364
368
  `;
369
+ ctx.hooks.callHook("generator:css", "reset.css", output);
370
+ return output;
365
371
  }
366
372
 
367
373
  // src/artifacts/css/static-css.ts
@@ -387,7 +393,9 @@ var generateStaticCss = (ctx) => {
387
393
  sheet.processRecipe(recipeConfig, value);
388
394
  });
389
395
  });
390
- return sheet.toCss({ optimize });
396
+ const output = sheet.toCss({ optimize });
397
+ ctx.hooks.callHook("generator:css", "static.css", output);
398
+ return output;
391
399
  };
392
400
 
393
401
  // src/artifacts/css/token-css.ts
@@ -423,10 +431,12 @@ function generateTokenCss(ctx) {
423
431
  }
424
432
  }
425
433
  const css2 = results.join("\n\n");
426
- return `@layer tokens {
434
+ const output = `@layer tokens {
427
435
  ${prettifyCss(cleanupSelectors(css2, root))}
428
436
  }
429
437
  `;
438
+ ctx.hooks.callHook("generator:css", "tokens.css", output);
439
+ return output;
430
440
  }
431
441
  function getDeepestRule(root, selectors) {
432
442
  const rule = postcss2.rule({ selector: "" });
@@ -2020,7 +2030,7 @@ var recipe_d_ts_default = {
2020
2030
 
2021
2031
  // src/artifacts/generated/pattern.d.ts.json
2022
2032
  var pattern_d_ts_default = {
2023
- content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternConfig<T = PatternProperty> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties: T extends Record<string, PatternProperty> ? T : Record<string, PatternProperty>\n /**\n * The css object this pattern will generate.\n */\n transform?: (\n props: T extends Record<infer Keys, PatternProperty> ? Record<Keys, any> : Record<string, PatternProperty>,\n helpers: PatternHelpers,\n ) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2033
+ content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\ntype PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2024
2034
  };
2025
2035
 
2026
2036
  // src/artifacts/generated/parts.d.ts.json
@@ -2370,7 +2380,7 @@ function setupResetCss(ctx) {
2370
2380
  if (!preflight)
2371
2381
  return;
2372
2382
  const scope = isObject(preflight) ? preflight.scope : void 0;
2373
- const code = generateResetCss(scope);
2383
+ const code = generateResetCss(ctx, scope);
2374
2384
  return { files: [{ file: "reset.css", code }] };
2375
2385
  }
2376
2386
  function setupGlobalCss(ctx) {
@@ -2427,7 +2437,7 @@ var generateFlattenedCss = (ctx) => (options) => {
2427
2437
  content: resolve ? [
2428
2438
  generateGlobalCss(ctx),
2429
2439
  staticCss && generateStaticCss(ctx),
2430
- preflight && generateResetCss(),
2440
+ preflight && generateResetCss(ctx),
2431
2441
  !ctx.tokens.isEmpty && generateTokenCss(ctx),
2432
2442
  keyframes && generateKeyframeCss(ctx)
2433
2443
  ].filter(Boolean).join("\n\n") : unresolved
@@ -2504,7 +2514,9 @@ var generateParserCss = (ctx) => (result) => pipe(
2504
2514
  }),
2505
2515
  tryCatch(
2506
2516
  ({ sheet, result: result2, config: { minify, optimize } }) => {
2507
- return !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
2517
+ const css2 = !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
2518
+ ctx.hooks.callHook("parser:css", result2.filePath ?? "", css2);
2519
+ return css2;
2508
2520
  },
2509
2521
  (err) => {
2510
2522
  logger.error("serializer:css", "Failed to serialize CSS: " + err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20230614113002",
3
+ "version": "0.0.0-dev-20230614152938",
4
4
  "description": "The css generator for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -20,16 +20,17 @@
20
20
  "pluralize": "8.0.0",
21
21
  "postcss": "8.4.24",
22
22
  "ts-pattern": "4.3.0",
23
- "@pandacss/core": "0.0.0-dev-20230614113002",
24
- "@pandacss/logger": "0.0.0-dev-20230614113002",
25
- "@pandacss/is-valid-prop": "0.0.0-dev-20230614113002",
26
- "@pandacss/shared": "0.0.0-dev-20230614113002",
27
- "@pandacss/types": "0.0.0-dev-20230614113002",
28
- "@pandacss/token-dictionary": "0.0.0-dev-20230614113002"
23
+ "@pandacss/core": "0.0.0-dev-20230614152938",
24
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230614152938",
25
+ "@pandacss/logger": "0.0.0-dev-20230614152938",
26
+ "@pandacss/shared": "0.0.0-dev-20230614152938",
27
+ "@pandacss/token-dictionary": "0.0.0-dev-20230614152938",
28
+ "@pandacss/types": "0.0.0-dev-20230614152938"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/pluralize": "0.0.29",
32
- "@pandacss/fixture": "0.0.0-dev-20230614113002"
32
+ "hookable": "5.5.3",
33
+ "@pandacss/fixture": "0.0.0-dev-20230614152938"
33
34
  },
34
35
  "scripts": {
35
36
  "prebuild": "tsx scripts/prebuild.ts",