@pandacss/node 0.0.0-dev-20221128065048 → 0.0.0-dev-20221128112158

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
@@ -57,10 +57,11 @@ declare function createContext(conf: LoadConfigResult, io?: IO): {
57
57
  pattern: string;
58
58
  jsx: string;
59
59
  };
60
- reloadSourceFiles(): void;
61
- getSourceFile(file: string): ts_morph.SourceFile | undefined;
62
- addSourceFile(file: string): ts_morph.SourceFile;
63
- removeSourceFile(file: string): boolean | undefined;
60
+ reloadSourceFiles: () => void;
61
+ getSourceFile: (file: string) => ts_morph.SourceFile | undefined;
62
+ addSourceFile: (file: string) => void;
63
+ reloadSourceFile: (file: string) => void;
64
+ removeSourceFile: (file: string) => boolean | undefined;
64
65
  parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => Collector | undefined;
65
66
  getPath: (str: string) => string;
66
67
  paths: {
@@ -88,7 +89,7 @@ declare function createContext(conf: LoadConfigResult, io?: IO): {
88
89
  file: string;
89
90
  } | undefined;
90
91
  patterns: Record<string, PatternConfig>;
91
- hasPattern: boolean;
92
+ hasPatterns: boolean;
92
93
  getPattern: (name: string) => PatternConfig | undefined;
93
94
  execPattern: (name: string, data: Record<string, any>) => _pandacss_types.StyleObject<_pandacss_types_dist_system_types.TCondition, _pandacss_types_dist_system_types.NeverType, false>;
94
95
  patternNodes: {
@@ -174,10 +175,11 @@ declare class Builder {
174
175
  pattern: string;
175
176
  jsx: string;
176
177
  };
177
- reloadSourceFiles(): void;
178
- getSourceFile(file: string): ts_morph.SourceFile | undefined;
179
- addSourceFile(file: string): ts_morph.SourceFile;
180
- removeSourceFile(file: string): boolean | undefined;
178
+ reloadSourceFiles: () => void;
179
+ getSourceFile: (file: string) => ts_morph.SourceFile | undefined;
180
+ addSourceFile: (file: string) => void;
181
+ reloadSourceFile: (file: string) => void;
182
+ removeSourceFile: (file: string) => boolean | undefined;
181
183
  parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => _pandacss_parser.Collector | undefined;
182
184
  getPath: (str: string) => string;
183
185
  paths: {
@@ -205,7 +207,7 @@ declare class Builder {
205
207
  file: string;
206
208
  } | undefined;
207
209
  patterns: Record<string, _pandacss_types.PatternConfig>;
208
- hasPattern: boolean;
210
+ hasPatterns: boolean;
209
211
  getPattern: (name: string) => _pandacss_types.PatternConfig | undefined;
210
212
  execPattern: (name: string, data: Record<string, any>) => _pandacss_types.StyleObject<_pandacss_types_dist_system_types.TCondition, _pandacss_types_dist_system_types.NeverType, false>;
211
213
  patternNodes: {
@@ -289,10 +291,11 @@ declare function loadConfigAndCreateContext(options?: {
289
291
  pattern: string;
290
292
  jsx: string;
291
293
  };
292
- reloadSourceFiles(): void;
293
- getSourceFile(file: string): ts_morph.SourceFile | undefined;
294
- addSourceFile(file: string): ts_morph.SourceFile;
295
- removeSourceFile(file: string): boolean | undefined;
294
+ reloadSourceFiles: () => void;
295
+ getSourceFile: (file: string) => ts_morph.SourceFile | undefined;
296
+ addSourceFile: (file: string) => void;
297
+ reloadSourceFile: (file: string) => void;
298
+ removeSourceFile: (file: string) => boolean | undefined;
296
299
  parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => _pandacss_parser.Collector | undefined;
297
300
  getPath: (str: string) => string;
298
301
  paths: {
@@ -320,7 +323,7 @@ declare function loadConfigAndCreateContext(options?: {
320
323
  file: string;
321
324
  } | undefined;
322
325
  patterns: Record<string, _pandacss_types.PatternConfig>;
323
- hasPattern: boolean;
326
+ hasPatterns: boolean;
324
327
  getPattern: (name: string) => _pandacss_types.PatternConfig | undefined;
325
328
  execPattern: (name: string, data: Record<string, any>) => _pandacss_types.StyleObject<_pandacss_types_dist_system_types.TCondition, _pandacss_types_dist_system_types.NeverType, false>;
326
329
  patternNodes: {
package/dist/index.js CHANGED
@@ -323,10 +323,9 @@ function generatePreactJsxFactory(ctx) {
323
323
  import type { JSXStyleProperties } from '../types'
324
324
 
325
325
  type Element = keyof JSX.IntrinsicElements
326
-
327
- type Merge<P, T> = Omit<P, 'color'> & T;
328
326
 
329
- export type HTML${upperName}Props<T extends Element> = Merge<ComponentProps<T>, JSXStyleProperties>
327
+ export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties
328
+
330
329
 
331
330
  type JSXFactory = {
332
331
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -335,8 +334,8 @@ function generatePreactJsxFactory(ctx) {
335
334
  export declare const ${name}: JSXFactory
336
335
  `,
337
336
  js: import_outdent6.outdent`
338
- import { h } from 'preact';
339
- import { forwardRef } from 'preact/compat';
337
+ import { h } from 'preact'
338
+ import { forwardRef } from 'preact/compat'
340
339
  import { isCssProperty } from './is-valid-prop'
341
340
  import { css } from '../css'
342
341
 
@@ -371,7 +370,7 @@ function generatePreactJsxFactory(ctx) {
371
370
  return cx(atomicClass, elementProps.className)
372
371
  }
373
372
 
374
- return h(Element, { ...elementProps, ref, className: classes() });
373
+ return h(Element, { ...elementProps, ref, className: classes() })
375
374
  })
376
375
 
377
376
  ${upperName}Component.displayName = \`${name}.\${Dynamic}\`
@@ -391,7 +390,7 @@ function generatePreactJsxFactory(ctx) {
391
390
  })
392
391
  }
393
392
 
394
- export const ${name} = createFactory();
393
+ export const ${name} = createFactory()
395
394
  `
396
395
  };
397
396
  }
@@ -485,22 +484,18 @@ function generate(name, pattern, jsxFactory) {
485
484
  import { JSXStyleProperties, Assign } from '../types'
486
485
 
487
486
  type ElementType = keyof JSX.IntrinsicElements
488
-
489
- type PropsWithChildren<T> = T & { children?: ComponentChildren }
490
- type PropsOf<C extends ElementType> = ComponentProps<C>
491
-
492
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
493
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
487
+
488
+ type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
489
+ Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
494
490
 
495
491
  type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
496
492
 
497
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
493
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
494
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
498
495
  `
499
496
  };
500
497
  }
501
498
  function generatePreactJsxPattern(ctx) {
502
- if (!ctx.hasPattern)
503
- return [];
504
499
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate(name, pattern, ctx.jsxFactory));
505
500
  }
506
501
 
@@ -517,7 +512,7 @@ function generateReactJsxFactory(ctx) {
517
512
 
518
513
  type Element = keyof JSX.IntrinsicElements
519
514
 
520
- export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, "color"> & JSXStyleProperties
515
+ export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties;
521
516
 
522
517
  type JSXFactory = {
523
518
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -675,20 +670,18 @@ function generate2(name, pattern, jsxFactory) {
675
670
  import { ${upperName}Properties } from '../patterns/${(0, import_shared5.dashCase)(name)}'
676
671
  import { JSXStyleProperties, Assign } from '../types'
677
672
 
678
- type PropsOf<C extends ElementType> = ComponentProps<C>
679
-
680
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
681
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
673
+ type Polymorphic<C extends ElementType = "div", P = {}> =
674
+ | JSXStyleProperties
675
+ | Assign<Omit<ComponentProps<C>, "color">, P & { as?: C }>
682
676
 
683
677
  export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
684
678
 
685
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
679
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
680
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
686
681
  `
687
682
  };
688
683
  }
689
684
  function generateReactJsxPattern(ctx) {
690
- if (!ctx.hasPattern)
691
- return [];
692
685
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate2(name, pattern, ctx.jsxFactory));
693
686
  }
694
687
 
@@ -705,7 +698,7 @@ function generateSolidJsxFactory(ctx) {
705
698
 
706
699
  type Element = keyof JSX.IntrinsicElements
707
700
 
708
- export type HTML${upperName}Props<T extends Element> = Assign<JSX.IntrinsicElements[T], JSXStyleProperties>
701
+ export type HTML${upperName}Props<T extends Element> = Omit<JSX.IntrinsicElements[T], 'color'> | JSXStyleProperties
709
702
 
710
703
  type JSXFactory = {
711
704
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -714,8 +707,8 @@ function generateSolidJsxFactory(ctx) {
714
707
  export declare const ${name}: JSXFactory
715
708
  `,
716
709
  js: import_outdent12.outdent`
717
- import { Dynamic } from 'solid-js/web';
718
- import { mergeProps, splitProps } from 'solid-js';
710
+ import { Dynamic } from 'solid-js/web'
711
+ import { mergeProps, splitProps } from 'solid-js'
719
712
  import { allCssProperties } from './is-valid-prop'
720
713
  import { css } from '../css'
721
714
 
@@ -744,19 +737,19 @@ function generateSolidJsxFactory(ctx) {
744
737
  }
745
738
 
746
739
  function createFactory() {
747
- const cache = new Map();
740
+ const cache = new Map()
748
741
 
749
742
  return new Proxy(Object.create(null), {
750
743
  get(_, el) {
751
744
  if (!cache.has(el)) {
752
- cache.set(el, styled(el));
745
+ cache.set(el, styled(el))
753
746
  }
754
- return cache.get(el);
747
+ return cache.get(el)
755
748
  },
756
749
  })
757
750
  }
758
751
 
759
- export const ${name} = createFactory();
752
+ export const ${name} = createFactory()
760
753
  `
761
754
  };
762
755
  }
@@ -848,20 +841,18 @@ function generate3(name, pattern, jsxFactory) {
848
841
  import { Assign, JSXStyleProperties } from '../types'
849
842
 
850
843
  type ElementType = keyof JSX.IntrinsicElements
851
- type PropsOf<C extends ElementType> = ComponentProps<C>
852
844
 
853
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
854
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
845
+ type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
846
+ Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
855
847
 
856
848
  export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
857
849
 
858
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
850
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
851
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
859
852
  `
860
853
  };
861
854
  }
862
855
  function generateSolidJsxPattern(ctx) {
863
- if (!ctx.hasPattern)
864
- return [];
865
856
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate3(name, pattern, ctx.jsxFactory));
866
857
  }
867
858
 
@@ -880,6 +871,8 @@ var patternMap = {
880
871
  preact: generatePreactJsxPattern
881
872
  };
882
873
  function generateJsxPatterns(ctx) {
874
+ if (!ctx.hasPatterns)
875
+ return [];
883
876
  return patternMap[ctx.jsxFramework](ctx);
884
877
  }
885
878
  var layoutGridMap = {
@@ -942,7 +935,7 @@ function generate4(name, pattern) {
942
935
  };
943
936
  }
944
937
  function generatePattern(ctx) {
945
- if (!ctx.hasPattern)
938
+ if (!ctx.hasPatterns)
946
939
  return;
947
940
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(name, pattern));
948
941
  }
@@ -1616,6 +1609,7 @@ var import_fs_extra2 = require("fs-extra");
1616
1609
  var import_promises = require("fs/promises");
1617
1610
  var import_path3 = require("path");
1618
1611
  var import_postcss = __toESM(require("postcss"));
1612
+ var import_ts_morph = require("ts-morph");
1619
1613
  var import_ts_pattern6 = require("ts-pattern");
1620
1614
  var helpers = {
1621
1615
  map: import_shared11.mapObject
@@ -1719,6 +1713,7 @@ function createContext(conf, io = fileSystem) {
1719
1713
  function getPatternFnName(jsx) {
1720
1714
  return patternNodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared11.uncapitalize)(jsx);
1721
1715
  }
1716
+ const hasPatterns = Object.keys(patterns).length > 0;
1722
1717
  function getRecipe(name) {
1723
1718
  const recipe = recipes[name];
1724
1719
  if (!recipe) {
@@ -1741,6 +1736,7 @@ function createContext(conf, io = fileSystem) {
1741
1736
  return [{}, props];
1742
1737
  return splitProps(props, recipe.props);
1743
1738
  }
1739
+ const hasRecipes = Object.keys(recipes).length > 0;
1744
1740
  const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
1745
1741
  function isProperty(prop) {
1746
1742
  const regex = new RegExp("^(?:" + properties.join("|") + ")$");
@@ -1815,14 +1811,46 @@ function createContext(conf, io = fileSystem) {
1815
1811
  }
1816
1812
  const files = getFiles();
1817
1813
  import_logger4.logger.debug({ type: "ctx:files", msg: files });
1814
+ const tsProject = (0, import_parser.createProject)();
1815
+ function addSourceFile(file) {
1816
+ tsProject.createSourceFile(file, (0, import_fs3.readFileSync)(file, "utf8"), {
1817
+ overwrite: true,
1818
+ scriptKind: import_ts_morph.ScriptKind.TSX
1819
+ });
1820
+ }
1821
+ function reloadSourceFile(file) {
1822
+ const sourceFile = tsProject.getSourceFile(file);
1823
+ sourceFile?.refreshFromFileSystemSync();
1824
+ }
1825
+ function reloadSourceFiles() {
1826
+ const files2 = getFiles();
1827
+ for (const file of files2) {
1828
+ const source = tsProject.getSourceFile(file);
1829
+ if (source) {
1830
+ source.refreshFromFileSystemSync();
1831
+ } else {
1832
+ tsProject.addSourceFileAtPath(file);
1833
+ }
1834
+ }
1835
+ }
1836
+ function getSourceFile(file) {
1837
+ return tsProject.getSourceFile(absPath(file));
1838
+ }
1839
+ function removeSourceFile(file) {
1840
+ const sourceFile = tsProject.getSourceFile(absPath(file));
1841
+ if (sourceFile) {
1842
+ return tsProject.removeSourceFile(sourceFile);
1843
+ }
1844
+ }
1845
+ files.forEach((file) => {
1846
+ addSourceFile(file);
1847
+ });
1818
1848
  const importMap = {
1819
1849
  css: `${outdir}/css`,
1820
1850
  recipe: `${outdir}/recipes`,
1821
1851
  pattern: `${outdir}/patterns`,
1822
1852
  jsx: `${outdir}/jsx`
1823
1853
  };
1824
- const tsProject = (0, import_parser.createProject)();
1825
- tsProject.addSourceFilesAtPaths(files);
1826
1854
  const parseSourceFile = (0, import_parser.createParser)({
1827
1855
  importMap,
1828
1856
  jsx: {
@@ -1904,29 +1932,11 @@ function createContext(conf, io = fileSystem) {
1904
1932
  exclude,
1905
1933
  conditions,
1906
1934
  importMap,
1907
- reloadSourceFiles() {
1908
- const files2 = getFiles();
1909
- for (const file of files2) {
1910
- const source = tsProject.getSourceFile(file);
1911
- if (source) {
1912
- source.refreshFromFileSystemSync();
1913
- } else {
1914
- tsProject.addSourceFileAtPath(file);
1915
- }
1916
- }
1917
- },
1918
- getSourceFile(file) {
1919
- return tsProject.getSourceFile(absPath(file));
1920
- },
1921
- addSourceFile(file) {
1922
- return tsProject.addSourceFileAtPath(absPath(file));
1923
- },
1924
- removeSourceFile(file) {
1925
- const sourceFile = tsProject.getSourceFile(absPath(file));
1926
- if (sourceFile) {
1927
- return tsProject.removeSourceFile(sourceFile);
1928
- }
1929
- },
1935
+ reloadSourceFiles,
1936
+ getSourceFile,
1937
+ addSourceFile,
1938
+ reloadSourceFile,
1939
+ removeSourceFile,
1930
1940
  parseSourceFile,
1931
1941
  getPath,
1932
1942
  paths,
@@ -1938,14 +1948,14 @@ function createContext(conf, io = fileSystem) {
1938
1948
  utility,
1939
1949
  collectStyles,
1940
1950
  patterns,
1941
- hasPattern: Object.keys(patterns).length > 0,
1951
+ hasPatterns,
1942
1952
  getPattern,
1943
1953
  execPattern,
1944
1954
  patternNodes,
1945
1955
  getPatternFnName,
1946
1956
  recipes,
1947
1957
  getRecipe,
1948
- hasRecipes: Object.keys(recipes).length > 0,
1958
+ hasRecipes,
1949
1959
  jsxFramework,
1950
1960
  jsxFactory,
1951
1961
  cssVarRoot,
@@ -2118,6 +2128,7 @@ var import_logger8 = require("@pandacss/logger");
2118
2128
  var import_logger7 = require("@pandacss/logger");
2119
2129
  var import_chokidar = __toESM(require("chokidar"));
2120
2130
  var import_path6 = require("path");
2131
+ var import_ts_pattern7 = require("ts-pattern");
2121
2132
  function createWatcher(files, options = {}) {
2122
2133
  const { ignore, cwd = process.cwd(), poll } = options;
2123
2134
  const coalesce = poll || process.platform === "win32";
@@ -2149,13 +2160,17 @@ async function createContentWatcher(ctx, callback) {
2149
2160
  });
2150
2161
  watcher.on("all", async (event, file) => {
2151
2162
  import_logger7.logger.debug({ type: `file:${event}`, file });
2152
- ctx.removeSourceFile(file);
2153
- if (event === "unlink") {
2163
+ (0, import_ts_pattern7.match)(event).with("unlink", () => {
2164
+ ctx.removeSourceFile(file);
2154
2165
  ctx.chunks.rm(file);
2155
- } else {
2166
+ }).with("change", async () => {
2167
+ ctx.reloadSourceFile(file);
2168
+ await callback(file);
2169
+ }).with("add", async () => {
2156
2170
  ctx.addSourceFile(file);
2157
2171
  await callback(file);
2158
- }
2172
+ }).otherwise(() => {
2173
+ });
2159
2174
  });
2160
2175
  return watcher;
2161
2176
  }
package/dist/index.mjs CHANGED
@@ -278,10 +278,9 @@ function generatePreactJsxFactory(ctx) {
278
278
  import type { JSXStyleProperties } from '../types'
279
279
 
280
280
  type Element = keyof JSX.IntrinsicElements
281
-
282
- type Merge<P, T> = Omit<P, 'color'> & T;
283
281
 
284
- export type HTML${upperName}Props<T extends Element> = Merge<ComponentProps<T>, JSXStyleProperties>
282
+ export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties
283
+
285
284
 
286
285
  type JSXFactory = {
287
286
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -290,8 +289,8 @@ function generatePreactJsxFactory(ctx) {
290
289
  export declare const ${name}: JSXFactory
291
290
  `,
292
291
  js: outdent6`
293
- import { h } from 'preact';
294
- import { forwardRef } from 'preact/compat';
292
+ import { h } from 'preact'
293
+ import { forwardRef } from 'preact/compat'
295
294
  import { isCssProperty } from './is-valid-prop'
296
295
  import { css } from '../css'
297
296
 
@@ -326,7 +325,7 @@ function generatePreactJsxFactory(ctx) {
326
325
  return cx(atomicClass, elementProps.className)
327
326
  }
328
327
 
329
- return h(Element, { ...elementProps, ref, className: classes() });
328
+ return h(Element, { ...elementProps, ref, className: classes() })
330
329
  })
331
330
 
332
331
  ${upperName}Component.displayName = \`${name}.\${Dynamic}\`
@@ -346,7 +345,7 @@ function generatePreactJsxFactory(ctx) {
346
345
  })
347
346
  }
348
347
 
349
- export const ${name} = createFactory();
348
+ export const ${name} = createFactory()
350
349
  `
351
350
  };
352
351
  }
@@ -440,22 +439,18 @@ function generate(name, pattern, jsxFactory) {
440
439
  import { JSXStyleProperties, Assign } from '../types'
441
440
 
442
441
  type ElementType = keyof JSX.IntrinsicElements
443
-
444
- type PropsWithChildren<T> = T & { children?: ComponentChildren }
445
- type PropsOf<C extends ElementType> = ComponentProps<C>
446
-
447
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
448
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
442
+
443
+ type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
444
+ Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
449
445
 
450
446
  type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
451
447
 
452
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
448
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
449
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
453
450
  `
454
451
  };
455
452
  }
456
453
  function generatePreactJsxPattern(ctx) {
457
- if (!ctx.hasPattern)
458
- return [];
459
454
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate(name, pattern, ctx.jsxFactory));
460
455
  }
461
456
 
@@ -472,7 +467,7 @@ function generateReactJsxFactory(ctx) {
472
467
 
473
468
  type Element = keyof JSX.IntrinsicElements
474
469
 
475
- export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, "color"> & JSXStyleProperties
470
+ export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties;
476
471
 
477
472
  type JSXFactory = {
478
473
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -630,20 +625,18 @@ function generate2(name, pattern, jsxFactory) {
630
625
  import { ${upperName}Properties } from '../patterns/${dashCase2(name)}'
631
626
  import { JSXStyleProperties, Assign } from '../types'
632
627
 
633
- type PropsOf<C extends ElementType> = ComponentProps<C>
634
-
635
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
636
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
628
+ type Polymorphic<C extends ElementType = "div", P = {}> =
629
+ | JSXStyleProperties
630
+ | Assign<Omit<ComponentProps<C>, "color">, P & { as?: C }>
637
631
 
638
632
  export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
639
633
 
640
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
634
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
635
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
641
636
  `
642
637
  };
643
638
  }
644
639
  function generateReactJsxPattern(ctx) {
645
- if (!ctx.hasPattern)
646
- return [];
647
640
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate2(name, pattern, ctx.jsxFactory));
648
641
  }
649
642
 
@@ -660,7 +653,7 @@ function generateSolidJsxFactory(ctx) {
660
653
 
661
654
  type Element = keyof JSX.IntrinsicElements
662
655
 
663
- export type HTML${upperName}Props<T extends Element> = Assign<JSX.IntrinsicElements[T], JSXStyleProperties>
656
+ export type HTML${upperName}Props<T extends Element> = Omit<JSX.IntrinsicElements[T], 'color'> | JSXStyleProperties
664
657
 
665
658
  type JSXFactory = {
666
659
  [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
@@ -669,8 +662,8 @@ function generateSolidJsxFactory(ctx) {
669
662
  export declare const ${name}: JSXFactory
670
663
  `,
671
664
  js: outdent12`
672
- import { Dynamic } from 'solid-js/web';
673
- import { mergeProps, splitProps } from 'solid-js';
665
+ import { Dynamic } from 'solid-js/web'
666
+ import { mergeProps, splitProps } from 'solid-js'
674
667
  import { allCssProperties } from './is-valid-prop'
675
668
  import { css } from '../css'
676
669
 
@@ -699,19 +692,19 @@ function generateSolidJsxFactory(ctx) {
699
692
  }
700
693
 
701
694
  function createFactory() {
702
- const cache = new Map();
695
+ const cache = new Map()
703
696
 
704
697
  return new Proxy(Object.create(null), {
705
698
  get(_, el) {
706
699
  if (!cache.has(el)) {
707
- cache.set(el, styled(el));
700
+ cache.set(el, styled(el))
708
701
  }
709
- return cache.get(el);
702
+ return cache.get(el)
710
703
  },
711
704
  })
712
705
  }
713
706
 
714
- export const ${name} = createFactory();
707
+ export const ${name} = createFactory()
715
708
  `
716
709
  };
717
710
  }
@@ -803,20 +796,18 @@ function generate3(name, pattern, jsxFactory) {
803
796
  import { Assign, JSXStyleProperties } from '../types'
804
797
 
805
798
  type ElementType = keyof JSX.IntrinsicElements
806
- type PropsOf<C extends ElementType> = ComponentProps<C>
807
799
 
808
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
809
- Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
800
+ type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
801
+ Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
810
802
 
811
803
  export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
812
804
 
813
- export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
805
+ ${pattern.description ? `/** ${pattern.description} */` : ""}
806
+ export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
814
807
  `
815
808
  };
816
809
  }
817
810
  function generateSolidJsxPattern(ctx) {
818
- if (!ctx.hasPattern)
819
- return [];
820
811
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate3(name, pattern, ctx.jsxFactory));
821
812
  }
822
813
 
@@ -835,6 +826,8 @@ var patternMap = {
835
826
  preact: generatePreactJsxPattern
836
827
  };
837
828
  function generateJsxPatterns(ctx) {
829
+ if (!ctx.hasPatterns)
830
+ return [];
838
831
  return patternMap[ctx.jsxFramework](ctx);
839
832
  }
840
833
  var layoutGridMap = {
@@ -897,7 +890,7 @@ function generate4(name, pattern) {
897
890
  };
898
891
  }
899
892
  function generatePattern(ctx) {
900
- if (!ctx.hasPattern)
893
+ if (!ctx.hasPatterns)
901
894
  return;
902
895
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(name, pattern));
903
896
  }
@@ -1550,7 +1543,7 @@ import { discardDuplicate as discardDuplicate2 } from "@pandacss/core";
1550
1543
  import { ConfigNotFoundError } from "@pandacss/error";
1551
1544
  import { logger as logger5 } from "@pandacss/logger";
1552
1545
  import { toHash } from "@pandacss/shared";
1553
- import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
1546
+ import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
1554
1547
  import { statSync } from "fs-extra";
1555
1548
  import { resolve as resolve3 } from "path";
1556
1549
 
@@ -1572,11 +1565,12 @@ import { createParser, createProject } from "@pandacss/parser";
1572
1565
  import { capitalize as capitalize10, compact, mapObject, uncapitalize } from "@pandacss/shared";
1573
1566
  import { TokenDictionary } from "@pandacss/token-dictionary";
1574
1567
  import glob from "fast-glob";
1575
- import { readdirSync } from "fs";
1568
+ import { readdirSync, readFileSync as readFileSync4 } from "fs";
1576
1569
  import { emptyDir, ensureDir, existsSync } from "fs-extra";
1577
1570
  import { readFile, unlink, writeFile } from "fs/promises";
1578
1571
  import { extname, isAbsolute, join as join2, relative, resolve, sep } from "path";
1579
1572
  import postcss from "postcss";
1573
+ import { ScriptKind } from "ts-morph";
1580
1574
  import { match as match6, P } from "ts-pattern";
1581
1575
  var helpers = {
1582
1576
  map: mapObject
@@ -1680,6 +1674,7 @@ function createContext(conf, io = fileSystem) {
1680
1674
  function getPatternFnName(jsx) {
1681
1675
  return patternNodes.find((node) => node.name === jsx)?.baseName ?? uncapitalize(jsx);
1682
1676
  }
1677
+ const hasPatterns = Object.keys(patterns).length > 0;
1683
1678
  function getRecipe(name) {
1684
1679
  const recipe = recipes[name];
1685
1680
  if (!recipe) {
@@ -1702,6 +1697,7 @@ function createContext(conf, io = fileSystem) {
1702
1697
  return [{}, props];
1703
1698
  return splitProps(props, recipe.props);
1704
1699
  }
1700
+ const hasRecipes = Object.keys(recipes).length > 0;
1705
1701
  const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
1706
1702
  function isProperty(prop) {
1707
1703
  const regex = new RegExp("^(?:" + properties.join("|") + ")$");
@@ -1776,14 +1772,46 @@ function createContext(conf, io = fileSystem) {
1776
1772
  }
1777
1773
  const files = getFiles();
1778
1774
  logger4.debug({ type: "ctx:files", msg: files });
1775
+ const tsProject = createProject();
1776
+ function addSourceFile(file) {
1777
+ tsProject.createSourceFile(file, readFileSync4(file, "utf8"), {
1778
+ overwrite: true,
1779
+ scriptKind: ScriptKind.TSX
1780
+ });
1781
+ }
1782
+ function reloadSourceFile(file) {
1783
+ const sourceFile = tsProject.getSourceFile(file);
1784
+ sourceFile?.refreshFromFileSystemSync();
1785
+ }
1786
+ function reloadSourceFiles() {
1787
+ const files2 = getFiles();
1788
+ for (const file of files2) {
1789
+ const source = tsProject.getSourceFile(file);
1790
+ if (source) {
1791
+ source.refreshFromFileSystemSync();
1792
+ } else {
1793
+ tsProject.addSourceFileAtPath(file);
1794
+ }
1795
+ }
1796
+ }
1797
+ function getSourceFile(file) {
1798
+ return tsProject.getSourceFile(absPath(file));
1799
+ }
1800
+ function removeSourceFile(file) {
1801
+ const sourceFile = tsProject.getSourceFile(absPath(file));
1802
+ if (sourceFile) {
1803
+ return tsProject.removeSourceFile(sourceFile);
1804
+ }
1805
+ }
1806
+ files.forEach((file) => {
1807
+ addSourceFile(file);
1808
+ });
1779
1809
  const importMap = {
1780
1810
  css: `${outdir}/css`,
1781
1811
  recipe: `${outdir}/recipes`,
1782
1812
  pattern: `${outdir}/patterns`,
1783
1813
  jsx: `${outdir}/jsx`
1784
1814
  };
1785
- const tsProject = createProject();
1786
- tsProject.addSourceFilesAtPaths(files);
1787
1815
  const parseSourceFile = createParser({
1788
1816
  importMap,
1789
1817
  jsx: {
@@ -1865,29 +1893,11 @@ function createContext(conf, io = fileSystem) {
1865
1893
  exclude,
1866
1894
  conditions,
1867
1895
  importMap,
1868
- reloadSourceFiles() {
1869
- const files2 = getFiles();
1870
- for (const file of files2) {
1871
- const source = tsProject.getSourceFile(file);
1872
- if (source) {
1873
- source.refreshFromFileSystemSync();
1874
- } else {
1875
- tsProject.addSourceFileAtPath(file);
1876
- }
1877
- }
1878
- },
1879
- getSourceFile(file) {
1880
- return tsProject.getSourceFile(absPath(file));
1881
- },
1882
- addSourceFile(file) {
1883
- return tsProject.addSourceFileAtPath(absPath(file));
1884
- },
1885
- removeSourceFile(file) {
1886
- const sourceFile = tsProject.getSourceFile(absPath(file));
1887
- if (sourceFile) {
1888
- return tsProject.removeSourceFile(sourceFile);
1889
- }
1890
- },
1896
+ reloadSourceFiles,
1897
+ getSourceFile,
1898
+ addSourceFile,
1899
+ reloadSourceFile,
1900
+ removeSourceFile,
1891
1901
  parseSourceFile,
1892
1902
  getPath,
1893
1903
  paths,
@@ -1899,14 +1909,14 @@ function createContext(conf, io = fileSystem) {
1899
1909
  utility,
1900
1910
  collectStyles,
1901
1911
  patterns,
1902
- hasPattern: Object.keys(patterns).length > 0,
1912
+ hasPatterns,
1903
1913
  getPattern,
1904
1914
  execPattern,
1905
1915
  patternNodes,
1906
1916
  getPatternFnName,
1907
1917
  recipes,
1908
1918
  getRecipe,
1909
- hasRecipes: Object.keys(recipes).length > 0,
1919
+ hasRecipes,
1910
1920
  jsxFramework,
1911
1921
  jsxFactory,
1912
1922
  cssVarRoot,
@@ -1981,7 +1991,7 @@ function getConfigHash() {
1981
1991
  if (!file) {
1982
1992
  throw new ConfigNotFoundError();
1983
1993
  }
1984
- return toHash(readFileSync4(file, "utf-8"));
1994
+ return toHash(readFileSync5(file, "utf-8"));
1985
1995
  }
1986
1996
  var Builder = class {
1987
1997
  fileModifiedMap = /* @__PURE__ */ new Map();
@@ -2079,6 +2089,7 @@ import { logger as logger8 } from "@pandacss/logger";
2079
2089
  import { logger as logger7 } from "@pandacss/logger";
2080
2090
  import chokidar from "chokidar";
2081
2091
  import { join as join3 } from "path";
2092
+ import { match as match7 } from "ts-pattern";
2082
2093
  function createWatcher(files, options = {}) {
2083
2094
  const { ignore, cwd = process.cwd(), poll } = options;
2084
2095
  const coalesce = poll || process.platform === "win32";
@@ -2110,13 +2121,17 @@ async function createContentWatcher(ctx, callback) {
2110
2121
  });
2111
2122
  watcher.on("all", async (event, file) => {
2112
2123
  logger7.debug({ type: `file:${event}`, file });
2113
- ctx.removeSourceFile(file);
2114
- if (event === "unlink") {
2124
+ match7(event).with("unlink", () => {
2125
+ ctx.removeSourceFile(file);
2115
2126
  ctx.chunks.rm(file);
2116
- } else {
2127
+ }).with("change", async () => {
2128
+ ctx.reloadSourceFile(file);
2129
+ await callback(file);
2130
+ }).with("add", async () => {
2117
2131
  ctx.addSourceFile(file);
2118
2132
  await callback(file);
2119
- }
2133
+ }).otherwise(() => {
2134
+ });
2120
2135
  });
2121
2136
  return watcher;
2122
2137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.0.0-dev-20221128065048",
3
+ "version": "0.0.0-dev-20221128112158",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,15 +30,15 @@
30
30
  "telejson": "6.0.8",
31
31
  "ts-pattern": "4.0.6",
32
32
  "ts-morph": "17.0.1",
33
- "@pandacss/types": "0.0.0-dev-20221128065048",
34
- "@pandacss/is-valid-prop": "0.0.0-dev-20221128065048",
35
- "@pandacss/error": "0.0.0-dev-20221128065048",
36
- "@pandacss/parser": "0.0.0-dev-20221128065048",
37
- "@pandacss/shared": "0.0.0-dev-20221128065048",
38
- "@pandacss/token-dictionary": "0.0.0-dev-20221128065048",
39
- "@pandacss/logger": "0.0.0-dev-20221128065048",
40
- "@pandacss/core": "0.0.0-dev-20221128065048",
41
- "@pandacss/config": "0.0.0-dev-20221128065048"
33
+ "@pandacss/types": "0.0.0-dev-20221128112158",
34
+ "@pandacss/is-valid-prop": "0.0.0-dev-20221128112158",
35
+ "@pandacss/error": "0.0.0-dev-20221128112158",
36
+ "@pandacss/parser": "0.0.0-dev-20221128112158",
37
+ "@pandacss/shared": "0.0.0-dev-20221128112158",
38
+ "@pandacss/token-dictionary": "0.0.0-dev-20221128112158",
39
+ "@pandacss/logger": "0.0.0-dev-20221128112158",
40
+ "@pandacss/core": "0.0.0-dev-20221128112158",
41
+ "@pandacss/config": "0.0.0-dev-20221128112158"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/fs-extra": "9.0.13",
@@ -46,7 +46,7 @@
46
46
  "@types/glob-parent": "^5.1.1",
47
47
  "@types/pluralize": "0.0.29",
48
48
  "@types/lodash.merge": "4.6.7",
49
- "@pandacss/fixture": "0.0.0-dev-20221128065048"
49
+ "@pandacss/fixture": "0.0.0-dev-20221128112158"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",