@pandacss/node 0.0.0-dev-20240129104928 → 0.0.0-dev-20240129191307
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +56 -40
- package/dist/index.mjs +55 -39
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -41,7 +41,9 @@ declare class PandaContext extends Generator {
|
|
|
41
41
|
project: Project;
|
|
42
42
|
output: OutputEngine;
|
|
43
43
|
diff: DiffEngine;
|
|
44
|
+
explicitDeps: string[];
|
|
44
45
|
constructor(conf: LoadConfigResult);
|
|
46
|
+
private getExplicitDependencies;
|
|
45
47
|
getFiles: () => string[];
|
|
46
48
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
|
47
49
|
parseFiles: (styleEncoder?: StyleEncoder) => {
|
|
@@ -50,7 +52,7 @@ declare class PandaContext extends Generator {
|
|
|
50
52
|
results: ParserResult[];
|
|
51
53
|
};
|
|
52
54
|
writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
53
|
-
watchConfig: (cb: () => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
|
|
55
|
+
watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
|
|
54
56
|
watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>) => void;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -205,6 +207,7 @@ declare class Builder {
|
|
|
205
207
|
context: PandaContext | undefined;
|
|
206
208
|
private hasEmitted;
|
|
207
209
|
private filesMeta;
|
|
210
|
+
private explicitDepsMeta;
|
|
208
211
|
private affecteds;
|
|
209
212
|
private configDependencies;
|
|
210
213
|
setConfigDependencies(options: SetupContextOptions): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -41,7 +41,9 @@ declare class PandaContext extends Generator {
|
|
|
41
41
|
project: Project;
|
|
42
42
|
output: OutputEngine;
|
|
43
43
|
diff: DiffEngine;
|
|
44
|
+
explicitDeps: string[];
|
|
44
45
|
constructor(conf: LoadConfigResult);
|
|
46
|
+
private getExplicitDependencies;
|
|
45
47
|
getFiles: () => string[];
|
|
46
48
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
|
47
49
|
parseFiles: (styleEncoder?: StyleEncoder) => {
|
|
@@ -50,7 +52,7 @@ declare class PandaContext extends Generator {
|
|
|
50
52
|
results: ParserResult[];
|
|
51
53
|
};
|
|
52
54
|
writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
53
|
-
watchConfig: (cb: () => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
|
|
55
|
+
watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, 'include'>) => void;
|
|
54
56
|
watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>) => void;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -205,6 +207,7 @@ declare class Builder {
|
|
|
205
207
|
context: PandaContext | undefined;
|
|
206
208
|
private hasEmitted;
|
|
207
209
|
private filesMeta;
|
|
210
|
+
private explicitDepsMeta;
|
|
208
211
|
private affecteds;
|
|
209
212
|
private configDependencies;
|
|
210
213
|
setConfigDependencies(options: SetupContextOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -790,7 +790,7 @@ init_cjs_shims();
|
|
|
790
790
|
var import_config4 = require("@pandacss/config");
|
|
791
791
|
var import_core = require("@pandacss/core");
|
|
792
792
|
var import_logger6 = require("@pandacss/logger");
|
|
793
|
-
var
|
|
793
|
+
var import_shared2 = require("@pandacss/shared");
|
|
794
794
|
var import_fs = require("fs");
|
|
795
795
|
var import_path3 = require("path");
|
|
796
796
|
|
|
@@ -2245,6 +2245,7 @@ init_cjs_shims();
|
|
|
2245
2245
|
var import_generator2 = require("@pandacss/generator");
|
|
2246
2246
|
var import_logger5 = require("@pandacss/logger");
|
|
2247
2247
|
var import_parser = require("@pandacss/parser");
|
|
2248
|
+
var import_shared = require("@pandacss/shared");
|
|
2248
2249
|
var import_perfect_debounce = require("perfect-debounce");
|
|
2249
2250
|
|
|
2250
2251
|
// src/diff-engine.ts
|
|
@@ -2402,6 +2403,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2402
2403
|
project;
|
|
2403
2404
|
output;
|
|
2404
2405
|
diff;
|
|
2406
|
+
explicitDeps = [];
|
|
2405
2407
|
constructor(conf) {
|
|
2406
2408
|
super(conf);
|
|
2407
2409
|
const config = conf.config;
|
|
@@ -2422,7 +2424,14 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2422
2424
|
});
|
|
2423
2425
|
this.output = new OutputEngine(this);
|
|
2424
2426
|
this.diff = new DiffEngine(this);
|
|
2427
|
+
this.explicitDeps = this.getExplicitDependencies();
|
|
2425
2428
|
}
|
|
2429
|
+
getExplicitDependencies = () => {
|
|
2430
|
+
const { cwd, dependencies } = this.config;
|
|
2431
|
+
if (!dependencies)
|
|
2432
|
+
return [];
|
|
2433
|
+
return this.runtime.fs.glob({ include: dependencies, cwd });
|
|
2434
|
+
};
|
|
2426
2435
|
getFiles = () => {
|
|
2427
2436
|
const { include, exclude, cwd } = this.config;
|
|
2428
2437
|
return this.runtime.fs.glob({ include, exclude, cwd });
|
|
@@ -2473,16 +2482,16 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2473
2482
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2474
2483
|
import_logger5.logger.info("ctx:watch", this.messages.configWatch());
|
|
2475
2484
|
const watcher = this.runtime.fs.watch({
|
|
2476
|
-
include: this.conf.dependencies,
|
|
2485
|
+
include: (0, import_shared.uniq)([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2477
2486
|
exclude,
|
|
2478
2487
|
cwd,
|
|
2479
2488
|
poll
|
|
2480
2489
|
});
|
|
2481
2490
|
watcher.on(
|
|
2482
2491
|
"change",
|
|
2483
|
-
(0, import_perfect_debounce.debounce)(async () => {
|
|
2492
|
+
(0, import_perfect_debounce.debounce)(async (file) => {
|
|
2484
2493
|
import_logger5.logger.info("ctx:change", "config changed, rebuilding...");
|
|
2485
|
-
await cb();
|
|
2494
|
+
await cb(file);
|
|
2486
2495
|
})
|
|
2487
2496
|
);
|
|
2488
2497
|
};
|
|
@@ -2607,6 +2616,7 @@ var Builder = class {
|
|
|
2607
2616
|
context;
|
|
2608
2617
|
hasEmitted = false;
|
|
2609
2618
|
filesMeta;
|
|
2619
|
+
explicitDepsMeta;
|
|
2610
2620
|
affecteds;
|
|
2611
2621
|
configDependencies = /* @__PURE__ */ new Set();
|
|
2612
2622
|
setConfigDependencies(options) {
|
|
@@ -2618,7 +2628,9 @@ var Builder = class {
|
|
|
2618
2628
|
...foundDeps,
|
|
2619
2629
|
...(this.context?.conf.dependencies ?? []).map((file) => (0, import_path3.resolve)(cwd, file))
|
|
2620
2630
|
]);
|
|
2621
|
-
|
|
2631
|
+
configDeps.forEach((file) => {
|
|
2632
|
+
this.configDependencies.add(file);
|
|
2633
|
+
});
|
|
2622
2634
|
import_logger6.logger.debug("builder", "Config dependencies");
|
|
2623
2635
|
import_logger6.logger.debug("builder", configDeps);
|
|
2624
2636
|
}
|
|
@@ -2634,6 +2646,14 @@ var Builder = class {
|
|
|
2634
2646
|
this.context = new PandaContext(conf);
|
|
2635
2647
|
});
|
|
2636
2648
|
import_logger6.logger.debug("builder", this.affecteds);
|
|
2649
|
+
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2650
|
+
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2651
|
+
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2652
|
+
fileModifiedMap.set(file, meta.mtime);
|
|
2653
|
+
});
|
|
2654
|
+
import_logger6.logger.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2655
|
+
this.affecteds.hasConfigChanged = true;
|
|
2656
|
+
}
|
|
2637
2657
|
if (this.affecteds.hasConfigChanged) {
|
|
2638
2658
|
import_logger6.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2639
2659
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
@@ -2655,12 +2675,16 @@ var Builder = class {
|
|
|
2655
2675
|
setupContext = async (options) => {
|
|
2656
2676
|
const { configPath, cwd } = options;
|
|
2657
2677
|
const ctx = await loadConfigAndCreateContext({ configPath, cwd });
|
|
2678
|
+
const configDeps = (0, import_shared2.uniq)([...ctx.conf.dependencies, ...ctx.explicitDeps]);
|
|
2679
|
+
configDeps.forEach((file) => {
|
|
2680
|
+
this.configDependencies.add((0, import_path3.resolve)(cwd || ctx.conf.config.cwd, file));
|
|
2681
|
+
});
|
|
2658
2682
|
this.context = ctx;
|
|
2659
2683
|
return ctx;
|
|
2660
2684
|
};
|
|
2661
2685
|
getContextOrThrow = () => {
|
|
2662
2686
|
if (!this.context) {
|
|
2663
|
-
throw new
|
|
2687
|
+
throw new import_shared2.PandaError("NO_CONTEXT", "context not loaded");
|
|
2664
2688
|
}
|
|
2665
2689
|
return this.context;
|
|
2666
2690
|
};
|
|
@@ -2779,7 +2803,8 @@ var cssgen = async (ctx, options) => {
|
|
|
2779
2803
|
ctx.appendCssOfType(type, sheet);
|
|
2780
2804
|
if (outfile) {
|
|
2781
2805
|
const css = ctx.getCss(sheet);
|
|
2782
|
-
ctx.runtime.
|
|
2806
|
+
import_logger8.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2807
|
+
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2783
2808
|
} else {
|
|
2784
2809
|
await ctx.writeCss(sheet);
|
|
2785
2810
|
}
|
|
@@ -2794,7 +2819,8 @@ var cssgen = async (ctx, options) => {
|
|
|
2794
2819
|
ctx.appendParserCss(sheet);
|
|
2795
2820
|
if (outfile) {
|
|
2796
2821
|
const css = ctx.getCss(sheet);
|
|
2797
|
-
ctx.runtime.
|
|
2822
|
+
import_logger8.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2823
|
+
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2798
2824
|
} else {
|
|
2799
2825
|
await ctx.writeCss(sheet);
|
|
2800
2826
|
}
|
|
@@ -2859,7 +2885,6 @@ async function debug(ctx, options) {
|
|
|
2859
2885
|
// src/generate.ts
|
|
2860
2886
|
init_cjs_shims();
|
|
2861
2887
|
var import_logger10 = require("@pandacss/logger");
|
|
2862
|
-
var import_ts_pattern = require("ts-pattern");
|
|
2863
2888
|
async function build(ctx, artifactIds) {
|
|
2864
2889
|
await codegen(ctx, artifactIds);
|
|
2865
2890
|
if (ctx.config.emitTokensOnly) {
|
|
@@ -2877,25 +2902,19 @@ async function build(ctx, artifactIds) {
|
|
|
2877
2902
|
async function generate(config, configPath) {
|
|
2878
2903
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2879
2904
|
await build(ctx);
|
|
2880
|
-
const {
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
ctx
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
}
|
|
2894
|
-
import_logger10.logger.info("config:change", "Config changed, restarting...");
|
|
2895
|
-
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
2896
|
-
return build(ctx, Array.from(affecteds.artifacts));
|
|
2897
|
-
});
|
|
2898
|
-
const contentWatcher = fs2.watch(ctx.config);
|
|
2905
|
+
const { cwd, watch, poll } = ctx.config;
|
|
2906
|
+
if (watch) {
|
|
2907
|
+
ctx.watchConfig(
|
|
2908
|
+
async () => {
|
|
2909
|
+
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2910
|
+
ctx = new PandaContext(conf);
|
|
2911
|
+
});
|
|
2912
|
+
import_logger10.logger.info("ctx:updated", "config rebuilt \u2705");
|
|
2913
|
+
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
2914
|
+
return build(ctx, Array.from(affecteds.artifacts));
|
|
2915
|
+
},
|
|
2916
|
+
{ cwd, poll }
|
|
2917
|
+
);
|
|
2899
2918
|
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2900
2919
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2901
2920
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
@@ -2909,21 +2928,18 @@ async function generate(config, configPath) {
|
|
|
2909
2928
|
return { msg: ctx2.messages.buildComplete(1) };
|
|
2910
2929
|
}
|
|
2911
2930
|
};
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
}).with("change", async () => {
|
|
2931
|
+
ctx.watchFiles(async (event, file) => {
|
|
2932
|
+
const filePath = ctx.runtime.path.abs(cwd, file);
|
|
2933
|
+
if (event === "unlink") {
|
|
2934
|
+
ctx.project.removeSourceFile(filePath);
|
|
2935
|
+
} else if (event === "change") {
|
|
2918
2936
|
ctx.project.reloadSourceFile(file);
|
|
2919
|
-
|
|
2920
|
-
}
|
|
2937
|
+
await bundleStyles(ctx, filePath);
|
|
2938
|
+
} else if (event === "add") {
|
|
2921
2939
|
ctx.project.createSourceFile(file);
|
|
2922
|
-
|
|
2923
|
-
}
|
|
2924
|
-
});
|
|
2940
|
+
await bundleStyles(ctx, filePath);
|
|
2941
|
+
}
|
|
2925
2942
|
});
|
|
2926
|
-
import_logger10.logger.info("ctx:watch", ctx.messages.watch());
|
|
2927
2943
|
}
|
|
2928
2944
|
}
|
|
2929
2945
|
|
package/dist/index.mjs
CHANGED
|
@@ -765,7 +765,7 @@ init_esm_shims();
|
|
|
765
765
|
import { findConfig, getConfigDependencies } from "@pandacss/config";
|
|
766
766
|
import { optimizeCss } from "@pandacss/core";
|
|
767
767
|
import { logger as logger6 } from "@pandacss/logger";
|
|
768
|
-
import { PandaError } from "@pandacss/shared";
|
|
768
|
+
import { PandaError, uniq as uniq2 } from "@pandacss/shared";
|
|
769
769
|
import { existsSync, statSync } from "fs";
|
|
770
770
|
import { normalize as normalize2, resolve as resolve3 } from "path";
|
|
771
771
|
|
|
@@ -2220,6 +2220,7 @@ init_esm_shims();
|
|
|
2220
2220
|
import { Generator as Generator2 } from "@pandacss/generator";
|
|
2221
2221
|
import { logger as logger5 } from "@pandacss/logger";
|
|
2222
2222
|
import { Project } from "@pandacss/parser";
|
|
2223
|
+
import { uniq } from "@pandacss/shared";
|
|
2223
2224
|
import { debounce } from "perfect-debounce";
|
|
2224
2225
|
|
|
2225
2226
|
// src/diff-engine.ts
|
|
@@ -2377,6 +2378,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2377
2378
|
project;
|
|
2378
2379
|
output;
|
|
2379
2380
|
diff;
|
|
2381
|
+
explicitDeps = [];
|
|
2380
2382
|
constructor(conf) {
|
|
2381
2383
|
super(conf);
|
|
2382
2384
|
const config = conf.config;
|
|
@@ -2397,7 +2399,14 @@ var PandaContext = class extends Generator2 {
|
|
|
2397
2399
|
});
|
|
2398
2400
|
this.output = new OutputEngine(this);
|
|
2399
2401
|
this.diff = new DiffEngine(this);
|
|
2402
|
+
this.explicitDeps = this.getExplicitDependencies();
|
|
2400
2403
|
}
|
|
2404
|
+
getExplicitDependencies = () => {
|
|
2405
|
+
const { cwd, dependencies } = this.config;
|
|
2406
|
+
if (!dependencies)
|
|
2407
|
+
return [];
|
|
2408
|
+
return this.runtime.fs.glob({ include: dependencies, cwd });
|
|
2409
|
+
};
|
|
2401
2410
|
getFiles = () => {
|
|
2402
2411
|
const { include, exclude, cwd } = this.config;
|
|
2403
2412
|
return this.runtime.fs.glob({ include, exclude, cwd });
|
|
@@ -2448,16 +2457,16 @@ var PandaContext = class extends Generator2 {
|
|
|
2448
2457
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2449
2458
|
logger5.info("ctx:watch", this.messages.configWatch());
|
|
2450
2459
|
const watcher = this.runtime.fs.watch({
|
|
2451
|
-
include: this.conf.dependencies,
|
|
2460
|
+
include: uniq([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2452
2461
|
exclude,
|
|
2453
2462
|
cwd,
|
|
2454
2463
|
poll
|
|
2455
2464
|
});
|
|
2456
2465
|
watcher.on(
|
|
2457
2466
|
"change",
|
|
2458
|
-
debounce(async () => {
|
|
2467
|
+
debounce(async (file) => {
|
|
2459
2468
|
logger5.info("ctx:change", "config changed, rebuilding...");
|
|
2460
|
-
await cb();
|
|
2469
|
+
await cb(file);
|
|
2461
2470
|
})
|
|
2462
2471
|
);
|
|
2463
2472
|
};
|
|
@@ -2582,6 +2591,7 @@ var Builder = class {
|
|
|
2582
2591
|
context;
|
|
2583
2592
|
hasEmitted = false;
|
|
2584
2593
|
filesMeta;
|
|
2594
|
+
explicitDepsMeta;
|
|
2585
2595
|
affecteds;
|
|
2586
2596
|
configDependencies = /* @__PURE__ */ new Set();
|
|
2587
2597
|
setConfigDependencies(options) {
|
|
@@ -2593,7 +2603,9 @@ var Builder = class {
|
|
|
2593
2603
|
...foundDeps,
|
|
2594
2604
|
...(this.context?.conf.dependencies ?? []).map((file) => resolve3(cwd, file))
|
|
2595
2605
|
]);
|
|
2596
|
-
|
|
2606
|
+
configDeps.forEach((file) => {
|
|
2607
|
+
this.configDependencies.add(file);
|
|
2608
|
+
});
|
|
2597
2609
|
logger6.debug("builder", "Config dependencies");
|
|
2598
2610
|
logger6.debug("builder", configDeps);
|
|
2599
2611
|
}
|
|
@@ -2609,6 +2621,14 @@ var Builder = class {
|
|
|
2609
2621
|
this.context = new PandaContext(conf);
|
|
2610
2622
|
});
|
|
2611
2623
|
logger6.debug("builder", this.affecteds);
|
|
2624
|
+
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2625
|
+
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2626
|
+
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2627
|
+
fileModifiedMap.set(file, meta.mtime);
|
|
2628
|
+
});
|
|
2629
|
+
logger6.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2630
|
+
this.affecteds.hasConfigChanged = true;
|
|
2631
|
+
}
|
|
2612
2632
|
if (this.affecteds.hasConfigChanged) {
|
|
2613
2633
|
logger6.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2614
2634
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
@@ -2630,6 +2650,10 @@ var Builder = class {
|
|
|
2630
2650
|
setupContext = async (options) => {
|
|
2631
2651
|
const { configPath, cwd } = options;
|
|
2632
2652
|
const ctx = await loadConfigAndCreateContext({ configPath, cwd });
|
|
2653
|
+
const configDeps = uniq2([...ctx.conf.dependencies, ...ctx.explicitDeps]);
|
|
2654
|
+
configDeps.forEach((file) => {
|
|
2655
|
+
this.configDependencies.add(resolve3(cwd || ctx.conf.config.cwd, file));
|
|
2656
|
+
});
|
|
2633
2657
|
this.context = ctx;
|
|
2634
2658
|
return ctx;
|
|
2635
2659
|
};
|
|
@@ -2754,7 +2778,8 @@ var cssgen = async (ctx, options) => {
|
|
|
2754
2778
|
ctx.appendCssOfType(type, sheet);
|
|
2755
2779
|
if (outfile) {
|
|
2756
2780
|
const css = ctx.getCss(sheet);
|
|
2757
|
-
ctx.runtime.
|
|
2781
|
+
logger8.info("css", ctx.runtime.path.resolve(outfile));
|
|
2782
|
+
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2758
2783
|
} else {
|
|
2759
2784
|
await ctx.writeCss(sheet);
|
|
2760
2785
|
}
|
|
@@ -2769,7 +2794,8 @@ var cssgen = async (ctx, options) => {
|
|
|
2769
2794
|
ctx.appendParserCss(sheet);
|
|
2770
2795
|
if (outfile) {
|
|
2771
2796
|
const css = ctx.getCss(sheet);
|
|
2772
|
-
ctx.runtime.
|
|
2797
|
+
logger8.info("css", ctx.runtime.path.resolve(outfile));
|
|
2798
|
+
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2773
2799
|
} else {
|
|
2774
2800
|
await ctx.writeCss(sheet);
|
|
2775
2801
|
}
|
|
@@ -2834,7 +2860,6 @@ async function debug(ctx, options) {
|
|
|
2834
2860
|
// src/generate.ts
|
|
2835
2861
|
init_esm_shims();
|
|
2836
2862
|
import { logger as logger10 } from "@pandacss/logger";
|
|
2837
|
-
import { match } from "ts-pattern";
|
|
2838
2863
|
async function build(ctx, artifactIds) {
|
|
2839
2864
|
await codegen(ctx, artifactIds);
|
|
2840
2865
|
if (ctx.config.emitTokensOnly) {
|
|
@@ -2852,25 +2877,19 @@ async function build(ctx, artifactIds) {
|
|
|
2852
2877
|
async function generate(config, configPath) {
|
|
2853
2878
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2854
2879
|
await build(ctx);
|
|
2855
|
-
const {
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
ctx
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
}
|
|
2869
|
-
logger10.info("config:change", "Config changed, restarting...");
|
|
2870
|
-
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
2871
|
-
return build(ctx, Array.from(affecteds.artifacts));
|
|
2872
|
-
});
|
|
2873
|
-
const contentWatcher = fs2.watch(ctx.config);
|
|
2880
|
+
const { cwd, watch, poll } = ctx.config;
|
|
2881
|
+
if (watch) {
|
|
2882
|
+
ctx.watchConfig(
|
|
2883
|
+
async () => {
|
|
2884
|
+
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2885
|
+
ctx = new PandaContext(conf);
|
|
2886
|
+
});
|
|
2887
|
+
logger10.info("ctx:updated", "config rebuilt \u2705");
|
|
2888
|
+
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
2889
|
+
return build(ctx, Array.from(affecteds.artifacts));
|
|
2890
|
+
},
|
|
2891
|
+
{ cwd, poll }
|
|
2892
|
+
);
|
|
2874
2893
|
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2875
2894
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2876
2895
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
@@ -2884,21 +2903,18 @@ async function generate(config, configPath) {
|
|
|
2884
2903
|
return { msg: ctx2.messages.buildComplete(1) };
|
|
2885
2904
|
}
|
|
2886
2905
|
};
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
}).with("change", async () => {
|
|
2906
|
+
ctx.watchFiles(async (event, file) => {
|
|
2907
|
+
const filePath = ctx.runtime.path.abs(cwd, file);
|
|
2908
|
+
if (event === "unlink") {
|
|
2909
|
+
ctx.project.removeSourceFile(filePath);
|
|
2910
|
+
} else if (event === "change") {
|
|
2893
2911
|
ctx.project.reloadSourceFile(file);
|
|
2894
|
-
|
|
2895
|
-
}
|
|
2912
|
+
await bundleStyles(ctx, filePath);
|
|
2913
|
+
} else if (event === "add") {
|
|
2896
2914
|
ctx.project.createSourceFile(file);
|
|
2897
|
-
|
|
2898
|
-
}
|
|
2899
|
-
});
|
|
2915
|
+
await bundleStyles(ctx, filePath);
|
|
2916
|
+
}
|
|
2900
2917
|
});
|
|
2901
|
-
logger10.info("ctx:watch", ctx.messages.watch());
|
|
2902
2918
|
}
|
|
2903
2919
|
}
|
|
2904
2920
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20240129191307",
|
|
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-
|
|
57
|
-
"@pandacss/core": "0.0.0-dev-
|
|
58
|
-
"@pandacss/extractor": "0.0.0-dev-
|
|
59
|
-
"@pandacss/generator": "0.0.0-dev-
|
|
60
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
61
|
-
"@pandacss/parser": "0.0.0-dev-
|
|
62
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
63
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
64
|
-
"@pandacss/types": "0.0.0-dev-
|
|
56
|
+
"@pandacss/config": "0.0.0-dev-20240129191307",
|
|
57
|
+
"@pandacss/core": "0.0.0-dev-20240129191307",
|
|
58
|
+
"@pandacss/extractor": "0.0.0-dev-20240129191307",
|
|
59
|
+
"@pandacss/generator": "0.0.0-dev-20240129191307",
|
|
60
|
+
"@pandacss/logger": "0.0.0-dev-20240129191307",
|
|
61
|
+
"@pandacss/parser": "0.0.0-dev-20240129191307",
|
|
62
|
+
"@pandacss/shared": "0.0.0-dev-20240129191307",
|
|
63
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20240129191307",
|
|
64
|
+
"@pandacss/types": "0.0.0-dev-20240129191307"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/fs-extra": "11.0.4",
|