@pandacss/node 0.0.0-dev-20230614111156 → 0.0.0-dev-20230614142625

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
@@ -1,13 +1,14 @@
1
1
  export { discardDuplicate } from '@pandacss/core';
2
2
  import * as _pandacss_types from '@pandacss/types';
3
- import { Artifact, LoadConfigResult, ParserResultType, Config } from '@pandacss/types';
3
+ import { PandaHookable, Artifact, ConfigResultWithHooks, ParserResultType, Config } from '@pandacss/types';
4
4
  import { Generator } from '@pandacss/generator';
5
5
  import { Project } from '@pandacss/parser';
6
6
  import { Runtime } from '@pandacss/types/src/runtime';
7
7
  import { Root, Message } from 'postcss';
8
8
 
9
- declare const getChunkEngine: ({ paths, config, runtime: { path, fs } }: Generator & {
9
+ declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Generator & {
10
10
  runtime: Runtime;
11
+ hooks: PandaHookable;
11
12
  }) => {
12
13
  dir: string;
13
14
  readFile(file: string): string;
@@ -19,16 +20,18 @@ declare const getChunkEngine: ({ paths, config, runtime: { path, fs } }: Generat
19
20
  readonly glob: string[];
20
21
  };
21
22
 
22
- declare const getOutputEngine: ({ paths, runtime: { path, fs } }: Generator & {
23
+ declare const getOutputEngine: ({ paths, runtime: { path, fs }, }: Generator & {
23
24
  runtime: Runtime;
25
+ hooks: PandaHookable;
24
26
  }) => {
25
27
  empty(): void;
26
28
  write(output: Artifact | undefined): Promise<void[] | undefined>;
27
29
  };
28
30
 
29
- declare const createContext: (conf: LoadConfigResult) => PandaContext;
31
+ declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
30
32
  type PandaContext = Generator & {
31
33
  runtime: Runtime;
34
+ hooks: PandaHookable;
32
35
  project: Project;
33
36
  getFiles: () => string[];
34
37
  chunks: ReturnType<typeof getChunkEngine>;
package/dist/index.js CHANGED
@@ -798,7 +798,11 @@ var import_lil_fp = require("lil-fp");
798
798
  // src/chunk-engine.ts
799
799
  init_cjs_shims();
800
800
  var import_core = require("@pandacss/core");
801
- var getChunkEngine = ({ paths, config, runtime: { path: path2, fs } }) => ({
801
+ var getChunkEngine = ({
802
+ paths,
803
+ config,
804
+ runtime: { path: path2, fs }
805
+ }) => ({
802
806
  dir: path2.join(...paths.chunk),
803
807
  readFile(file) {
804
808
  const fileName = path2.join(...paths.chunk, this.format(file));
@@ -906,7 +910,10 @@ process.on("uncaughtException", (reason) => {
906
910
 
907
911
  // src/output-engine.ts
908
912
  init_cjs_shims();
909
- var getOutputEngine = ({ paths, runtime: { path: path2, fs } }) => ({
913
+ var getOutputEngine = ({
914
+ paths,
915
+ runtime: { path: path2, fs }
916
+ }) => ({
910
917
  empty() {
911
918
  fs.rmDirSync(path2.join(...paths.root));
912
919
  },
@@ -930,7 +937,7 @@ var getOutputEngine = ({ paths, runtime: { path: path2, fs } }) => ({
930
937
  var createContext = (conf) => (0, import_lil_fp.pipe)(
931
938
  conf,
932
939
  import_generator.createGenerator,
933
- import_lil_fp.Obj.assign({ runtime: nodeRuntime }),
940
+ import_lil_fp.Obj.assign({ runtime: nodeRuntime, hooks: conf.hooks }),
934
941
  (0, import_lil_fp.tap)(({ config, runtime }) => {
935
942
  config.cwd ||= runtime.cwd();
936
943
  }),
@@ -942,6 +949,7 @@ var createContext = (conf) => (0, import_lil_fp.pipe)(
942
949
  return (0, import_parser.createProject)({
943
950
  getFiles,
944
951
  readFile: fs.readFileSync,
952
+ hooks: conf.hooks,
945
953
  parserOptions
946
954
  });
947
955
  }),
@@ -950,6 +958,7 @@ var createContext = (conf) => (0, import_lil_fp.pipe)(
950
958
  );
951
959
 
952
960
  // src/config.ts
961
+ var import_hookable = require("hookable");
953
962
  var configs = [".ts", ".js", ".mjs", ".cjs"];
954
963
  function findConfig() {
955
964
  for (const config of configs) {
@@ -960,6 +969,7 @@ function findConfig() {
960
969
  }
961
970
  }
962
971
  async function loadConfigAndCreateContext(options = {}) {
972
+ const hooks = (0, import_hookable.createHooks)();
963
973
  const { cwd = process.cwd(), config, configPath } = options;
964
974
  const conf = await (0, import_config.loadConfigFile)({ cwd, file: configPath });
965
975
  if (config) {
@@ -969,7 +979,14 @@ async function loadConfigAndCreateContext(options = {}) {
969
979
  conf.config.cwd = options.cwd;
970
980
  }
971
981
  conf.config.outdir ??= "styled-system";
972
- return createContext(conf);
982
+ if (conf.config.hooks) {
983
+ hooks.addHooks(conf.config.hooks);
984
+ }
985
+ await hooks.callHook("config:resolved", conf);
986
+ if (conf.config.logLevel === "debug") {
987
+ (0, import_hookable.createDebugger)(hooks, { tag: "panda" });
988
+ }
989
+ return createContext({ ...conf, hooks });
973
990
  }
974
991
 
975
992
  // src/extract.ts
@@ -2433,10 +2450,12 @@ var Builder = class {
2433
2450
  const { deps: configDeps } = (0, import_config2.getConfigDependencies)(configPath);
2434
2451
  const deps = this.checkConfigDeps(configPath, configDeps);
2435
2452
  if (deps.isModified) {
2436
- return this.setupContext({
2453
+ await this.setupContext({
2437
2454
  configPath,
2438
2455
  depsModifiedMap: deps.modifiedMap
2439
2456
  });
2457
+ const updatedCtx = this.context;
2458
+ await updatedCtx.hooks.callHook("config:change", updatedCtx.config);
2440
2459
  }
2441
2460
  const cache = configCache.get(configPath);
2442
2461
  if (cache) {
@@ -2654,6 +2673,7 @@ async function generate(config, configPath) {
2654
2673
  configWatcher.on("change", async () => {
2655
2674
  import_logger7.logger.info("config:change", "Config changed, restarting...");
2656
2675
  await loadCtx();
2676
+ await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
2657
2677
  return build(ctxRef.current);
2658
2678
  });
2659
2679
  const contentWatcher = fs.watch(ctx.config);
package/dist/index.mjs CHANGED
@@ -776,7 +776,11 @@ import { Obj, pipe, tap } from "lil-fp";
776
776
  // src/chunk-engine.ts
777
777
  init_esm_shims();
778
778
  import { mergeCss } from "@pandacss/core";
779
- var getChunkEngine = ({ paths, config, runtime: { path: path2, fs } }) => ({
779
+ var getChunkEngine = ({
780
+ paths,
781
+ config,
782
+ runtime: { path: path2, fs }
783
+ }) => ({
780
784
  dir: path2.join(...paths.chunk),
781
785
  readFile(file) {
782
786
  const fileName = path2.join(...paths.chunk, this.format(file));
@@ -893,7 +897,10 @@ process.on("uncaughtException", (reason) => {
893
897
 
894
898
  // src/output-engine.ts
895
899
  init_esm_shims();
896
- var getOutputEngine = ({ paths, runtime: { path: path2, fs } }) => ({
900
+ var getOutputEngine = ({
901
+ paths,
902
+ runtime: { path: path2, fs }
903
+ }) => ({
897
904
  empty() {
898
905
  fs.rmDirSync(path2.join(...paths.root));
899
906
  },
@@ -917,7 +924,7 @@ var getOutputEngine = ({ paths, runtime: { path: path2, fs } }) => ({
917
924
  var createContext = (conf) => pipe(
918
925
  conf,
919
926
  createGenerator,
920
- Obj.assign({ runtime: nodeRuntime }),
927
+ Obj.assign({ runtime: nodeRuntime, hooks: conf.hooks }),
921
928
  tap(({ config, runtime }) => {
922
929
  config.cwd ||= runtime.cwd();
923
930
  }),
@@ -929,6 +936,7 @@ var createContext = (conf) => pipe(
929
936
  return createProject({
930
937
  getFiles,
931
938
  readFile: fs.readFileSync,
939
+ hooks: conf.hooks,
932
940
  parserOptions
933
941
  });
934
942
  }),
@@ -937,6 +945,7 @@ var createContext = (conf) => pipe(
937
945
  );
938
946
 
939
947
  // src/config.ts
948
+ import { createDebugger, createHooks } from "hookable";
940
949
  var configs = [".ts", ".js", ".mjs", ".cjs"];
941
950
  function findConfig() {
942
951
  for (const config of configs) {
@@ -947,6 +956,7 @@ function findConfig() {
947
956
  }
948
957
  }
949
958
  async function loadConfigAndCreateContext(options = {}) {
959
+ const hooks = createHooks();
950
960
  const { cwd = process.cwd(), config, configPath } = options;
951
961
  const conf = await loadConfigFile({ cwd, file: configPath });
952
962
  if (config) {
@@ -956,7 +966,14 @@ async function loadConfigAndCreateContext(options = {}) {
956
966
  conf.config.cwd = options.cwd;
957
967
  }
958
968
  conf.config.outdir ??= "styled-system";
959
- return createContext(conf);
969
+ if (conf.config.hooks) {
970
+ hooks.addHooks(conf.config.hooks);
971
+ }
972
+ await hooks.callHook("config:resolved", conf);
973
+ if (conf.config.logLevel === "debug") {
974
+ createDebugger(hooks, { tag: "panda" });
975
+ }
976
+ return createContext({ ...conf, hooks });
960
977
  }
961
978
 
962
979
  // src/extract.ts
@@ -2420,10 +2437,12 @@ var Builder = class {
2420
2437
  const { deps: configDeps } = getConfigDependencies(configPath);
2421
2438
  const deps = this.checkConfigDeps(configPath, configDeps);
2422
2439
  if (deps.isModified) {
2423
- return this.setupContext({
2440
+ await this.setupContext({
2424
2441
  configPath,
2425
2442
  depsModifiedMap: deps.modifiedMap
2426
2443
  });
2444
+ const updatedCtx = this.context;
2445
+ await updatedCtx.hooks.callHook("config:change", updatedCtx.config);
2427
2446
  }
2428
2447
  const cache = configCache.get(configPath);
2429
2448
  if (cache) {
@@ -2641,6 +2660,7 @@ async function generate(config, configPath) {
2641
2660
  configWatcher.on("change", async () => {
2642
2661
  logger7.info("config:change", "Config changed, restarting...");
2643
2662
  await loadCtx();
2663
+ await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
2644
2664
  return build(ctxRef.current);
2645
2665
  });
2646
2666
  const contentWatcher = fs.watch(ctx.config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.0.0-dev-20230614111156",
3
+ "version": "0.0.0-dev-20230614142625",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,17 +32,17 @@
32
32
  "preferred-pm": "^3.0.3",
33
33
  "ts-morph": "18.0.0",
34
34
  "ts-pattern": "4.3.0",
35
- "@pandacss/config": "0.0.0-dev-20230614111156",
36
- "@pandacss/core": "0.0.0-dev-20230614111156",
37
- "@pandacss/error": "0.0.0-dev-20230614111156",
38
- "@pandacss/extractor": "0.0.0-dev-20230614111156",
39
- "@pandacss/generator": "0.0.0-dev-20230614111156",
40
- "@pandacss/is-valid-prop": "0.0.0-dev-20230614111156",
41
- "@pandacss/logger": "0.0.0-dev-20230614111156",
42
- "@pandacss/parser": "0.0.0-dev-20230614111156",
43
- "@pandacss/shared": "0.0.0-dev-20230614111156",
44
- "@pandacss/token-dictionary": "0.0.0-dev-20230614111156",
45
- "@pandacss/types": "0.0.0-dev-20230614111156"
35
+ "@pandacss/config": "0.0.0-dev-20230614142625",
36
+ "@pandacss/core": "0.0.0-dev-20230614142625",
37
+ "@pandacss/error": "0.0.0-dev-20230614142625",
38
+ "@pandacss/extractor": "0.0.0-dev-20230614142625",
39
+ "@pandacss/generator": "0.0.0-dev-20230614142625",
40
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230614142625",
41
+ "@pandacss/logger": "0.0.0-dev-20230614142625",
42
+ "@pandacss/parser": "0.0.0-dev-20230614142625",
43
+ "@pandacss/shared": "0.0.0-dev-20230614142625",
44
+ "@pandacss/token-dictionary": "0.0.0-dev-20230614142625",
45
+ "@pandacss/types": "0.0.0-dev-20230614142625"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/fs-extra": "11.0.1",
@@ -51,7 +51,7 @@
51
51
  "@types/lodash.merge": "4.6.7",
52
52
  "@types/pluralize": "0.0.29",
53
53
  "boxen": "^7.1.0",
54
- "@pandacss/fixture": "0.0.0-dev-20230614111156"
54
+ "@pandacss/fixture": "0.0.0-dev-20230614142625"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",