@pandacss/node 0.4.0 → 0.5.1

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.
@@ -0,0 +1,259 @@
1
+ export { discardDuplicate } from '@pandacss/core';
2
+ import * as _pandacss_types from '@pandacss/types';
3
+ import { PandaHookable, Artifact, ConfigResultWithHooks, ParserResultType, Config } from '@pandacss/types';
4
+ import { Generator } from '@pandacss/generator';
5
+ import { Project } from '@pandacss/parser';
6
+ import { Runtime } from '@pandacss/types/src/runtime';
7
+ import { Root, Message } from 'postcss';
8
+
9
+ declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Generator & {
10
+ runtime: Runtime;
11
+ hooks: PandaHookable;
12
+ }) => {
13
+ dir: string;
14
+ readFile(file: string): string;
15
+ getFiles(): string[];
16
+ format(file: string): string;
17
+ getArtifact(file: string, css: string): Artifact;
18
+ rm(file: string): void;
19
+ empty(): void;
20
+ readonly glob: string[];
21
+ };
22
+
23
+ declare const getOutputEngine: ({ paths, runtime: { path, fs }, }: Generator & {
24
+ runtime: Runtime;
25
+ hooks: PandaHookable;
26
+ }) => {
27
+ empty(): void;
28
+ write(output: Artifact | undefined): Promise<void[] | undefined>;
29
+ };
30
+
31
+ declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
32
+ type PandaContext = Generator & {
33
+ runtime: Runtime;
34
+ hooks: PandaHookable;
35
+ project: Project;
36
+ getFiles: () => string[];
37
+ chunks: ReturnType<typeof getChunkEngine>;
38
+ output: ReturnType<typeof getOutputEngine>;
39
+ };
40
+
41
+ type Options = {
42
+ onResult?: (file: string, result: ParserResultType) => void;
43
+ };
44
+ declare function analyzeTokens(ctx: PandaContext, options?: Options): {
45
+ duration: {
46
+ extractTimeByFiles: {
47
+ [k: string]: number;
48
+ };
49
+ extractTotal: number;
50
+ classify: number;
51
+ };
52
+ fileSizes: {
53
+ lineCount: number;
54
+ normal: string | number | any[] | {
55
+ value: any;
56
+ symbol: any;
57
+ exponent: number;
58
+ unit: string;
59
+ };
60
+ minified: string | number | any[] | {
61
+ value: any;
62
+ symbol: any;
63
+ exponent: number;
64
+ unit: string;
65
+ };
66
+ gzip: {
67
+ normal: string | number | any[] | {
68
+ value: any;
69
+ symbol: any;
70
+ exponent: number;
71
+ unit: string;
72
+ };
73
+ minified: string | number | any[] | {
74
+ value: any;
75
+ symbol: any;
76
+ exponent: number;
77
+ unit: string;
78
+ };
79
+ };
80
+ };
81
+ } & {
82
+ counts: {
83
+ filesWithTokens: number;
84
+ propNameUsed: number;
85
+ tokenUsed: number;
86
+ shorthandUsed: number;
87
+ propertyPathUsed: number;
88
+ typeUsed: number;
89
+ instanceNameUsed: number;
90
+ kindUsed: number;
91
+ instanceOfKindUsed: number;
92
+ colorsUsed: number;
93
+ };
94
+ stats: {
95
+ filesWithMostInstance: {
96
+ [k: string]: number;
97
+ };
98
+ filesWithMostPropValueCombinations: {
99
+ [k: string]: number;
100
+ };
101
+ mostUseds: {
102
+ propNames: {
103
+ key: string;
104
+ count: number;
105
+ }[];
106
+ tokens: {
107
+ key: string;
108
+ count: number;
109
+ }[];
110
+ shorthands: {
111
+ key: string;
112
+ count: number;
113
+ }[];
114
+ conditions: {
115
+ key: string;
116
+ count: number;
117
+ }[];
118
+ propertyPaths: {
119
+ key: string;
120
+ count: number;
121
+ }[];
122
+ categories: {
123
+ key: string;
124
+ count: number;
125
+ }[];
126
+ types: {
127
+ key: string;
128
+ count: number;
129
+ }[];
130
+ instanceNames: {
131
+ key: string;
132
+ count: number;
133
+ }[];
134
+ fromKinds: {
135
+ key: string;
136
+ count: number;
137
+ }[];
138
+ instanceOfKinds: {
139
+ key: string;
140
+ count: number;
141
+ }[];
142
+ colors: {
143
+ key: string;
144
+ count: number;
145
+ }[];
146
+ };
147
+ };
148
+ details: {
149
+ byId: Map<number, _pandacss_types.ReportItem>;
150
+ byInstanceId: Map<number, _pandacss_types.ReportInstanceItem>;
151
+ byFilepath: Map<string, Set<number>>;
152
+ byInstanceInFilepath: Map<string, Set<number>>;
153
+ globalMaps: {
154
+ byInstanceOfKind: Map<"function" | "component", Set<number>>;
155
+ byPropertyName: Map<string, Set<number>>;
156
+ byCategory: Map<string, Set<number>>;
157
+ byConditionName: Map<string, Set<number>>;
158
+ byShorthand: Map<string, Set<number>>;
159
+ byTokenName: Map<string, Set<number>>;
160
+ byPropertyPath: Map<string, Set<number>>;
161
+ fromKind: Map<"function" | "component", Set<number>>;
162
+ byType: Map<string, Set<number>>;
163
+ byInstanceName: Map<string, Set<number>>;
164
+ colorsUsed: Map<string, Set<number>>;
165
+ };
166
+ byFilePathMaps: Map<string, {
167
+ byInstanceOfKind: Map<"function" | "component", Set<number>>;
168
+ byPropertyName: Map<string, Set<number>>;
169
+ byCategory: Map<string, Set<number>>;
170
+ byConditionName: Map<string, Set<number>>;
171
+ byShorthand: Map<string, Set<number>>;
172
+ byTokenName: Map<string, Set<number>>;
173
+ byPropertyPath: Map<string, Set<number>>;
174
+ fromKind: Map<"function" | "component", Set<number>>;
175
+ byType: Map<string, Set<number>>;
176
+ byInstanceName: Map<string, Set<number>>;
177
+ colorsUsed: Map<string, Set<number>>;
178
+ }>;
179
+ };
180
+ };
181
+ declare const writeAnalyzeJSON: (fileName: string, result: ReturnType<typeof analyzeTokens>, ctx: PandaContext) => Promise<void>;
182
+
183
+ type ConfigDepsResult = {
184
+ modifiedMap: Map<string, number>;
185
+ isModified: boolean;
186
+ };
187
+ declare class Builder {
188
+ /**
189
+ * The current panda context
190
+ */
191
+ context: PandaContext | undefined;
192
+ writeFileCss(file: string, css: string): void;
193
+ checkConfigDeps(configPath: string, deps: Set<string>): ConfigDepsResult;
194
+ getConfigPath(): string;
195
+ setup(options?: {
196
+ configPath?: string;
197
+ }): Promise<void>;
198
+ setupContext(options: {
199
+ configPath: string;
200
+ depsModifiedMap: Map<string, number>;
201
+ }): Promise<void>;
202
+ getContextOrThrow(): PandaContext;
203
+ get fileModifiedMap(): Map<string, number>;
204
+ get fileCssMap(): Map<string, string>;
205
+ extractFile(ctx: PandaContext, file: string): Promise<string | undefined>;
206
+ extract(): Promise<void>;
207
+ toString(): string;
208
+ isValidRoot(root: Root): boolean;
209
+ write(root: Root): void;
210
+ registerDependency(fn: (dep: Message) => void): void;
211
+ }
212
+
213
+ declare function findConfig(): string | undefined;
214
+ declare function loadConfigAndCreateContext(options?: {
215
+ cwd?: string;
216
+ config?: Config;
217
+ configPath?: string;
218
+ }): Promise<PandaContext>;
219
+
220
+ declare function debugFiles(ctx: PandaContext, options: {
221
+ outdir: string;
222
+ dry: boolean;
223
+ }): Promise<void>;
224
+
225
+ declare function execCommand(cmd: string, cwd: string): Promise<void>;
226
+
227
+ declare function extractFile(ctx: PandaContext, file: string): string | undefined;
228
+ declare function emitArtifacts(ctx: PandaContext): Promise<{
229
+ box: string;
230
+ msg: string;
231
+ }>;
232
+ declare function emitAndExtract(ctx: PandaContext): Promise<{
233
+ files: string[];
234
+ msg: string;
235
+ }>;
236
+ declare function extractCss(ctx: PandaContext): Promise<{
237
+ files: string[];
238
+ msg: string;
239
+ }>;
240
+ declare function bundleCss(ctx: PandaContext, outfile: string): Promise<{
241
+ files: string[];
242
+ msg: string;
243
+ }>;
244
+
245
+ declare function generate(config: Config, configPath?: string): Promise<void>;
246
+
247
+ declare function setupGitIgnore(ctx: PandaContext): void;
248
+
249
+ declare function parseDependency(fileOrGlob: string): Message | null;
250
+
251
+ type SetupOptions = Partial<Config> & {
252
+ force?: boolean;
253
+ };
254
+ declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
255
+ declare function setupPostcss(cwd: string): Promise<void>;
256
+
257
+ declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
258
+
259
+ export { Builder, PandaContext, analyzeTokens, bundleCss, createContext, debugFiles, emitAndExtract, emitArtifacts, execCommand, extractCss, extractFile, findConfig, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON };
package/dist/index.d.ts CHANGED
@@ -225,19 +225,30 @@ declare function debugFiles(ctx: PandaContext, options: {
225
225
  declare function execCommand(cmd: string, cwd: string): Promise<void>;
226
226
 
227
227
  declare function extractFile(ctx: PandaContext, file: string): string | undefined;
228
- declare function emitArtifacts(ctx: PandaContext): Promise<string>;
229
- declare function emitAndExtract(ctx: PandaContext): Promise<string>;
230
- declare function extractCss(ctx: PandaContext): Promise<string>;
228
+ declare function emitArtifacts(ctx: PandaContext): Promise<{
229
+ box: string;
230
+ msg: string;
231
+ }>;
232
+ declare function emitAndExtract(ctx: PandaContext): Promise<{
233
+ files: string[];
234
+ msg: string;
235
+ }>;
236
+ declare function extractCss(ctx: PandaContext): Promise<{
237
+ files: string[];
238
+ msg: string;
239
+ }>;
240
+ declare function bundleCss(ctx: PandaContext, outfile: string): Promise<{
241
+ files: string[];
242
+ msg: string;
243
+ }>;
231
244
 
232
245
  declare function generate(config: Config, configPath?: string): Promise<void>;
233
246
 
234
- declare function parseDependency(fileOrGlob: string): Message | null;
235
-
236
247
  declare function setupGitIgnore(ctx: PandaContext): void;
237
248
 
238
- type SetupOptions = {
239
- outExtension?: string;
240
- jsxFramework?: string;
249
+ declare function parseDependency(fileOrGlob: string): Message | null;
250
+
251
+ type SetupOptions = Partial<Config> & {
241
252
  force?: boolean;
242
253
  };
243
254
  declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
@@ -245,4 +256,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
245
256
 
246
257
  declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
247
258
 
248
- export { Builder, PandaContext, analyzeTokens, createContext, debugFiles, emitAndExtract, emitArtifacts, execCommand, extractCss, extractFile, findConfig, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON };
259
+ export { Builder, PandaContext, analyzeTokens, bundleCss, createContext, debugFiles, emitAndExtract, emitArtifacts, execCommand, extractCss, extractFile, findConfig, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON };
package/dist/index.js CHANGED
@@ -33,15 +33,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "use strict";
39
40
  }
40
41
  });
41
42
 
42
43
  // ../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js
43
44
  var require_eastasianwidth = __commonJS({
44
45
  "../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js"(exports, module2) {
46
+ "use strict";
45
47
  init_cjs_shims();
46
48
  var eaw = {};
47
49
  if ("undefined" == typeof module2) {
@@ -403,6 +405,7 @@ var src_exports = {};
403
405
  __export(src_exports, {
404
406
  Builder: () => Builder,
405
407
  analyzeTokens: () => analyzeTokens,
408
+ bundleCss: () => bundleCss,
406
409
  createContext: () => createContext,
407
410
  debugFiles: () => debugFiles,
408
411
  discardDuplicate: () => import_core3.discardDuplicate,
@@ -789,6 +792,7 @@ init_cjs_shims();
789
792
  var import_config = require("@pandacss/config");
790
793
  var import_hookable = require("hookable");
791
794
  var import_look_it_up = require("look-it-up");
795
+ var import_tsconfck = require("tsconfck");
792
796
 
793
797
  // src/create-context.ts
794
798
  init_cjs_shims();
@@ -948,6 +952,7 @@ var createContext = (conf) => (0, import_lil_fp.pipe)(
948
952
  }),
949
953
  import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs }, parserOptions }) => {
950
954
  return (0, import_parser.createProject)({
955
+ ...conf.tsconfig,
951
956
  getFiles,
952
957
  readFile: fs.readFileSync,
953
958
  hooks: conf.hooks,
@@ -978,6 +983,11 @@ async function loadConfigAndCreateContext(options = {}) {
978
983
  if (options.cwd) {
979
984
  conf.config.cwd = options.cwd;
980
985
  }
986
+ const tsconfigResult = await (0, import_tsconfck.parse)(conf.path, { root: cwd, resolveWithEmptyIfConfigNotFound: true });
987
+ if (tsconfigResult) {
988
+ conf.tsconfig = tsconfigResult.tsconfig;
989
+ conf.tsconfigFile = tsconfigResult.tsconfigFile;
990
+ }
981
991
  conf.config.outdir ??= "styled-system";
982
992
  if (conf.config.hooks) {
983
993
  hooks.addHooks(conf.config.hooks);
@@ -2293,12 +2303,14 @@ var createBox = (options) => boxen(options.content, {
2293
2303
  });
2294
2304
 
2295
2305
  // src/extract.ts
2306
+ var import_promises2 = require("fs/promises");
2296
2307
  async function bundleChunks(ctx) {
2297
2308
  const files = ctx.chunks.getFiles();
2298
- return ctx.output.write({
2309
+ await ctx.output.write({
2299
2310
  dir: ctx.paths.root,
2300
2311
  files: [{ file: "styles.css", code: ctx.getCss({ files }) }]
2301
2312
  });
2313
+ return { files, msg: ctx.messages.buildComplete(files.length) };
2302
2314
  }
2303
2315
  async function writeFileChunk(ctx, file) {
2304
2316
  const { path: path2 } = ctx.runtime;
@@ -2340,21 +2352,29 @@ async function emitArtifacts(ctx) {
2340
2352
  if (ctx.config.clean)
2341
2353
  ctx.output.empty();
2342
2354
  await Promise.all(ctx.getArtifacts().map(ctx.output.write));
2343
- return ctx.messages.artifactsGenerated() + createBox({
2344
- content: ctx.messages.codegenComplete(),
2345
- title: `\u{1F43C} ${pickRandom(randomWords)}! \u2728`
2346
- });
2355
+ return {
2356
+ box: createBox({
2357
+ content: ctx.messages.codegenComplete(),
2358
+ title: `\u{1F43C} ${pickRandom(randomWords)}! \u2728`
2359
+ }),
2360
+ msg: ctx.messages.artifactsGenerated()
2361
+ };
2347
2362
  }
2348
2363
  async function emitAndExtract(ctx) {
2349
2364
  await emitArtifacts(ctx);
2350
- if (ctx.config.emitTokensOnly)
2351
- return "Successfully rebuilt the css variables and js function to query your tokens \u2728";
2365
+ if (ctx.config.emitTokensOnly) {
2366
+ return { files: [], msg: "Successfully rebuilt the css variables and js function to query your tokens \u2728" };
2367
+ }
2352
2368
  return extractCss(ctx);
2353
2369
  }
2354
2370
  async function extractCss(ctx) {
2355
2371
  await extractFiles(ctx);
2356
- await bundleChunks(ctx);
2357
- return ctx.messages.buildComplete(ctx.getFiles().length);
2372
+ return bundleChunks(ctx);
2373
+ }
2374
+ async function bundleCss(ctx, outfile) {
2375
+ const files = ctx.chunks.getFiles();
2376
+ await (0, import_promises2.writeFile)(outfile, ctx.getCss({ files, resolve: true }));
2377
+ return { files, msg: ctx.messages.buildComplete(files.length) };
2358
2378
  }
2359
2379
 
2360
2380
  // src/parse-dependency.ts
@@ -2447,7 +2467,18 @@ var Builder = class {
2447
2467
  async setup(options = {}) {
2448
2468
  import_logger4.logger.debug("builder", "\u{1F6A7} Setup");
2449
2469
  const configPath = options.configPath ?? this.getConfigPath();
2450
- const { deps: configDeps } = (0, import_config2.getConfigDependencies)(configPath);
2470
+ let tsOptions = { baseUrl: void 0, pathMappings: [] };
2471
+ if (this.context?.tsconfig) {
2472
+ const options2 = this.context.tsconfig.compilerOptions;
2473
+ if (options2?.paths) {
2474
+ const baseUrl = options2.baseUrl;
2475
+ tsOptions = {
2476
+ baseUrl,
2477
+ pathMappings: (0, import_config2.convertTsPathsToRegexes)(options2?.paths, baseUrl ?? this.context.config.cwd)
2478
+ };
2479
+ }
2480
+ }
2481
+ const { deps: configDeps } = (0, import_config2.getConfigDependencies)(configPath, tsOptions);
2451
2482
  const deps = this.checkConfigDeps(configPath, configDeps);
2452
2483
  if (deps.isModified) {
2453
2484
  await this.setupContext({
@@ -2583,12 +2614,11 @@ async function debugFiles(ctx, options) {
2583
2614
  measure();
2584
2615
  if (!result)
2585
2616
  return;
2586
- const list = result.toArray().map((resultItem) => resultItem.box?.toJSON?.() ?? resultItem);
2587
2617
  const css = ctx.getParserCss(result);
2588
2618
  if (!css)
2589
2619
  return;
2590
2620
  if (options.dry) {
2591
- console.log({ path: file, ast: list, code: css });
2621
+ console.log({ path: file, ast: result, code: css });
2592
2622
  return Promise.resolve();
2593
2623
  }
2594
2624
  if (outdir) {
@@ -2600,7 +2630,7 @@ async function debugFiles(ctx, options) {
2600
2630
  import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${astJsonPath}`)}`);
2601
2631
  import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${cssPath}`)}`);
2602
2632
  return Promise.all([
2603
- fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(list, debugResultSerializer, 2)),
2633
+ fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2604
2634
  fs.writeFile(`${outdir}/${cssPath}`, css)
2605
2635
  ]);
2606
2636
  }
@@ -2609,15 +2639,6 @@ async function debugFiles(ctx, options) {
2609
2639
  import_logger5.logger.info("cli", `Found ${import_logger5.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2610
2640
  measureTotal();
2611
2641
  }
2612
- var debugResultSerializer = (_key, value) => {
2613
- if (value instanceof Set) {
2614
- return Array.from(value);
2615
- }
2616
- if (value instanceof Map) {
2617
- return Object.fromEntries(value);
2618
- }
2619
- return value;
2620
- };
2621
2642
 
2622
2643
  // src/exec-command.ts
2623
2644
  init_cjs_shims();
@@ -2656,7 +2677,7 @@ var loadContext = async (config, configPath) => {
2656
2677
 
2657
2678
  // src/generate.ts
2658
2679
  async function build(ctx) {
2659
- const msg = await emitAndExtract(ctx);
2680
+ const { msg } = await emitAndExtract(ctx);
2660
2681
  import_logger7.logger.info("css:emit", msg);
2661
2682
  }
2662
2683
  async function generate(config, configPath) {
@@ -2723,15 +2744,15 @@ function setupGitIgnore(ctx) {
2723
2744
 
2724
2745
  // src/setup-config.ts
2725
2746
  init_cjs_shims();
2726
- var import_logger8 = require("@pandacss/logger");
2727
2747
  var import_generator2 = require("@pandacss/generator");
2748
+ var import_logger8 = require("@pandacss/logger");
2728
2749
  var import_fs_extra3 = require("fs-extra");
2729
2750
  var import_look_it_up3 = require("look-it-up");
2730
2751
  var import_outdent2 = require("outdent");
2731
2752
  var import_path3 = require("path");
2732
2753
  var import_preferred_pm2 = __toESM(require("preferred-pm"));
2733
2754
  async function setupConfig(cwd, opts = {}) {
2734
- const { force, outExtension, jsxFramework } = opts;
2755
+ const { force, outExtension, jsxFramework, syntax } = opts;
2735
2756
  const configFile = findConfig();
2736
2757
  const pmResult = await (0, import_preferred_pm2.default)(cwd);
2737
2758
  const pm = pmResult?.name ?? "npm";
@@ -2767,6 +2788,9 @@ outExtension: '${outExtension}',` : ""}
2767
2788
  ${jsxFramework ? `
2768
2789
  // The JSX framework to use
2769
2790
  jsxFramework: '${jsxFramework}'` : ""}
2791
+ ${syntax ? `
2792
+ // The CSS Syntax to use to use
2793
+ syntax: '${syntax}'` : ""}
2770
2794
  })
2771
2795
  `;
2772
2796
  await (0, import_fs_extra3.writeFile)((0, import_path3.join)(cwd, file), content);
@@ -2789,7 +2813,7 @@ module.exports = {
2789
2813
  init_cjs_shims();
2790
2814
  var import_logger9 = require("@pandacss/logger");
2791
2815
  var import_parser2 = require("@pandacss/parser");
2792
- var import_promises2 = require("fs/promises");
2816
+ var import_promises3 = require("fs/promises");
2793
2817
  var path = __toESM(require("path"));
2794
2818
  async function shipFiles(ctx, outfile) {
2795
2819
  const files = ctx.getFiles();
@@ -2809,13 +2833,14 @@ async function shipFiles(ctx, outfile) {
2809
2833
  const minify = ctx.config.minify;
2810
2834
  import_logger9.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger9.colors.bold(outfile)}`);
2811
2835
  const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
2812
- await (0, import_promises2.writeFile)(outfile, output);
2836
+ await (0, import_promises3.writeFile)(outfile, output);
2813
2837
  import_logger9.logger.info("cli", "Done!");
2814
2838
  }
2815
2839
  // Annotate the CommonJS export names for ESM import in node:
2816
2840
  0 && (module.exports = {
2817
2841
  Builder,
2818
2842
  analyzeTokens,
2843
+ bundleCss,
2819
2844
  createContext,
2820
2845
  debugFiles,
2821
2846
  discardDuplicate,
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  }) : x)(function(x) {
10
10
  if (typeof require !== "undefined")
11
11
  return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
13
  });
14
14
  var __esm = (fn, res) => function __init() {
15
15
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -34,15 +34,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // ../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/esm_shims.js
37
+ // ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/esm_shims.js
38
38
  var init_esm_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/esm_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/esm_shims.js"() {
40
+ "use strict";
40
41
  }
41
42
  });
42
43
 
43
44
  // ../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js
44
45
  var require_eastasianwidth = __commonJS({
45
46
  "../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js"(exports, module) {
47
+ "use strict";
46
48
  init_esm_shims();
47
49
  var eaw = {};
48
50
  if ("undefined" == typeof module) {
@@ -754,7 +756,7 @@ var writeAnalyzeJSON = (fileName, result, ctx) => {
754
756
 
755
757
  // src/builder.ts
756
758
  init_esm_shims();
757
- import { getConfigDependencies } from "@pandacss/config";
759
+ import { getConfigDependencies, convertTsPathsToRegexes } from "@pandacss/config";
758
760
  import { discardDuplicate, mergeCss as mergeCss2 } from "@pandacss/core";
759
761
  import { ConfigNotFoundError } from "@pandacss/error";
760
762
  import { logger as logger4 } from "@pandacss/logger";
@@ -767,6 +769,7 @@ init_esm_shims();
767
769
  import { loadConfigFile } from "@pandacss/config";
768
770
  import { createDebugger, createHooks } from "hookable";
769
771
  import { lookItUpSync } from "look-it-up";
772
+ import { parse } from "tsconfck";
770
773
 
771
774
  // src/create-context.ts
772
775
  init_esm_shims();
@@ -935,6 +938,7 @@ var createContext = (conf) => pipe(
935
938
  }),
936
939
  Obj.bind("project", ({ getFiles, runtime: { fs }, parserOptions }) => {
937
940
  return createProject({
941
+ ...conf.tsconfig,
938
942
  getFiles,
939
943
  readFile: fs.readFileSync,
940
944
  hooks: conf.hooks,
@@ -965,6 +969,11 @@ async function loadConfigAndCreateContext(options = {}) {
965
969
  if (options.cwd) {
966
970
  conf.config.cwd = options.cwd;
967
971
  }
972
+ const tsconfigResult = await parse(conf.path, { root: cwd, resolveWithEmptyIfConfigNotFound: true });
973
+ if (tsconfigResult) {
974
+ conf.tsconfig = tsconfigResult.tsconfig;
975
+ conf.tsconfigFile = tsconfigResult.tsconfigFile;
976
+ }
968
977
  conf.config.outdir ??= "styled-system";
969
978
  if (conf.config.hooks) {
970
979
  hooks.addHooks(conf.config.hooks);
@@ -2280,12 +2289,14 @@ var createBox = (options) => boxen(options.content, {
2280
2289
  });
2281
2290
 
2282
2291
  // src/extract.ts
2292
+ import { writeFile as writeFile3 } from "fs/promises";
2283
2293
  async function bundleChunks(ctx) {
2284
2294
  const files = ctx.chunks.getFiles();
2285
- return ctx.output.write({
2295
+ await ctx.output.write({
2286
2296
  dir: ctx.paths.root,
2287
2297
  files: [{ file: "styles.css", code: ctx.getCss({ files }) }]
2288
2298
  });
2299
+ return { files, msg: ctx.messages.buildComplete(files.length) };
2289
2300
  }
2290
2301
  async function writeFileChunk(ctx, file) {
2291
2302
  const { path: path2 } = ctx.runtime;
@@ -2327,21 +2338,29 @@ async function emitArtifacts(ctx) {
2327
2338
  if (ctx.config.clean)
2328
2339
  ctx.output.empty();
2329
2340
  await Promise.all(ctx.getArtifacts().map(ctx.output.write));
2330
- return ctx.messages.artifactsGenerated() + createBox({
2331
- content: ctx.messages.codegenComplete(),
2332
- title: `\u{1F43C} ${pickRandom(randomWords)}! \u2728`
2333
- });
2341
+ return {
2342
+ box: createBox({
2343
+ content: ctx.messages.codegenComplete(),
2344
+ title: `\u{1F43C} ${pickRandom(randomWords)}! \u2728`
2345
+ }),
2346
+ msg: ctx.messages.artifactsGenerated()
2347
+ };
2334
2348
  }
2335
2349
  async function emitAndExtract(ctx) {
2336
2350
  await emitArtifacts(ctx);
2337
- if (ctx.config.emitTokensOnly)
2338
- return "Successfully rebuilt the css variables and js function to query your tokens \u2728";
2351
+ if (ctx.config.emitTokensOnly) {
2352
+ return { files: [], msg: "Successfully rebuilt the css variables and js function to query your tokens \u2728" };
2353
+ }
2339
2354
  return extractCss(ctx);
2340
2355
  }
2341
2356
  async function extractCss(ctx) {
2342
2357
  await extractFiles(ctx);
2343
- await bundleChunks(ctx);
2344
- return ctx.messages.buildComplete(ctx.getFiles().length);
2358
+ return bundleChunks(ctx);
2359
+ }
2360
+ async function bundleCss(ctx, outfile) {
2361
+ const files = ctx.chunks.getFiles();
2362
+ await writeFile3(outfile, ctx.getCss({ files, resolve: true }));
2363
+ return { files, msg: ctx.messages.buildComplete(files.length) };
2345
2364
  }
2346
2365
 
2347
2366
  // src/parse-dependency.ts
@@ -2434,7 +2453,18 @@ var Builder = class {
2434
2453
  async setup(options = {}) {
2435
2454
  logger4.debug("builder", "\u{1F6A7} Setup");
2436
2455
  const configPath = options.configPath ?? this.getConfigPath();
2437
- const { deps: configDeps } = getConfigDependencies(configPath);
2456
+ let tsOptions = { baseUrl: void 0, pathMappings: [] };
2457
+ if (this.context?.tsconfig) {
2458
+ const options2 = this.context.tsconfig.compilerOptions;
2459
+ if (options2?.paths) {
2460
+ const baseUrl = options2.baseUrl;
2461
+ tsOptions = {
2462
+ baseUrl,
2463
+ pathMappings: convertTsPathsToRegexes(options2?.paths, baseUrl ?? this.context.config.cwd)
2464
+ };
2465
+ }
2466
+ }
2467
+ const { deps: configDeps } = getConfigDependencies(configPath, tsOptions);
2438
2468
  const deps = this.checkConfigDeps(configPath, configDeps);
2439
2469
  if (deps.isModified) {
2440
2470
  await this.setupContext({
@@ -2570,12 +2600,11 @@ async function debugFiles(ctx, options) {
2570
2600
  measure();
2571
2601
  if (!result)
2572
2602
  return;
2573
- const list = result.toArray().map((resultItem) => resultItem.box?.toJSON?.() ?? resultItem);
2574
2603
  const css = ctx.getParserCss(result);
2575
2604
  if (!css)
2576
2605
  return;
2577
2606
  if (options.dry) {
2578
- console.log({ path: file, ast: list, code: css });
2607
+ console.log({ path: file, ast: result, code: css });
2579
2608
  return Promise.resolve();
2580
2609
  }
2581
2610
  if (outdir) {
@@ -2587,7 +2616,7 @@ async function debugFiles(ctx, options) {
2587
2616
  logger5.info("cli", `Writing ${colors.bold(`${outdir}/${astJsonPath}`)}`);
2588
2617
  logger5.info("cli", `Writing ${colors.bold(`${outdir}/${cssPath}`)}`);
2589
2618
  return Promise.all([
2590
- fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(list, debugResultSerializer, 2)),
2619
+ fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2591
2620
  fs.writeFile(`${outdir}/${cssPath}`, css)
2592
2621
  ]);
2593
2622
  }
@@ -2596,15 +2625,6 @@ async function debugFiles(ctx, options) {
2596
2625
  logger5.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2597
2626
  measureTotal();
2598
2627
  }
2599
- var debugResultSerializer = (_key, value) => {
2600
- if (value instanceof Set) {
2601
- return Array.from(value);
2602
- }
2603
- if (value instanceof Map) {
2604
- return Object.fromEntries(value);
2605
- }
2606
- return value;
2607
- };
2608
2628
 
2609
2629
  // src/exec-command.ts
2610
2630
  init_esm_shims();
@@ -2643,7 +2663,7 @@ var loadContext = async (config, configPath) => {
2643
2663
 
2644
2664
  // src/generate.ts
2645
2665
  async function build(ctx) {
2646
- const msg = await emitAndExtract(ctx);
2666
+ const { msg } = await emitAndExtract(ctx);
2647
2667
  logger7.info("css:emit", msg);
2648
2668
  }
2649
2669
  async function generate(config, configPath) {
@@ -2710,15 +2730,15 @@ function setupGitIgnore(ctx) {
2710
2730
 
2711
2731
  // src/setup-config.ts
2712
2732
  init_esm_shims();
2713
- import { logger as logger8, quote } from "@pandacss/logger";
2714
2733
  import { messages } from "@pandacss/generator";
2715
- import { writeFile as writeFile3 } from "fs-extra";
2734
+ import { logger as logger8, quote } from "@pandacss/logger";
2735
+ import { writeFile as writeFile4 } from "fs-extra";
2716
2736
  import { lookItUpSync as lookItUpSync3 } from "look-it-up";
2717
2737
  import { outdent as outdent2 } from "outdent";
2718
2738
  import { join as join2 } from "path";
2719
2739
  import getPackageManager2 from "preferred-pm";
2720
2740
  async function setupConfig(cwd, opts = {}) {
2721
- const { force, outExtension, jsxFramework } = opts;
2741
+ const { force, outExtension, jsxFramework, syntax } = opts;
2722
2742
  const configFile = findConfig();
2723
2743
  const pmResult = await getPackageManager2(cwd);
2724
2744
  const pm = pmResult?.name ?? "npm";
@@ -2754,9 +2774,12 @@ outExtension: '${outExtension}',` : ""}
2754
2774
  ${jsxFramework ? `
2755
2775
  // The JSX framework to use
2756
2776
  jsxFramework: '${jsxFramework}'` : ""}
2777
+ ${syntax ? `
2778
+ // The CSS Syntax to use to use
2779
+ syntax: '${syntax}'` : ""}
2757
2780
  })
2758
2781
  `;
2759
- await writeFile3(join2(cwd, file), content);
2782
+ await writeFile4(join2(cwd, file), content);
2760
2783
  logger8.log(messages.thankYou());
2761
2784
  }
2762
2785
  }
@@ -2769,14 +2792,14 @@ module.exports = {
2769
2792
  },
2770
2793
  }
2771
2794
  `;
2772
- await writeFile3(join2(cwd, "postcss.config.cjs"), content);
2795
+ await writeFile4(join2(cwd, "postcss.config.cjs"), content);
2773
2796
  }
2774
2797
 
2775
2798
  // src/ship-files.ts
2776
2799
  init_esm_shims();
2777
2800
  import { colors as colors2, logger as logger9 } from "@pandacss/logger";
2778
2801
  import { createParserResult } from "@pandacss/parser";
2779
- import { writeFile as writeFile4 } from "fs/promises";
2802
+ import { writeFile as writeFile5 } from "fs/promises";
2780
2803
  import * as path from "path";
2781
2804
  async function shipFiles(ctx, outfile) {
2782
2805
  const files = ctx.getFiles();
@@ -2796,12 +2819,13 @@ async function shipFiles(ctx, outfile) {
2796
2819
  const minify = ctx.config.minify;
2797
2820
  logger9.info("cli", `Writing ${minify ? "[min] " : " "}${colors2.bold(outfile)}`);
2798
2821
  const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
2799
- await writeFile4(outfile, output);
2822
+ await writeFile5(outfile, output);
2800
2823
  logger9.info("cli", "Done!");
2801
2824
  }
2802
2825
  export {
2803
2826
  Builder,
2804
2827
  analyzeTokens,
2828
+ bundleCss,
2805
2829
  createContext,
2806
2830
  debugFiles,
2807
2831
  discardDuplicate2 as discardDuplicate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,17 +33,18 @@
33
33
  "preferred-pm": "^3.0.3",
34
34
  "ts-morph": "18.0.0",
35
35
  "ts-pattern": "4.3.0",
36
- "@pandacss/core": "0.4.0",
37
- "@pandacss/error": "0.4.0",
38
- "@pandacss/extractor": "0.4.0",
39
- "@pandacss/generator": "0.4.0",
40
- "@pandacss/is-valid-prop": "0.4.0",
41
- "@pandacss/logger": "0.4.0",
42
- "@pandacss/config": "0.4.0",
43
- "@pandacss/parser": "0.4.0",
44
- "@pandacss/token-dictionary": "0.4.0",
45
- "@pandacss/shared": "0.4.0",
46
- "@pandacss/types": "0.4.0"
36
+ "tsconfck": "^2.1.1",
37
+ "@pandacss/config": "0.5.1",
38
+ "@pandacss/core": "0.5.1",
39
+ "@pandacss/error": "0.5.1",
40
+ "@pandacss/extractor": "0.5.1",
41
+ "@pandacss/generator": "0.5.1",
42
+ "@pandacss/is-valid-prop": "0.5.1",
43
+ "@pandacss/logger": "0.5.1",
44
+ "@pandacss/parser": "0.5.1",
45
+ "@pandacss/shared": "0.5.1",
46
+ "@pandacss/token-dictionary": "0.5.1",
47
+ "@pandacss/types": "0.5.1"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/fs-extra": "11.0.1",
@@ -52,7 +53,7 @@
52
53
  "@types/lodash.merge": "4.6.7",
53
54
  "@types/pluralize": "0.0.29",
54
55
  "boxen": "^7.1.0",
55
- "@pandacss/fixture": "0.4.0"
56
+ "@pandacss/fixture": "0.5.1"
56
57
  },
57
58
  "scripts": {
58
59
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",