@pandacss/node 0.0.0-dev-20240130133424 → 0.0.0-dev-20240130182551

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.mts CHANGED
@@ -53,7 +53,7 @@ declare class PandaContext extends Generator {
53
53
  };
54
54
  writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
55
55
  watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
56
- watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>) => void;
56
+ watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include' | 'exclude' | 'poll' | 'cwd' | 'logger'>) => void;
57
57
  }
58
58
 
59
59
  interface Options {
@@ -246,14 +246,14 @@ declare function codegen(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
246
246
  msg: string;
247
247
  }>;
248
248
 
249
- declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
250
-
251
249
  declare function loadConfigAndCreateContext(options?: {
252
250
  cwd?: string;
253
251
  config?: Config;
254
252
  configPath?: string;
255
253
  }): Promise<PandaContext>;
256
254
 
255
+ declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
256
+
257
257
  interface CssGenOptions {
258
258
  cwd: string;
259
259
  outfile?: string;
@@ -273,6 +273,15 @@ declare function generate(config: Config, configPath?: string): Promise<void>;
273
273
 
274
274
  declare function setupGitIgnore(ctx: PandaContext): void;
275
275
 
276
+ interface LogstreamOptions {
277
+ cwd?: string;
278
+ logfile?: string;
279
+ }
280
+ declare const setLogStream: (options: LogstreamOptions) => {
281
+ end(): void;
282
+ [Symbol.dispose]: () => void;
283
+ };
284
+
276
285
  declare function parseDependency(fileOrGlob: string): Message | null;
277
286
 
278
287
  type SetupOptions = Partial<Config> & {
@@ -281,4 +290,4 @@ type SetupOptions = Partial<Config> & {
281
290
  declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
282
291
  declare function setupPostcss(cwd: string): Promise<void>;
283
292
 
284
- export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
293
+ export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setLogStream, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
package/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ declare class PandaContext extends Generator {
53
53
  };
54
54
  writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
55
55
  watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
56
- watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>) => void;
56
+ watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include' | 'exclude' | 'poll' | 'cwd' | 'logger'>) => void;
57
57
  }
58
58
 
59
59
  interface Options {
@@ -246,14 +246,14 @@ declare function codegen(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
246
246
  msg: string;
247
247
  }>;
248
248
 
249
- declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
250
-
251
249
  declare function loadConfigAndCreateContext(options?: {
252
250
  cwd?: string;
253
251
  config?: Config;
254
252
  configPath?: string;
255
253
  }): Promise<PandaContext>;
256
254
 
255
+ declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
256
+
257
257
  interface CssGenOptions {
258
258
  cwd: string;
259
259
  outfile?: string;
@@ -273,6 +273,15 @@ declare function generate(config: Config, configPath?: string): Promise<void>;
273
273
 
274
274
  declare function setupGitIgnore(ctx: PandaContext): void;
275
275
 
276
+ interface LogstreamOptions {
277
+ cwd?: string;
278
+ logfile?: string;
279
+ }
280
+ declare const setLogStream: (options: LogstreamOptions) => {
281
+ end(): void;
282
+ [Symbol.dispose]: () => void;
283
+ };
284
+
276
285
  declare function parseDependency(fileOrGlob: string): Message | null;
277
286
 
278
287
  type SetupOptions = Partial<Config> & {
@@ -281,4 +290,4 @@ type SetupOptions = Partial<Config> & {
281
290
  declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
282
291
  declare function setupPostcss(cwd: string): Promise<void>;
283
292
 
284
- export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
293
+ export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setLogStream, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
package/dist/index.js CHANGED
@@ -413,6 +413,7 @@ __export(src_exports, {
413
413
  generate: () => generate,
414
414
  loadConfigAndCreateContext: () => loadConfigAndCreateContext,
415
415
  parseDependency: () => parseDependency,
416
+ setLogStream: () => setLogStream,
416
417
  setupConfig: () => setupConfig,
417
418
  setupGitIgnore: () => setupGitIgnore,
418
419
  setupPostcss: () => setupPostcss,
@@ -2327,8 +2328,8 @@ var nodeRuntime = {
2327
2328
  readDirSync: import_fs_extra.default.readdirSync,
2328
2329
  rmDirSync: import_fs_extra.default.emptyDirSync,
2329
2330
  rmFileSync: import_fs_extra.default.removeSync,
2330
- ensureDirSync(path2) {
2331
- return import_fs_extra.default.ensureDirSync(path2);
2331
+ ensureDirSync(path3) {
2332
+ return import_fs_extra.default.ensureDirSync(path3);
2332
2333
  },
2333
2334
  watch(options) {
2334
2335
  const { include, exclude, cwd, poll } = options;
@@ -2495,10 +2496,11 @@ var PandaContext = class extends import_generator2.Generator {
2495
2496
  })
2496
2497
  );
2497
2498
  };
2498
- watchFiles = (cb) => {
2499
+ watchFiles = (cb, opts) => {
2499
2500
  const { include, exclude, poll, cwd } = this.config;
2500
2501
  import_logger5.logger.info("ctx:watch", this.messages.watch());
2501
2502
  const watcher = this.runtime.fs.watch({
2503
+ ...opts,
2502
2504
  include,
2503
2505
  exclude,
2504
2506
  poll,
@@ -2837,12 +2839,12 @@ async function debug(ctx, options) {
2837
2839
  const measureTotal = import_logger9.logger.time.debug(`Done parsing ${files.length} files`);
2838
2840
  ctx.config.minify = false;
2839
2841
  ctx.config.optimize = true;
2840
- const { fs: fs2, path: path2 } = ctx.runtime;
2842
+ const { fs: fs3, path: path3 } = ctx.runtime;
2841
2843
  const outdir = options.outdir;
2842
2844
  if (!options.dry && outdir) {
2843
- fs2.ensureDirSync(outdir);
2845
+ fs3.ensureDirSync(outdir);
2844
2846
  import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/config.json`)}`);
2845
- await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2847
+ await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2846
2848
  }
2847
2849
  if (options.onlyConfig) {
2848
2850
  measureTotal();
@@ -2867,14 +2869,14 @@ async function debug(ctx, options) {
2867
2869
  if (outdir) {
2868
2870
  filesWithCss.push(file);
2869
2871
  const parsedPath = (0, import_path5.parse)(file);
2870
- const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
2871
- const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2872
- const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2872
+ const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
2873
+ const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
2874
+ const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path3.sep, "__");
2873
2875
  import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${astJsonPath}`)}`);
2874
2876
  import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${cssPath}`)}`);
2875
2877
  return Promise.allSettled([
2876
- fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2877
- fs2.writeFile(`${outdir}/${cssPath}`, css)
2878
+ fs3.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2879
+ fs3.writeFile(`${outdir}/${cssPath}`, css)
2878
2880
  ]);
2879
2881
  }
2880
2882
  });
@@ -2968,11 +2970,46 @@ function setupGitIgnore(ctx) {
2968
2970
  }
2969
2971
  }
2970
2972
 
2973
+ // src/logstream.ts
2974
+ init_cjs_shims();
2975
+ var import_logger11 = require("@pandacss/logger");
2976
+ var import_node_fs = __toESM(require("fs"));
2977
+ var import_node_path = __toESM(require("path"));
2978
+ var setLogStream = (options) => {
2979
+ const { cwd = process.cwd() } = options;
2980
+ let stream;
2981
+ if (options.logfile) {
2982
+ const outPath = import_node_path.default.resolve(cwd, options.logfile);
2983
+ ensure(outPath);
2984
+ import_logger11.logger.info("logfile", outPath);
2985
+ stream = import_node_fs.default.createWriteStream(outPath, { flags: "a" });
2986
+ import_logger11.logger.onLog = (entry) => {
2987
+ stream?.write(JSON.stringify(entry) + "\n");
2988
+ };
2989
+ }
2990
+ process.once("SIGINT", () => {
2991
+ stream?.end();
2992
+ });
2993
+ return {
2994
+ end() {
2995
+ stream?.end();
2996
+ },
2997
+ [Symbol.dispose]: () => {
2998
+ stream?.end();
2999
+ }
3000
+ };
3001
+ };
3002
+ var ensure = (outPath) => {
3003
+ const dirname2 = import_node_path.default.dirname(outPath);
3004
+ import_node_fs.default.mkdirSync(dirname2, { recursive: true });
3005
+ return outPath;
3006
+ };
3007
+
2971
3008
  // src/setup-config.ts
2972
3009
  init_cjs_shims();
2973
3010
  var import_config7 = require("@pandacss/config");
2974
3011
  var import_core2 = require("@pandacss/core");
2975
- var import_logger11 = require("@pandacss/logger");
3012
+ var import_logger12 = require("@pandacss/logger");
2976
3013
  var import_shared3 = require("@pandacss/shared");
2977
3014
  var import_fs_extra2 = __toESM(require("fs-extra"));
2978
3015
  var import_look_it_up2 = require("look-it-up");
@@ -2995,9 +3032,9 @@ async function setupConfig(cwd, opts = {}) {
2995
3032
  const cmd = pm === "npm" ? "npm run" : pm;
2996
3033
  const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
2997
3034
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2998
- import_logger11.logger.info("init:config", `creating panda config file: ${(0, import_logger11.quote)(file)}`);
3035
+ import_logger12.logger.info("init:config", `creating panda config file: ${(0, import_logger12.quote)(file)}`);
2999
3036
  if (!force && configFile) {
3000
- import_logger11.logger.warn("init:config", import_core2.messages.configExists(cmd));
3037
+ import_logger12.logger.warn("init:config", import_core2.messages.configExists(cmd));
3001
3038
  } else {
3002
3039
  const content = import_outdent2.outdent`
3003
3040
  import { defineConfig } from "@pandacss/dev"
@@ -3030,11 +3067,11 @@ syntax: '${syntax}'` : ""}
3030
3067
  })
3031
3068
  `;
3032
3069
  await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, file), import_prettier.default.format(content, { parser: "babel" }));
3033
- import_logger11.logger.log(import_core2.messages.thankYou());
3070
+ import_logger12.logger.log(import_core2.messages.thankYou());
3034
3071
  }
3035
3072
  }
3036
3073
  async function setupPostcss(cwd) {
3037
- import_logger11.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger11.quote)("postcss.config.cjs")}`);
3074
+ import_logger12.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger12.quote)("postcss.config.cjs")}`);
3038
3075
  const content = import_outdent2.outdent`
3039
3076
  module.exports = {
3040
3077
  plugins: {
@@ -3056,6 +3093,7 @@ module.exports = {
3056
3093
  generate,
3057
3094
  loadConfigAndCreateContext,
3058
3095
  parseDependency,
3096
+ setLogStream,
3059
3097
  setupConfig,
3060
3098
  setupGitIgnore,
3061
3099
  setupPostcss,
package/dist/index.mjs CHANGED
@@ -2302,8 +2302,8 @@ var nodeRuntime = {
2302
2302
  readDirSync: fsExtra.readdirSync,
2303
2303
  rmDirSync: fsExtra.emptyDirSync,
2304
2304
  rmFileSync: fsExtra.removeSync,
2305
- ensureDirSync(path2) {
2306
- return fsExtra.ensureDirSync(path2);
2305
+ ensureDirSync(path3) {
2306
+ return fsExtra.ensureDirSync(path3);
2307
2307
  },
2308
2308
  watch(options) {
2309
2309
  const { include, exclude, cwd, poll } = options;
@@ -2470,10 +2470,11 @@ var PandaContext = class extends Generator2 {
2470
2470
  })
2471
2471
  );
2472
2472
  };
2473
- watchFiles = (cb) => {
2473
+ watchFiles = (cb, opts) => {
2474
2474
  const { include, exclude, poll, cwd } = this.config;
2475
2475
  logger5.info("ctx:watch", this.messages.watch());
2476
2476
  const watcher = this.runtime.fs.watch({
2477
+ ...opts,
2477
2478
  include,
2478
2479
  exclude,
2479
2480
  poll,
@@ -2812,12 +2813,12 @@ async function debug(ctx, options) {
2812
2813
  const measureTotal = logger9.time.debug(`Done parsing ${files.length} files`);
2813
2814
  ctx.config.minify = false;
2814
2815
  ctx.config.optimize = true;
2815
- const { fs: fs2, path: path2 } = ctx.runtime;
2816
+ const { fs: fs3, path: path3 } = ctx.runtime;
2816
2817
  const outdir = options.outdir;
2817
2818
  if (!options.dry && outdir) {
2818
- fs2.ensureDirSync(outdir);
2819
+ fs3.ensureDirSync(outdir);
2819
2820
  logger9.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
2820
- await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2821
+ await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2821
2822
  }
2822
2823
  if (options.onlyConfig) {
2823
2824
  measureTotal();
@@ -2842,14 +2843,14 @@ async function debug(ctx, options) {
2842
2843
  if (outdir) {
2843
2844
  filesWithCss.push(file);
2844
2845
  const parsedPath = parse2(file);
2845
- const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
2846
- const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2847
- const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2846
+ const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
2847
+ const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
2848
+ const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path3.sep, "__");
2848
2849
  logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${astJsonPath}`)}`);
2849
2850
  logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${cssPath}`)}`);
2850
2851
  return Promise.allSettled([
2851
- fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2852
- fs2.writeFile(`${outdir}/${cssPath}`, css)
2852
+ fs3.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2853
+ fs3.writeFile(`${outdir}/${cssPath}`, css)
2853
2854
  ]);
2854
2855
  }
2855
2856
  });
@@ -2943,11 +2944,46 @@ function setupGitIgnore(ctx) {
2943
2944
  }
2944
2945
  }
2945
2946
 
2947
+ // src/logstream.ts
2948
+ init_esm_shims();
2949
+ import { logger as logger11 } from "@pandacss/logger";
2950
+ import fs2 from "node:fs";
2951
+ import path2 from "node:path";
2952
+ var setLogStream = (options) => {
2953
+ const { cwd = process.cwd() } = options;
2954
+ let stream;
2955
+ if (options.logfile) {
2956
+ const outPath = path2.resolve(cwd, options.logfile);
2957
+ ensure(outPath);
2958
+ logger11.info("logfile", outPath);
2959
+ stream = fs2.createWriteStream(outPath, { flags: "a" });
2960
+ logger11.onLog = (entry) => {
2961
+ stream?.write(JSON.stringify(entry) + "\n");
2962
+ };
2963
+ }
2964
+ process.once("SIGINT", () => {
2965
+ stream?.end();
2966
+ });
2967
+ return {
2968
+ end() {
2969
+ stream?.end();
2970
+ },
2971
+ [Symbol.dispose]: () => {
2972
+ stream?.end();
2973
+ }
2974
+ };
2975
+ };
2976
+ var ensure = (outPath) => {
2977
+ const dirname2 = path2.dirname(outPath);
2978
+ fs2.mkdirSync(dirname2, { recursive: true });
2979
+ return outPath;
2980
+ };
2981
+
2946
2982
  // src/setup-config.ts
2947
2983
  init_esm_shims();
2948
2984
  import { findConfig as findConfig2 } from "@pandacss/config";
2949
2985
  import { messages } from "@pandacss/core";
2950
- import { logger as logger11, quote } from "@pandacss/logger";
2986
+ import { logger as logger12, quote } from "@pandacss/logger";
2951
2987
  import { PandaError as PandaError2 } from "@pandacss/shared";
2952
2988
  import fsExtra2 from "fs-extra";
2953
2989
  import { lookItUpSync as lookItUpSync2 } from "look-it-up";
@@ -2970,9 +3006,9 @@ async function setupConfig(cwd, opts = {}) {
2970
3006
  const cmd = pm === "npm" ? "npm run" : pm;
2971
3007
  const isTs = lookItUpSync2("tsconfig.json", cwd);
2972
3008
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2973
- logger11.info("init:config", `creating panda config file: ${quote(file)}`);
3009
+ logger12.info("init:config", `creating panda config file: ${quote(file)}`);
2974
3010
  if (!force && configFile) {
2975
- logger11.warn("init:config", messages.configExists(cmd));
3011
+ logger12.warn("init:config", messages.configExists(cmd));
2976
3012
  } else {
2977
3013
  const content = outdent2`
2978
3014
  import { defineConfig } from "@pandacss/dev"
@@ -3005,11 +3041,11 @@ syntax: '${syntax}'` : ""}
3005
3041
  })
3006
3042
  `;
3007
3043
  await fsExtra2.writeFile(join2(cwd, file), prettier.format(content, { parser: "babel" }));
3008
- logger11.log(messages.thankYou());
3044
+ logger12.log(messages.thankYou());
3009
3045
  }
3010
3046
  }
3011
3047
  async function setupPostcss(cwd) {
3012
- logger11.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
3048
+ logger12.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
3013
3049
  const content = outdent2`
3014
3050
  module.exports = {
3015
3051
  plugins: {
@@ -3030,6 +3066,7 @@ export {
3030
3066
  generate,
3031
3067
  loadConfigAndCreateContext,
3032
3068
  parseDependency,
3069
+ setLogStream,
3033
3070
  setupConfig,
3034
3071
  setupGitIgnore,
3035
3072
  setupPostcss,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.0.0-dev-20240130133424",
3
+ "version": "0.0.0-dev-20240130182551",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -53,15 +53,15 @@
53
53
  "ts-pattern": "5.0.5",
54
54
  "tsconfck": "^2.1.2",
55
55
  "v8-profiler-next": "^1.10.0",
56
- "@pandacss/config": "0.0.0-dev-20240130133424",
57
- "@pandacss/core": "0.0.0-dev-20240130133424",
58
- "@pandacss/extractor": "0.0.0-dev-20240130133424",
59
- "@pandacss/generator": "0.0.0-dev-20240130133424",
60
- "@pandacss/logger": "0.0.0-dev-20240130133424",
61
- "@pandacss/parser": "0.0.0-dev-20240130133424",
62
- "@pandacss/shared": "0.0.0-dev-20240130133424",
63
- "@pandacss/token-dictionary": "0.0.0-dev-20240130133424",
64
- "@pandacss/types": "0.0.0-dev-20240130133424"
56
+ "@pandacss/config": "0.0.0-dev-20240130182551",
57
+ "@pandacss/core": "0.0.0-dev-20240130182551",
58
+ "@pandacss/extractor": "0.0.0-dev-20240130182551",
59
+ "@pandacss/generator": "0.0.0-dev-20240130182551",
60
+ "@pandacss/logger": "0.0.0-dev-20240130182551",
61
+ "@pandacss/parser": "0.0.0-dev-20240130182551",
62
+ "@pandacss/shared": "0.0.0-dev-20240130182551",
63
+ "@pandacss/token-dictionary": "0.0.0-dev-20240130182551",
64
+ "@pandacss/types": "0.0.0-dev-20240130182551"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/fs-extra": "11.0.4",