@pandacss/node 0.19.0 → 0.20.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { Artifact, ConfigResultWithHooks, Runtime, PandaHookable, ParserResultType, Config } from '@pandacss/types';
2
+ import { Artifact, Runtime, PandaHookable, LoadConfigResult, ArtifactId, ConfigResultWithHooks, ParserResultType, Config } from '@pandacss/types';
3
3
  import { Generator } from '@pandacss/generator';
4
4
  import { PandaProject } from '@pandacss/parser';
5
+ import { Difference } from 'microdiff';
5
6
  import { Root, Message } from 'postcss';
6
7
 
7
8
  interface PandaChunksEngine {
@@ -15,19 +16,47 @@ interface PandaChunksEngine {
15
16
  glob: string[];
16
17
  }
17
18
 
18
- interface PandaOutputEngine {
19
+ declare class PandaOutputEngine {
20
+ private paths;
21
+ private fs;
22
+ private path;
23
+ constructor({ paths, runtime: { path, fs } }: Generator & {
24
+ runtime: Runtime;
25
+ hooks: PandaHookable;
26
+ });
19
27
  empty(): void;
20
28
  write(output: Artifact | undefined): Promise<PromiseSettledResult<void>[] | undefined>;
21
29
  }
22
30
 
23
- declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
24
- interface PandaContext extends Generator {
31
+ interface DiffConfigResult {
32
+ hasConfigChanged: boolean;
33
+ artifacts: Set<ArtifactId>;
34
+ diffs: Difference[];
35
+ }
36
+ declare class DiffEngine {
37
+ private ctx;
38
+ private previousConfig;
39
+ constructor(ctx: Generator);
40
+ /**
41
+ * Reload config from disk and refresh the context
42
+ */
43
+ reloadConfigAndRefreshContext(fn?: (conf: LoadConfigResult) => void): Promise<DiffConfigResult>;
44
+ /**
45
+ * Update the context from the refreshed config
46
+ * then persist the changes on each affected engines
47
+ * Returns the list of affected artifacts/engines
48
+ */
49
+ refresh(conf: LoadConfigResult, fn?: (conf: LoadConfigResult) => void): DiffConfigResult;
50
+ }
51
+
52
+ declare class PandaContext extends Generator {
25
53
  runtime: Runtime;
26
- hooks: PandaHookable;
27
54
  project: PandaProject;
28
55
  getFiles: () => string[];
29
56
  chunks: PandaChunksEngine;
30
57
  output: PandaOutputEngine;
58
+ diff: DiffEngine;
59
+ constructor(conf: ConfigResultWithHooks);
31
60
  }
32
61
 
33
62
  interface Options {
@@ -172,33 +201,25 @@ declare function analyzeTokens(ctx: PandaContext, options?: Options): {
172
201
  };
173
202
  declare const writeAnalyzeJSON: (filePath: string, result: ReturnType<typeof analyzeTokens>, ctx: PandaContext) => Promise<void>;
174
203
 
175
- interface ConfigDepsResult {
176
- modifiedMap: Map<string, number>;
177
- isModified: boolean;
178
- }
179
204
  declare class Builder {
180
205
  /**
181
206
  * The current panda context
182
207
  */
183
208
  context: PandaContext | undefined;
184
- hasEmitted: boolean;
185
- configDependencies: Set<string>;
186
- writeFileCss: (file: string, css: string) => void;
187
- checkConfigDeps: (configPath: string, deps: Set<string>) => ConfigDepsResult;
209
+ private hasEmitted;
210
+ private hasConfigChanged;
211
+ private affecteds;
188
212
  getConfigPath: () => string;
189
- hasConfigChanged: boolean;
190
213
  setup: (options?: {
191
214
  configPath?: string;
192
215
  cwd?: string;
193
- }) => Promise<void>;
194
- emit(): void;
216
+ from?: string;
217
+ }) => Promise<PandaContext | undefined>;
218
+ emit(): Promise<void>;
195
219
  setupContext: (options: {
196
220
  configPath: string;
197
- depsModifiedMap: Map<string, number>;
198
- }) => Promise<void>;
221
+ }) => Promise<PandaContext>;
199
222
  getContextOrThrow: () => PandaContext;
200
- get fileModifiedMap(): Map<string, number>;
201
- get fileCssMap(): Map<string, string>;
202
223
  extractFile: (ctx: PandaContext, file: string) => Promise<string | undefined>;
203
224
  extract: () => Promise<void>;
204
225
  toString: () => string;
@@ -226,14 +247,10 @@ declare function execCommand(cmd: string, cwd: string): Promise<void>;
226
247
  * Parse a file and return the corresponding css
227
248
  */
228
249
  declare function extractFile(ctx: PandaContext, file: string): string | undefined;
229
- declare function emitArtifacts(ctx: PandaContext): Promise<{
250
+ declare function emitArtifacts(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
230
251
  box: string;
231
252
  msg: string;
232
253
  }>;
233
- declare function emitArtfifactsAndCssChunks(ctx: PandaContext): Promise<{
234
- files: string[];
235
- msg: string;
236
- }>;
237
254
  /**
238
255
  * Writes all the css chunks in outdir/chunks/{file}.css
239
256
  * and bundles them in outdir/styles.css
@@ -281,4 +298,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
281
298
 
282
299
  declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
283
300
 
284
- export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, createContext, debugFiles, emitArtfifactsAndCssChunks, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };
301
+ export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, debugFiles, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { Artifact, ConfigResultWithHooks, Runtime, PandaHookable, ParserResultType, Config } from '@pandacss/types';
2
+ import { Artifact, Runtime, PandaHookable, LoadConfigResult, ArtifactId, ConfigResultWithHooks, ParserResultType, Config } from '@pandacss/types';
3
3
  import { Generator } from '@pandacss/generator';
4
4
  import { PandaProject } from '@pandacss/parser';
5
+ import { Difference } from 'microdiff';
5
6
  import { Root, Message } from 'postcss';
6
7
 
7
8
  interface PandaChunksEngine {
@@ -15,19 +16,47 @@ interface PandaChunksEngine {
15
16
  glob: string[];
16
17
  }
17
18
 
18
- interface PandaOutputEngine {
19
+ declare class PandaOutputEngine {
20
+ private paths;
21
+ private fs;
22
+ private path;
23
+ constructor({ paths, runtime: { path, fs } }: Generator & {
24
+ runtime: Runtime;
25
+ hooks: PandaHookable;
26
+ });
19
27
  empty(): void;
20
28
  write(output: Artifact | undefined): Promise<PromiseSettledResult<void>[] | undefined>;
21
29
  }
22
30
 
23
- declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
24
- interface PandaContext extends Generator {
31
+ interface DiffConfigResult {
32
+ hasConfigChanged: boolean;
33
+ artifacts: Set<ArtifactId>;
34
+ diffs: Difference[];
35
+ }
36
+ declare class DiffEngine {
37
+ private ctx;
38
+ private previousConfig;
39
+ constructor(ctx: Generator);
40
+ /**
41
+ * Reload config from disk and refresh the context
42
+ */
43
+ reloadConfigAndRefreshContext(fn?: (conf: LoadConfigResult) => void): Promise<DiffConfigResult>;
44
+ /**
45
+ * Update the context from the refreshed config
46
+ * then persist the changes on each affected engines
47
+ * Returns the list of affected artifacts/engines
48
+ */
49
+ refresh(conf: LoadConfigResult, fn?: (conf: LoadConfigResult) => void): DiffConfigResult;
50
+ }
51
+
52
+ declare class PandaContext extends Generator {
25
53
  runtime: Runtime;
26
- hooks: PandaHookable;
27
54
  project: PandaProject;
28
55
  getFiles: () => string[];
29
56
  chunks: PandaChunksEngine;
30
57
  output: PandaOutputEngine;
58
+ diff: DiffEngine;
59
+ constructor(conf: ConfigResultWithHooks);
31
60
  }
32
61
 
33
62
  interface Options {
@@ -172,33 +201,25 @@ declare function analyzeTokens(ctx: PandaContext, options?: Options): {
172
201
  };
173
202
  declare const writeAnalyzeJSON: (filePath: string, result: ReturnType<typeof analyzeTokens>, ctx: PandaContext) => Promise<void>;
174
203
 
175
- interface ConfigDepsResult {
176
- modifiedMap: Map<string, number>;
177
- isModified: boolean;
178
- }
179
204
  declare class Builder {
180
205
  /**
181
206
  * The current panda context
182
207
  */
183
208
  context: PandaContext | undefined;
184
- hasEmitted: boolean;
185
- configDependencies: Set<string>;
186
- writeFileCss: (file: string, css: string) => void;
187
- checkConfigDeps: (configPath: string, deps: Set<string>) => ConfigDepsResult;
209
+ private hasEmitted;
210
+ private hasConfigChanged;
211
+ private affecteds;
188
212
  getConfigPath: () => string;
189
- hasConfigChanged: boolean;
190
213
  setup: (options?: {
191
214
  configPath?: string;
192
215
  cwd?: string;
193
- }) => Promise<void>;
194
- emit(): void;
216
+ from?: string;
217
+ }) => Promise<PandaContext | undefined>;
218
+ emit(): Promise<void>;
195
219
  setupContext: (options: {
196
220
  configPath: string;
197
- depsModifiedMap: Map<string, number>;
198
- }) => Promise<void>;
221
+ }) => Promise<PandaContext>;
199
222
  getContextOrThrow: () => PandaContext;
200
- get fileModifiedMap(): Map<string, number>;
201
- get fileCssMap(): Map<string, string>;
202
223
  extractFile: (ctx: PandaContext, file: string) => Promise<string | undefined>;
203
224
  extract: () => Promise<void>;
204
225
  toString: () => string;
@@ -226,14 +247,10 @@ declare function execCommand(cmd: string, cwd: string): Promise<void>;
226
247
  * Parse a file and return the corresponding css
227
248
  */
228
249
  declare function extractFile(ctx: PandaContext, file: string): string | undefined;
229
- declare function emitArtifacts(ctx: PandaContext): Promise<{
250
+ declare function emitArtifacts(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
230
251
  box: string;
231
252
  msg: string;
232
253
  }>;
233
- declare function emitArtfifactsAndCssChunks(ctx: PandaContext): Promise<{
234
- files: string[];
235
- msg: string;
236
- }>;
237
254
  /**
238
255
  * Writes all the css chunks in outdir/chunks/{file}.css
239
256
  * and bundles them in outdir/styles.css
@@ -281,4 +298,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
281
298
 
282
299
  declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
283
300
 
284
- export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, createContext, debugFiles, emitArtfifactsAndCssChunks, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };
301
+ export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, debugFiles, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };