@pandacss/node 0.15.5 → 0.17.0
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 +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +112 -67
- package/dist/index.mjs +106 -62
- package/package.json +14 -14
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { discardDuplicate } from '@pandacss/core';
|
|
2
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
3
2
|
import { PandaHookable, Artifact, ConfigResultWithHooks, Runtime as Runtime$1, ParserResultType, Config } from '@pandacss/types';
|
|
4
3
|
import { Generator } from '@pandacss/generator';
|
|
@@ -226,23 +225,50 @@ declare function debugFiles(ctx: PandaContext, options: {
|
|
|
226
225
|
|
|
227
226
|
declare function execCommand(cmd: string, cwd: string): Promise<void>;
|
|
228
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Parse a file and return the corresponding css
|
|
230
|
+
*/
|
|
229
231
|
declare function extractFile(ctx: PandaContext, file: string): string | undefined;
|
|
230
232
|
declare function emitArtifacts(ctx: PandaContext): Promise<{
|
|
231
233
|
box: string;
|
|
232
234
|
msg: string;
|
|
233
235
|
}>;
|
|
234
|
-
declare function
|
|
236
|
+
declare function emitArtfifactsAndCssChunks(ctx: PandaContext): Promise<{
|
|
235
237
|
files: string[];
|
|
236
238
|
msg: string;
|
|
237
239
|
}>;
|
|
238
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Writes all the css chunks in outdir/chunks/{file}.css
|
|
242
|
+
* and bundles them in outdir/styles.css
|
|
243
|
+
*/
|
|
244
|
+
declare function writeAndBundleCssChunks(ctx: PandaContext): Promise<{
|
|
239
245
|
files: string[];
|
|
240
246
|
msg: string;
|
|
241
247
|
}>;
|
|
248
|
+
/**
|
|
249
|
+
* Bundles all the included files CSS into the given outfile
|
|
250
|
+
* Including the root CSS artifact files content (global, static, reset, tokens, keyframes)
|
|
251
|
+
* Without any imports
|
|
252
|
+
*/
|
|
242
253
|
declare function bundleCss(ctx: PandaContext, outfile: string): Promise<{
|
|
243
254
|
files: string[];
|
|
244
255
|
msg: string;
|
|
245
256
|
}>;
|
|
257
|
+
/**
|
|
258
|
+
* Bundles all the files CSS into outdir/chunks/{file}.css
|
|
259
|
+
* Without writing any chunks or needing any imports
|
|
260
|
+
*/
|
|
261
|
+
declare function bundleMinimalFilesCss(ctx: PandaContext, outfile: string): Promise<{
|
|
262
|
+
files: string[];
|
|
263
|
+
msg: string;
|
|
264
|
+
}>;
|
|
265
|
+
type CssArtifactType = 'preflight' | 'tokens' | 'static' | 'global' | 'keyframes';
|
|
266
|
+
/**
|
|
267
|
+
* Generates the CSS for a given artifact type
|
|
268
|
+
*/
|
|
269
|
+
declare function generateCssArtifactOfType(ctx: PandaContext, cssType: CssArtifactType, outfile: string): Promise<{
|
|
270
|
+
msg: string;
|
|
271
|
+
}>;
|
|
246
272
|
|
|
247
273
|
declare function generate(config: Config, configPath?: string): Promise<void>;
|
|
248
274
|
|
|
@@ -258,4 +284,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
|
|
|
258
284
|
|
|
259
285
|
declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
|
|
260
286
|
|
|
261
|
-
export { Builder, PandaContext, analyzeTokens, bundleCss, createContext, debugFiles,
|
|
287
|
+
export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, createContext, debugFiles, emitArtfifactsAndCssChunks, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { discardDuplicate } from '@pandacss/core';
|
|
2
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
3
2
|
import { PandaHookable, Artifact, ConfigResultWithHooks, Runtime as Runtime$1, ParserResultType, Config } from '@pandacss/types';
|
|
4
3
|
import { Generator } from '@pandacss/generator';
|
|
@@ -226,23 +225,50 @@ declare function debugFiles(ctx: PandaContext, options: {
|
|
|
226
225
|
|
|
227
226
|
declare function execCommand(cmd: string, cwd: string): Promise<void>;
|
|
228
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Parse a file and return the corresponding css
|
|
230
|
+
*/
|
|
229
231
|
declare function extractFile(ctx: PandaContext, file: string): string | undefined;
|
|
230
232
|
declare function emitArtifacts(ctx: PandaContext): Promise<{
|
|
231
233
|
box: string;
|
|
232
234
|
msg: string;
|
|
233
235
|
}>;
|
|
234
|
-
declare function
|
|
236
|
+
declare function emitArtfifactsAndCssChunks(ctx: PandaContext): Promise<{
|
|
235
237
|
files: string[];
|
|
236
238
|
msg: string;
|
|
237
239
|
}>;
|
|
238
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Writes all the css chunks in outdir/chunks/{file}.css
|
|
242
|
+
* and bundles them in outdir/styles.css
|
|
243
|
+
*/
|
|
244
|
+
declare function writeAndBundleCssChunks(ctx: PandaContext): Promise<{
|
|
239
245
|
files: string[];
|
|
240
246
|
msg: string;
|
|
241
247
|
}>;
|
|
248
|
+
/**
|
|
249
|
+
* Bundles all the included files CSS into the given outfile
|
|
250
|
+
* Including the root CSS artifact files content (global, static, reset, tokens, keyframes)
|
|
251
|
+
* Without any imports
|
|
252
|
+
*/
|
|
242
253
|
declare function bundleCss(ctx: PandaContext, outfile: string): Promise<{
|
|
243
254
|
files: string[];
|
|
244
255
|
msg: string;
|
|
245
256
|
}>;
|
|
257
|
+
/**
|
|
258
|
+
* Bundles all the files CSS into outdir/chunks/{file}.css
|
|
259
|
+
* Without writing any chunks or needing any imports
|
|
260
|
+
*/
|
|
261
|
+
declare function bundleMinimalFilesCss(ctx: PandaContext, outfile: string): Promise<{
|
|
262
|
+
files: string[];
|
|
263
|
+
msg: string;
|
|
264
|
+
}>;
|
|
265
|
+
type CssArtifactType = 'preflight' | 'tokens' | 'static' | 'global' | 'keyframes';
|
|
266
|
+
/**
|
|
267
|
+
* Generates the CSS for a given artifact type
|
|
268
|
+
*/
|
|
269
|
+
declare function generateCssArtifactOfType(ctx: PandaContext, cssType: CssArtifactType, outfile: string): Promise<{
|
|
270
|
+
msg: string;
|
|
271
|
+
}>;
|
|
246
272
|
|
|
247
273
|
declare function generate(config: Config, configPath?: string): Promise<void>;
|
|
248
274
|
|
|
@@ -258,4 +284,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
|
|
|
258
284
|
|
|
259
285
|
declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
|
|
260
286
|
|
|
261
|
-
export { Builder, PandaContext, analyzeTokens, bundleCss, createContext, debugFiles,
|
|
287
|
+
export { Builder, CssArtifactType, PandaContext, analyzeTokens, bundleCss, bundleMinimalFilesCss, createContext, debugFiles, emitArtfifactsAndCssChunks, emitArtifacts, execCommand, extractFile, findConfig, generate, generateCssArtifactOfType, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON, writeAndBundleCssChunks };
|
package/dist/index.js
CHANGED
|
@@ -33,9 +33,9 @@ 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@7.1.0_postcss@8.4.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -406,27 +406,27 @@ __export(src_exports, {
|
|
|
406
406
|
Builder: () => Builder,
|
|
407
407
|
analyzeTokens: () => analyzeTokens,
|
|
408
408
|
bundleCss: () => bundleCss,
|
|
409
|
+
bundleMinimalFilesCss: () => bundleMinimalFilesCss,
|
|
409
410
|
createContext: () => createContext,
|
|
410
411
|
debugFiles: () => debugFiles,
|
|
411
|
-
|
|
412
|
-
emitAndExtract: () => emitAndExtract,
|
|
412
|
+
emitArtfifactsAndCssChunks: () => emitArtfifactsAndCssChunks,
|
|
413
413
|
emitArtifacts: () => emitArtifacts,
|
|
414
414
|
execCommand: () => execCommand,
|
|
415
|
-
extractCss: () => extractCss,
|
|
416
415
|
extractFile: () => extractFile,
|
|
417
416
|
findConfig: () => findConfig,
|
|
418
417
|
generate: () => generate,
|
|
418
|
+
generateCssArtifactOfType: () => generateCssArtifactOfType,
|
|
419
419
|
loadConfigAndCreateContext: () => loadConfigAndCreateContext,
|
|
420
420
|
parseDependency: () => parseDependency,
|
|
421
421
|
setupConfig: () => setupConfig,
|
|
422
422
|
setupGitIgnore: () => setupGitIgnore,
|
|
423
423
|
setupPostcss: () => setupPostcss,
|
|
424
424
|
shipFiles: () => shipFiles,
|
|
425
|
-
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
425
|
+
writeAnalyzeJSON: () => writeAnalyzeJSON,
|
|
426
|
+
writeAndBundleCssChunks: () => writeAndBundleCssChunks
|
|
426
427
|
});
|
|
427
428
|
module.exports = __toCommonJS(src_exports);
|
|
428
429
|
init_cjs_shims();
|
|
429
|
-
var import_core3 = require("@pandacss/core");
|
|
430
430
|
|
|
431
431
|
// src/analyze-tokens.ts
|
|
432
432
|
init_cjs_shims();
|
|
@@ -780,9 +780,9 @@ var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
|
780
780
|
// src/builder.ts
|
|
781
781
|
init_cjs_shims();
|
|
782
782
|
var import_config2 = require("@pandacss/config");
|
|
783
|
-
var
|
|
783
|
+
var import_core3 = require("@pandacss/core");
|
|
784
784
|
var import_error = require("@pandacss/error");
|
|
785
|
-
var
|
|
785
|
+
var import_logger5 = require("@pandacss/logger");
|
|
786
786
|
var import_fs = require("fs");
|
|
787
787
|
var import_fs_extra2 = require("fs-extra");
|
|
788
788
|
var import_path2 = require("path");
|
|
@@ -927,22 +927,29 @@ var getOutputEngine = ({
|
|
|
927
927
|
const { dir = paths.root, files } = output;
|
|
928
928
|
fs.ensureDirSync(path2.join(...dir));
|
|
929
929
|
return Promise.allSettled(
|
|
930
|
-
files.map(async (
|
|
930
|
+
files.map(async (artifact) => {
|
|
931
|
+
if (!artifact)
|
|
932
|
+
return;
|
|
933
|
+
const { file, code } = artifact;
|
|
931
934
|
const absPath = path2.join(...dir, file);
|
|
932
|
-
if (code)
|
|
933
|
-
return
|
|
934
|
-
|
|
935
|
+
if (!code)
|
|
936
|
+
return;
|
|
937
|
+
return fs.writeFile(absPath, code);
|
|
935
938
|
})
|
|
936
939
|
);
|
|
937
940
|
}
|
|
938
941
|
});
|
|
939
942
|
|
|
940
943
|
// src/create-context.ts
|
|
944
|
+
var import_logger3 = require("@pandacss/logger");
|
|
941
945
|
var createContext = (conf) => {
|
|
942
946
|
const generator = (0, import_generator.createGenerator)(conf);
|
|
943
947
|
const config = conf.config;
|
|
944
948
|
const runtime = nodeRuntime;
|
|
945
949
|
config.cwd ||= runtime.cwd();
|
|
950
|
+
if (config.logLevel) {
|
|
951
|
+
import_logger3.logger.level = config.logLevel;
|
|
952
|
+
}
|
|
946
953
|
const { include, exclude, cwd } = config;
|
|
947
954
|
const getFiles = () => runtime.fs.glob({ include, exclude, cwd });
|
|
948
955
|
const ctx = {
|
|
@@ -1005,7 +1012,7 @@ async function loadConfigAndCreateContext(options = {}) {
|
|
|
1005
1012
|
|
|
1006
1013
|
// src/extract.ts
|
|
1007
1014
|
init_cjs_shims();
|
|
1008
|
-
var
|
|
1015
|
+
var import_logger4 = require("@pandacss/logger");
|
|
1009
1016
|
var import_lil_fp = require("lil-fp");
|
|
1010
1017
|
|
|
1011
1018
|
// src/cli-box.ts
|
|
@@ -2322,7 +2329,10 @@ var createBox = (options) => boxen(options.content, {
|
|
|
2322
2329
|
|
|
2323
2330
|
// src/extract.ts
|
|
2324
2331
|
var import_promises2 = require("fs/promises");
|
|
2325
|
-
|
|
2332
|
+
var import_parser2 = require("@pandacss/parser");
|
|
2333
|
+
var import_ts_pattern = require("ts-pattern");
|
|
2334
|
+
var import_core2 = require("@pandacss/core");
|
|
2335
|
+
async function bundleStyleChunksWithImports(ctx) {
|
|
2326
2336
|
const files = ctx.chunks.getFiles();
|
|
2327
2337
|
await ctx.output.write({
|
|
2328
2338
|
dir: ctx.paths.root,
|
|
@@ -2332,7 +2342,7 @@ async function bundleChunks(ctx) {
|
|
|
2332
2342
|
}
|
|
2333
2343
|
async function writeFileChunk(ctx, file) {
|
|
2334
2344
|
const { path: path2 } = ctx.runtime;
|
|
2335
|
-
|
|
2345
|
+
import_logger4.logger.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
|
|
2336
2346
|
const css = extractFile(ctx, file);
|
|
2337
2347
|
if (!css)
|
|
2338
2348
|
return;
|
|
@@ -2346,22 +2356,22 @@ function extractFile(ctx, file) {
|
|
|
2346
2356
|
} = ctx;
|
|
2347
2357
|
return (0, import_lil_fp.pipe)(
|
|
2348
2358
|
{ file: path2.abs(cwd, file) },
|
|
2349
|
-
(0, import_lil_fp.tap)(() =>
|
|
2350
|
-
import_lil_fp.Obj.bind("measure", () =>
|
|
2359
|
+
(0, import_lil_fp.tap)(() => import_logger4.logger.debug("file:extract", file)),
|
|
2360
|
+
import_lil_fp.Obj.bind("measure", () => import_logger4.logger.time.debug(`Extracted ${file}`)),
|
|
2351
2361
|
import_lil_fp.Obj.bind(
|
|
2352
2362
|
"result",
|
|
2353
2363
|
(0, import_lil_fp.tryCatch)(
|
|
2354
2364
|
({ file: file2 }) => ctx.project.parseSourceFile(file2),
|
|
2355
|
-
(error) =>
|
|
2365
|
+
(error) => import_logger4.logger.error("file:parse", error)
|
|
2356
2366
|
)
|
|
2357
2367
|
),
|
|
2358
|
-
import_lil_fp.Obj.bind("measureCss", () =>
|
|
2368
|
+
import_lil_fp.Obj.bind("measureCss", () => import_logger4.logger.time.debug(`Parsed ${file}`)),
|
|
2359
2369
|
import_lil_fp.Obj.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
|
|
2360
2370
|
(0, import_lil_fp.tap)(({ measure, measureCss }) => [measureCss(), measure()]),
|
|
2361
2371
|
import_lil_fp.Obj.get("css")
|
|
2362
2372
|
);
|
|
2363
2373
|
}
|
|
2364
|
-
function
|
|
2374
|
+
function writeChunks(ctx) {
|
|
2365
2375
|
return Promise.allSettled(ctx.getFiles().map((file) => writeFileChunk(ctx, file)));
|
|
2366
2376
|
}
|
|
2367
2377
|
var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
@@ -2379,23 +2389,57 @@ async function emitArtifacts(ctx) {
|
|
|
2379
2389
|
msg: ctx.messages.artifactsGenerated()
|
|
2380
2390
|
};
|
|
2381
2391
|
}
|
|
2382
|
-
async function
|
|
2392
|
+
async function emitArtfifactsAndCssChunks(ctx) {
|
|
2383
2393
|
await emitArtifacts(ctx);
|
|
2384
2394
|
if (ctx.config.emitTokensOnly) {
|
|
2385
2395
|
return { files: [], msg: "Successfully rebuilt the css variables and js function to query your tokens \u2728" };
|
|
2386
2396
|
}
|
|
2387
|
-
return
|
|
2397
|
+
return writeAndBundleCssChunks(ctx);
|
|
2388
2398
|
}
|
|
2389
|
-
async function
|
|
2390
|
-
await
|
|
2391
|
-
return
|
|
2399
|
+
async function writeAndBundleCssChunks(ctx) {
|
|
2400
|
+
await writeChunks(ctx);
|
|
2401
|
+
return bundleStyleChunksWithImports(ctx);
|
|
2392
2402
|
}
|
|
2393
2403
|
async function bundleCss(ctx, outfile) {
|
|
2394
|
-
const extracted = await
|
|
2404
|
+
const extracted = await writeChunks(ctx);
|
|
2395
2405
|
const files = ctx.chunks.getFiles();
|
|
2396
|
-
|
|
2406
|
+
const minify = ctx.config.minify;
|
|
2407
|
+
await (0, import_promises2.writeFile)(outfile, (0, import_core2.optimizeCss)(ctx.getCss({ files, resolve: true }), { minify }));
|
|
2397
2408
|
return { files, msg: ctx.messages.buildComplete(extracted.length) };
|
|
2398
2409
|
}
|
|
2410
|
+
async function bundleMinimalFilesCss(ctx, outfile) {
|
|
2411
|
+
const files = ctx.getFiles();
|
|
2412
|
+
const filesWithCss = [];
|
|
2413
|
+
const collector = (0, import_parser2.createParserResult)();
|
|
2414
|
+
files.forEach((file) => {
|
|
2415
|
+
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
2416
|
+
const result = ctx.project.parseSourceFile(file);
|
|
2417
|
+
measure();
|
|
2418
|
+
if (!result)
|
|
2419
|
+
return;
|
|
2420
|
+
collector.merge(result);
|
|
2421
|
+
filesWithCss.push(file);
|
|
2422
|
+
});
|
|
2423
|
+
const css = ctx.getParserCss(collector);
|
|
2424
|
+
if (!css)
|
|
2425
|
+
return { files, msg: ctx.messages.buildComplete(files.length) };
|
|
2426
|
+
const minify = ctx.config.minify;
|
|
2427
|
+
await (0, import_promises2.writeFile)(outfile, (0, import_core2.optimizeCss)(css, { minify }));
|
|
2428
|
+
return { files, msg: ctx.messages.buildComplete(files.length) };
|
|
2429
|
+
}
|
|
2430
|
+
async function generateCssArtifactOfType(ctx, cssType, outfile) {
|
|
2431
|
+
let notFound = false;
|
|
2432
|
+
const css = (0, import_ts_pattern.match)(cssType).with("preflight", () => ctx.getResetCss(ctx)).with("tokens", () => ctx.getTokenCss(ctx)).with("static", () => ctx.getStaticCss(ctx)).with("global", () => ctx.getGlobalCss(ctx)).with("keyframes", () => ctx.getKeyframeCss(ctx)).otherwise(() => {
|
|
2433
|
+
notFound = true;
|
|
2434
|
+
});
|
|
2435
|
+
if (notFound)
|
|
2436
|
+
return { msg: `No css artifact of type <${cssType}> was found` };
|
|
2437
|
+
if (!css)
|
|
2438
|
+
return { msg: `No css to generate for type <${cssType}>` };
|
|
2439
|
+
const minify = ctx.config.minify;
|
|
2440
|
+
await (0, import_promises2.writeFile)(outfile, (0, import_core2.optimizeCss)(css, { minify }));
|
|
2441
|
+
return { msg: `Successfully generated ${cssType} css artifact \u2728` };
|
|
2442
|
+
}
|
|
2399
2443
|
|
|
2400
2444
|
// src/parse-dependency.ts
|
|
2401
2445
|
init_cjs_shims();
|
|
@@ -2453,7 +2497,7 @@ var Builder = class {
|
|
|
2453
2497
|
configDependencies = /* @__PURE__ */ new Set();
|
|
2454
2498
|
writeFileCss = (file, css) => {
|
|
2455
2499
|
const oldCss = this.fileCssMap?.get(file) ?? "";
|
|
2456
|
-
const newCss = (0,
|
|
2500
|
+
const newCss = (0, import_core3.mergeCss)(oldCss, css);
|
|
2457
2501
|
this.fileCssMap?.set(file, newCss);
|
|
2458
2502
|
};
|
|
2459
2503
|
checkConfigDeps = (configPath, deps) => {
|
|
@@ -2477,7 +2521,7 @@ var Builder = class {
|
|
|
2477
2521
|
delete require.cache[file];
|
|
2478
2522
|
}
|
|
2479
2523
|
if (setupCount > 0) {
|
|
2480
|
-
|
|
2524
|
+
import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2481
2525
|
}
|
|
2482
2526
|
return { isModified: true, modifiedMap: newModified };
|
|
2483
2527
|
};
|
|
@@ -2489,7 +2533,7 @@ var Builder = class {
|
|
|
2489
2533
|
return configPath;
|
|
2490
2534
|
};
|
|
2491
2535
|
setup = async (options = {}) => {
|
|
2492
|
-
|
|
2536
|
+
import_logger5.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2493
2537
|
const configPath = options.configPath ?? this.getConfigPath();
|
|
2494
2538
|
const tsOptions = this.context?.tsOptions ?? { baseUrl: void 0, pathMappings: [] };
|
|
2495
2539
|
const compilerOptions = this.context?.tsconfig?.compilerOptions ?? {};
|
|
@@ -2562,7 +2606,7 @@ var Builder = class {
|
|
|
2562
2606
|
};
|
|
2563
2607
|
extract = async () => {
|
|
2564
2608
|
const ctx = this.getContextOrThrow();
|
|
2565
|
-
const done =
|
|
2609
|
+
const done = import_logger5.logger.time.info("Extracted in");
|
|
2566
2610
|
await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
|
|
2567
2611
|
done();
|
|
2568
2612
|
};
|
|
@@ -2587,7 +2631,7 @@ var Builder = class {
|
|
|
2587
2631
|
const rootCssContent = root.toString();
|
|
2588
2632
|
root.removeAll();
|
|
2589
2633
|
root.append(
|
|
2590
|
-
(0,
|
|
2634
|
+
(0, import_core3.optimizeCss)(`
|
|
2591
2635
|
${rootCssContent}
|
|
2592
2636
|
${this.toString()}
|
|
2593
2637
|
`)
|
|
@@ -2612,24 +2656,24 @@ var Builder = class {
|
|
|
2612
2656
|
|
|
2613
2657
|
// src/debug-files.ts
|
|
2614
2658
|
init_cjs_shims();
|
|
2615
|
-
var
|
|
2659
|
+
var import_logger6 = require("@pandacss/logger");
|
|
2616
2660
|
var nodePath = __toESM(require("path"));
|
|
2617
2661
|
async function debugFiles(ctx, options) {
|
|
2618
2662
|
const files = ctx.getFiles();
|
|
2619
|
-
const measureTotal =
|
|
2663
|
+
const measureTotal = import_logger6.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2620
2664
|
ctx.config.minify = false;
|
|
2621
2665
|
ctx.config.optimize = true;
|
|
2622
2666
|
const { fs, path: path2 } = ctx.runtime;
|
|
2623
2667
|
const outdir = options.outdir;
|
|
2624
2668
|
if (!options.dry && outdir) {
|
|
2625
2669
|
fs.ensureDirSync(outdir);
|
|
2626
|
-
|
|
2670
|
+
import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/config.json`)}`);
|
|
2627
2671
|
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2628
2672
|
}
|
|
2629
2673
|
const filesWithCss = [];
|
|
2630
2674
|
await Promise.allSettled(
|
|
2631
2675
|
files.map(async (file) => {
|
|
2632
|
-
const measure =
|
|
2676
|
+
const measure = import_logger6.logger.time.debug(`Parsed ${file}`);
|
|
2633
2677
|
const result = ctx.project.parseSourceFile(file);
|
|
2634
2678
|
measure();
|
|
2635
2679
|
if (!result)
|
|
@@ -2647,8 +2691,8 @@ async function debugFiles(ctx, options) {
|
|
|
2647
2691
|
const relative3 = path2.relative(ctx.config.cwd, parsedPath.dir);
|
|
2648
2692
|
const astJsonPath = `${relative3}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
|
|
2649
2693
|
const cssPath = `${relative3}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
|
|
2650
|
-
|
|
2651
|
-
|
|
2694
|
+
import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2695
|
+
import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2652
2696
|
return Promise.allSettled([
|
|
2653
2697
|
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2654
2698
|
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
@@ -2656,13 +2700,13 @@ async function debugFiles(ctx, options) {
|
|
|
2656
2700
|
}
|
|
2657
2701
|
})
|
|
2658
2702
|
);
|
|
2659
|
-
|
|
2703
|
+
import_logger6.logger.info("cli", `Found ${import_logger6.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2660
2704
|
measureTotal();
|
|
2661
2705
|
}
|
|
2662
2706
|
|
|
2663
2707
|
// src/exec-command.ts
|
|
2664
2708
|
init_cjs_shims();
|
|
2665
|
-
var
|
|
2709
|
+
var import_logger7 = require("@pandacss/logger");
|
|
2666
2710
|
var import_child_process = require("child_process");
|
|
2667
2711
|
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2668
2712
|
async function execCommand(cmd, cwd) {
|
|
@@ -2674,14 +2718,14 @@ async function execCommand(cmd, cwd) {
|
|
|
2674
2718
|
}
|
|
2675
2719
|
const check = (0, import_child_process.spawnSync)(pm, args, { cwd, stdio: "pipe" });
|
|
2676
2720
|
if (check.status !== 0) {
|
|
2677
|
-
|
|
2721
|
+
import_logger7.logger.error("exec", check.stderr.toString());
|
|
2678
2722
|
}
|
|
2679
2723
|
}
|
|
2680
2724
|
|
|
2681
2725
|
// src/generate.ts
|
|
2682
2726
|
init_cjs_shims();
|
|
2683
|
-
var
|
|
2684
|
-
var
|
|
2727
|
+
var import_logger8 = require("@pandacss/logger");
|
|
2728
|
+
var import_ts_pattern2 = require("ts-pattern");
|
|
2685
2729
|
|
|
2686
2730
|
// src/load-context.ts
|
|
2687
2731
|
init_cjs_shims();
|
|
@@ -2697,8 +2741,8 @@ var loadContext = async (config, configPath) => {
|
|
|
2697
2741
|
|
|
2698
2742
|
// src/generate.ts
|
|
2699
2743
|
async function build(ctx) {
|
|
2700
|
-
const { msg } = await
|
|
2701
|
-
|
|
2744
|
+
const { msg } = await emitArtfifactsAndCssChunks(ctx);
|
|
2745
|
+
import_logger8.logger.info("css:emit", msg);
|
|
2702
2746
|
}
|
|
2703
2747
|
async function generate(config, configPath) {
|
|
2704
2748
|
const [ctxRef, loadCtx] = await loadContext(config, configPath);
|
|
@@ -2712,28 +2756,28 @@ async function generate(config, configPath) {
|
|
|
2712
2756
|
if (ctx.config.watch) {
|
|
2713
2757
|
const configWatcher = fs.watch({ include: dependencies });
|
|
2714
2758
|
configWatcher.on("change", async () => {
|
|
2715
|
-
|
|
2759
|
+
import_logger8.logger.info("config:change", "Config changed, restarting...");
|
|
2716
2760
|
await loadCtx();
|
|
2717
2761
|
await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
|
|
2718
2762
|
return build(ctxRef.current);
|
|
2719
2763
|
});
|
|
2720
2764
|
const contentWatcher = fs.watch(ctx.config);
|
|
2721
2765
|
contentWatcher.on("all", async (event, file) => {
|
|
2722
|
-
|
|
2723
|
-
(0,
|
|
2766
|
+
import_logger8.logger.info(`file:${event}`, file);
|
|
2767
|
+
(0, import_ts_pattern2.match)(event).with("unlink", () => {
|
|
2724
2768
|
ctx.project.removeSourceFile(path2.abs(cwd, file));
|
|
2725
2769
|
ctx.chunks.rm(file);
|
|
2726
2770
|
}).with("change", async () => {
|
|
2727
2771
|
ctx.project.reloadSourceFile(file);
|
|
2728
2772
|
await writeFileChunk(ctxRef.current, file);
|
|
2729
|
-
return
|
|
2773
|
+
return bundleStyleChunksWithImports(ctxRef.current);
|
|
2730
2774
|
}).with("add", async () => {
|
|
2731
2775
|
ctx.project.createSourceFile(file);
|
|
2732
|
-
return
|
|
2776
|
+
return bundleStyleChunksWithImports(ctxRef.current);
|
|
2733
2777
|
}).otherwise(() => {
|
|
2734
2778
|
});
|
|
2735
2779
|
});
|
|
2736
|
-
|
|
2780
|
+
import_logger8.logger.info("ctx:watch", ctx.messages.watch());
|
|
2737
2781
|
}
|
|
2738
2782
|
}
|
|
2739
2783
|
|
|
@@ -2765,7 +2809,7 @@ function setupGitIgnore(ctx) {
|
|
|
2765
2809
|
// src/setup-config.ts
|
|
2766
2810
|
init_cjs_shims();
|
|
2767
2811
|
var import_generator2 = require("@pandacss/generator");
|
|
2768
|
-
var
|
|
2812
|
+
var import_logger9 = require("@pandacss/logger");
|
|
2769
2813
|
var import_fs_extra3 = require("fs-extra");
|
|
2770
2814
|
var import_look_it_up3 = require("look-it-up");
|
|
2771
2815
|
var import_outdent2 = require("outdent");
|
|
@@ -2779,9 +2823,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
2779
2823
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2780
2824
|
const isTs = (0, import_look_it_up3.lookItUpSync)("tsconfig.json", cwd);
|
|
2781
2825
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2782
|
-
|
|
2826
|
+
import_logger9.logger.info("init:config", `creating panda config file: ${(0, import_logger9.quote)(file)}`);
|
|
2783
2827
|
if (!force && configFile) {
|
|
2784
|
-
|
|
2828
|
+
import_logger9.logger.warn("init:config", import_generator2.messages.configExists(cmd));
|
|
2785
2829
|
} else {
|
|
2786
2830
|
const content = import_outdent2.outdent`
|
|
2787
2831
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2814,11 +2858,11 @@ syntax: '${syntax}'` : ""}
|
|
|
2814
2858
|
})
|
|
2815
2859
|
`;
|
|
2816
2860
|
await (0, import_fs_extra3.writeFile)((0, import_path3.join)(cwd, file), content);
|
|
2817
|
-
|
|
2861
|
+
import_logger9.logger.log(import_generator2.messages.thankYou());
|
|
2818
2862
|
}
|
|
2819
2863
|
}
|
|
2820
2864
|
async function setupPostcss(cwd) {
|
|
2821
|
-
|
|
2865
|
+
import_logger9.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger9.quote)("postcss.config.cjs")}`);
|
|
2822
2866
|
const content = import_outdent2.outdent`
|
|
2823
2867
|
module.exports = {
|
|
2824
2868
|
plugins: {
|
|
@@ -2831,13 +2875,13 @@ module.exports = {
|
|
|
2831
2875
|
|
|
2832
2876
|
// src/ship-files.ts
|
|
2833
2877
|
init_cjs_shims();
|
|
2834
|
-
var
|
|
2835
|
-
var
|
|
2878
|
+
var import_logger10 = require("@pandacss/logger");
|
|
2879
|
+
var import_parser3 = require("@pandacss/parser");
|
|
2836
2880
|
var import_promises3 = require("fs/promises");
|
|
2837
2881
|
var path = __toESM(require("path"));
|
|
2838
2882
|
async function shipFiles(ctx, outfile) {
|
|
2839
2883
|
const files = ctx.getFiles();
|
|
2840
|
-
const extractResult = (0,
|
|
2884
|
+
const extractResult = (0, import_parser3.createParserResult)();
|
|
2841
2885
|
const filesWithCss = [];
|
|
2842
2886
|
files.forEach(async (file) => {
|
|
2843
2887
|
const result = ctx.project.parseSourceFile(file);
|
|
@@ -2849,33 +2893,34 @@ async function shipFiles(ctx, outfile) {
|
|
|
2849
2893
|
extractResult.merge(result);
|
|
2850
2894
|
filesWithCss.push(path.relative(ctx.config.cwd, file));
|
|
2851
2895
|
});
|
|
2852
|
-
|
|
2896
|
+
import_logger10.logger.info("cli", `Found ${import_logger10.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2853
2897
|
const minify = ctx.config.minify;
|
|
2854
|
-
|
|
2898
|
+
import_logger10.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger10.colors.bold(outfile)}`);
|
|
2855
2899
|
const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
|
|
2856
2900
|
await (0, import_promises3.writeFile)(outfile, output);
|
|
2857
|
-
|
|
2901
|
+
import_logger10.logger.info("cli", "Done!");
|
|
2858
2902
|
}
|
|
2859
2903
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2860
2904
|
0 && (module.exports = {
|
|
2861
2905
|
Builder,
|
|
2862
2906
|
analyzeTokens,
|
|
2863
2907
|
bundleCss,
|
|
2908
|
+
bundleMinimalFilesCss,
|
|
2864
2909
|
createContext,
|
|
2865
2910
|
debugFiles,
|
|
2866
|
-
|
|
2867
|
-
emitAndExtract,
|
|
2911
|
+
emitArtfifactsAndCssChunks,
|
|
2868
2912
|
emitArtifacts,
|
|
2869
2913
|
execCommand,
|
|
2870
|
-
extractCss,
|
|
2871
2914
|
extractFile,
|
|
2872
2915
|
findConfig,
|
|
2873
2916
|
generate,
|
|
2917
|
+
generateCssArtifactOfType,
|
|
2874
2918
|
loadConfigAndCreateContext,
|
|
2875
2919
|
parseDependency,
|
|
2876
2920
|
setupConfig,
|
|
2877
2921
|
setupGitIgnore,
|
|
2878
2922
|
setupPostcss,
|
|
2879
2923
|
shipFiles,
|
|
2880
|
-
writeAnalyzeJSON
|
|
2924
|
+
writeAnalyzeJSON,
|
|
2925
|
+
writeAndBundleCssChunks
|
|
2881
2926
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
mod
|
|
35
35
|
));
|
|
36
36
|
|
|
37
|
-
// ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.
|
|
37
|
+
// ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
|
|
38
38
|
var init_esm_shims = __esm({
|
|
39
|
-
"../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.
|
|
39
|
+
"../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js"() {
|
|
40
40
|
"use strict";
|
|
41
41
|
}
|
|
42
42
|
});
|
|
@@ -403,7 +403,6 @@ var require_ansi_align = __commonJS({
|
|
|
403
403
|
|
|
404
404
|
// src/index.ts
|
|
405
405
|
init_esm_shims();
|
|
406
|
-
import { discardDuplicate as discardDuplicate2 } from "@pandacss/core";
|
|
407
406
|
|
|
408
407
|
// src/analyze-tokens.ts
|
|
409
408
|
init_esm_shims();
|
|
@@ -757,9 +756,9 @@ var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
|
757
756
|
// src/builder.ts
|
|
758
757
|
init_esm_shims();
|
|
759
758
|
import { getConfigDependencies } from "@pandacss/config";
|
|
760
|
-
import {
|
|
759
|
+
import { optimizeCss as optimizeCss2, mergeCss as mergeCss2 } from "@pandacss/core";
|
|
761
760
|
import { ConfigNotFoundError } from "@pandacss/error";
|
|
762
|
-
import { logger as
|
|
761
|
+
import { logger as logger5 } from "@pandacss/logger";
|
|
763
762
|
import { existsSync as existsSync2 } from "fs";
|
|
764
763
|
import { statSync } from "fs-extra";
|
|
765
764
|
import { resolve as resolve2 } from "path";
|
|
@@ -913,22 +912,29 @@ var getOutputEngine = ({
|
|
|
913
912
|
const { dir = paths.root, files } = output;
|
|
914
913
|
fs.ensureDirSync(path2.join(...dir));
|
|
915
914
|
return Promise.allSettled(
|
|
916
|
-
files.map(async (
|
|
915
|
+
files.map(async (artifact) => {
|
|
916
|
+
if (!artifact)
|
|
917
|
+
return;
|
|
918
|
+
const { file, code } = artifact;
|
|
917
919
|
const absPath = path2.join(...dir, file);
|
|
918
|
-
if (code)
|
|
919
|
-
return
|
|
920
|
-
|
|
920
|
+
if (!code)
|
|
921
|
+
return;
|
|
922
|
+
return fs.writeFile(absPath, code);
|
|
921
923
|
})
|
|
922
924
|
);
|
|
923
925
|
}
|
|
924
926
|
});
|
|
925
927
|
|
|
926
928
|
// src/create-context.ts
|
|
929
|
+
import { logger as logger3 } from "@pandacss/logger";
|
|
927
930
|
var createContext = (conf) => {
|
|
928
931
|
const generator = createGenerator(conf);
|
|
929
932
|
const config = conf.config;
|
|
930
933
|
const runtime = nodeRuntime;
|
|
931
934
|
config.cwd ||= runtime.cwd();
|
|
935
|
+
if (config.logLevel) {
|
|
936
|
+
logger3.level = config.logLevel;
|
|
937
|
+
}
|
|
932
938
|
const { include, exclude, cwd } = config;
|
|
933
939
|
const getFiles = () => runtime.fs.glob({ include, exclude, cwd });
|
|
934
940
|
const ctx = {
|
|
@@ -991,7 +997,7 @@ async function loadConfigAndCreateContext(options = {}) {
|
|
|
991
997
|
|
|
992
998
|
// src/extract.ts
|
|
993
999
|
init_esm_shims();
|
|
994
|
-
import { logger as
|
|
1000
|
+
import { logger as logger4 } from "@pandacss/logger";
|
|
995
1001
|
import { Obj, pipe, tap, tryCatch } from "lil-fp";
|
|
996
1002
|
|
|
997
1003
|
// src/cli-box.ts
|
|
@@ -2308,7 +2314,10 @@ var createBox = (options) => boxen(options.content, {
|
|
|
2308
2314
|
|
|
2309
2315
|
// src/extract.ts
|
|
2310
2316
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
2311
|
-
|
|
2317
|
+
import { createParserResult } from "@pandacss/parser";
|
|
2318
|
+
import { match } from "ts-pattern";
|
|
2319
|
+
import { optimizeCss } from "@pandacss/core";
|
|
2320
|
+
async function bundleStyleChunksWithImports(ctx) {
|
|
2312
2321
|
const files = ctx.chunks.getFiles();
|
|
2313
2322
|
await ctx.output.write({
|
|
2314
2323
|
dir: ctx.paths.root,
|
|
@@ -2318,7 +2327,7 @@ async function bundleChunks(ctx) {
|
|
|
2318
2327
|
}
|
|
2319
2328
|
async function writeFileChunk(ctx, file) {
|
|
2320
2329
|
const { path: path2 } = ctx.runtime;
|
|
2321
|
-
|
|
2330
|
+
logger4.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
|
|
2322
2331
|
const css = extractFile(ctx, file);
|
|
2323
2332
|
if (!css)
|
|
2324
2333
|
return;
|
|
@@ -2332,22 +2341,22 @@ function extractFile(ctx, file) {
|
|
|
2332
2341
|
} = ctx;
|
|
2333
2342
|
return pipe(
|
|
2334
2343
|
{ file: path2.abs(cwd, file) },
|
|
2335
|
-
tap(() =>
|
|
2336
|
-
Obj.bind("measure", () =>
|
|
2344
|
+
tap(() => logger4.debug("file:extract", file)),
|
|
2345
|
+
Obj.bind("measure", () => logger4.time.debug(`Extracted ${file}`)),
|
|
2337
2346
|
Obj.bind(
|
|
2338
2347
|
"result",
|
|
2339
2348
|
tryCatch(
|
|
2340
2349
|
({ file: file2 }) => ctx.project.parseSourceFile(file2),
|
|
2341
|
-
(error) =>
|
|
2350
|
+
(error) => logger4.error("file:parse", error)
|
|
2342
2351
|
)
|
|
2343
2352
|
),
|
|
2344
|
-
Obj.bind("measureCss", () =>
|
|
2353
|
+
Obj.bind("measureCss", () => logger4.time.debug(`Parsed ${file}`)),
|
|
2345
2354
|
Obj.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
|
|
2346
2355
|
tap(({ measure, measureCss }) => [measureCss(), measure()]),
|
|
2347
2356
|
Obj.get("css")
|
|
2348
2357
|
);
|
|
2349
2358
|
}
|
|
2350
|
-
function
|
|
2359
|
+
function writeChunks(ctx) {
|
|
2351
2360
|
return Promise.allSettled(ctx.getFiles().map((file) => writeFileChunk(ctx, file)));
|
|
2352
2361
|
}
|
|
2353
2362
|
var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
@@ -2365,23 +2374,57 @@ async function emitArtifacts(ctx) {
|
|
|
2365
2374
|
msg: ctx.messages.artifactsGenerated()
|
|
2366
2375
|
};
|
|
2367
2376
|
}
|
|
2368
|
-
async function
|
|
2377
|
+
async function emitArtfifactsAndCssChunks(ctx) {
|
|
2369
2378
|
await emitArtifacts(ctx);
|
|
2370
2379
|
if (ctx.config.emitTokensOnly) {
|
|
2371
2380
|
return { files: [], msg: "Successfully rebuilt the css variables and js function to query your tokens \u2728" };
|
|
2372
2381
|
}
|
|
2373
|
-
return
|
|
2382
|
+
return writeAndBundleCssChunks(ctx);
|
|
2374
2383
|
}
|
|
2375
|
-
async function
|
|
2376
|
-
await
|
|
2377
|
-
return
|
|
2384
|
+
async function writeAndBundleCssChunks(ctx) {
|
|
2385
|
+
await writeChunks(ctx);
|
|
2386
|
+
return bundleStyleChunksWithImports(ctx);
|
|
2378
2387
|
}
|
|
2379
2388
|
async function bundleCss(ctx, outfile) {
|
|
2380
|
-
const extracted = await
|
|
2389
|
+
const extracted = await writeChunks(ctx);
|
|
2381
2390
|
const files = ctx.chunks.getFiles();
|
|
2382
|
-
|
|
2391
|
+
const minify = ctx.config.minify;
|
|
2392
|
+
await writeFile3(outfile, optimizeCss(ctx.getCss({ files, resolve: true }), { minify }));
|
|
2383
2393
|
return { files, msg: ctx.messages.buildComplete(extracted.length) };
|
|
2384
2394
|
}
|
|
2395
|
+
async function bundleMinimalFilesCss(ctx, outfile) {
|
|
2396
|
+
const files = ctx.getFiles();
|
|
2397
|
+
const filesWithCss = [];
|
|
2398
|
+
const collector = createParserResult();
|
|
2399
|
+
files.forEach((file) => {
|
|
2400
|
+
const measure = logger4.time.debug(`Parsed ${file}`);
|
|
2401
|
+
const result = ctx.project.parseSourceFile(file);
|
|
2402
|
+
measure();
|
|
2403
|
+
if (!result)
|
|
2404
|
+
return;
|
|
2405
|
+
collector.merge(result);
|
|
2406
|
+
filesWithCss.push(file);
|
|
2407
|
+
});
|
|
2408
|
+
const css = ctx.getParserCss(collector);
|
|
2409
|
+
if (!css)
|
|
2410
|
+
return { files, msg: ctx.messages.buildComplete(files.length) };
|
|
2411
|
+
const minify = ctx.config.minify;
|
|
2412
|
+
await writeFile3(outfile, optimizeCss(css, { minify }));
|
|
2413
|
+
return { files, msg: ctx.messages.buildComplete(files.length) };
|
|
2414
|
+
}
|
|
2415
|
+
async function generateCssArtifactOfType(ctx, cssType, outfile) {
|
|
2416
|
+
let notFound = false;
|
|
2417
|
+
const css = match(cssType).with("preflight", () => ctx.getResetCss(ctx)).with("tokens", () => ctx.getTokenCss(ctx)).with("static", () => ctx.getStaticCss(ctx)).with("global", () => ctx.getGlobalCss(ctx)).with("keyframes", () => ctx.getKeyframeCss(ctx)).otherwise(() => {
|
|
2418
|
+
notFound = true;
|
|
2419
|
+
});
|
|
2420
|
+
if (notFound)
|
|
2421
|
+
return { msg: `No css artifact of type <${cssType}> was found` };
|
|
2422
|
+
if (!css)
|
|
2423
|
+
return { msg: `No css to generate for type <${cssType}>` };
|
|
2424
|
+
const minify = ctx.config.minify;
|
|
2425
|
+
await writeFile3(outfile, optimizeCss(css, { minify }));
|
|
2426
|
+
return { msg: `Successfully generated ${cssType} css artifact \u2728` };
|
|
2427
|
+
}
|
|
2385
2428
|
|
|
2386
2429
|
// src/parse-dependency.ts
|
|
2387
2430
|
init_esm_shims();
|
|
@@ -2463,7 +2506,7 @@ var Builder = class {
|
|
|
2463
2506
|
delete __require.cache[file];
|
|
2464
2507
|
}
|
|
2465
2508
|
if (setupCount > 0) {
|
|
2466
|
-
|
|
2509
|
+
logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2467
2510
|
}
|
|
2468
2511
|
return { isModified: true, modifiedMap: newModified };
|
|
2469
2512
|
};
|
|
@@ -2475,7 +2518,7 @@ var Builder = class {
|
|
|
2475
2518
|
return configPath;
|
|
2476
2519
|
};
|
|
2477
2520
|
setup = async (options = {}) => {
|
|
2478
|
-
|
|
2521
|
+
logger5.debug("builder", "\u{1F6A7} Setup");
|
|
2479
2522
|
const configPath = options.configPath ?? this.getConfigPath();
|
|
2480
2523
|
const tsOptions = this.context?.tsOptions ?? { baseUrl: void 0, pathMappings: [] };
|
|
2481
2524
|
const compilerOptions = this.context?.tsconfig?.compilerOptions ?? {};
|
|
@@ -2548,7 +2591,7 @@ var Builder = class {
|
|
|
2548
2591
|
};
|
|
2549
2592
|
extract = async () => {
|
|
2550
2593
|
const ctx = this.getContextOrThrow();
|
|
2551
|
-
const done =
|
|
2594
|
+
const done = logger5.time.info("Extracted in");
|
|
2552
2595
|
await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
|
|
2553
2596
|
done();
|
|
2554
2597
|
};
|
|
@@ -2573,7 +2616,7 @@ var Builder = class {
|
|
|
2573
2616
|
const rootCssContent = root.toString();
|
|
2574
2617
|
root.removeAll();
|
|
2575
2618
|
root.append(
|
|
2576
|
-
|
|
2619
|
+
optimizeCss2(`
|
|
2577
2620
|
${rootCssContent}
|
|
2578
2621
|
${this.toString()}
|
|
2579
2622
|
`)
|
|
@@ -2598,24 +2641,24 @@ var Builder = class {
|
|
|
2598
2641
|
|
|
2599
2642
|
// src/debug-files.ts
|
|
2600
2643
|
init_esm_shims();
|
|
2601
|
-
import { colors, logger as
|
|
2644
|
+
import { colors, logger as logger6 } from "@pandacss/logger";
|
|
2602
2645
|
import * as nodePath from "path";
|
|
2603
2646
|
async function debugFiles(ctx, options) {
|
|
2604
2647
|
const files = ctx.getFiles();
|
|
2605
|
-
const measureTotal =
|
|
2648
|
+
const measureTotal = logger6.time.debug(`Done parsing ${files.length} files`);
|
|
2606
2649
|
ctx.config.minify = false;
|
|
2607
2650
|
ctx.config.optimize = true;
|
|
2608
2651
|
const { fs, path: path2 } = ctx.runtime;
|
|
2609
2652
|
const outdir = options.outdir;
|
|
2610
2653
|
if (!options.dry && outdir) {
|
|
2611
2654
|
fs.ensureDirSync(outdir);
|
|
2612
|
-
|
|
2655
|
+
logger6.info("cli", `Writing ${colors.bold(`${outdir}/config.json`)}`);
|
|
2613
2656
|
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2614
2657
|
}
|
|
2615
2658
|
const filesWithCss = [];
|
|
2616
2659
|
await Promise.allSettled(
|
|
2617
2660
|
files.map(async (file) => {
|
|
2618
|
-
const measure =
|
|
2661
|
+
const measure = logger6.time.debug(`Parsed ${file}`);
|
|
2619
2662
|
const result = ctx.project.parseSourceFile(file);
|
|
2620
2663
|
measure();
|
|
2621
2664
|
if (!result)
|
|
@@ -2633,8 +2676,8 @@ async function debugFiles(ctx, options) {
|
|
|
2633
2676
|
const relative3 = path2.relative(ctx.config.cwd, parsedPath.dir);
|
|
2634
2677
|
const astJsonPath = `${relative3}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
|
|
2635
2678
|
const cssPath = `${relative3}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
|
|
2636
|
-
|
|
2637
|
-
|
|
2679
|
+
logger6.info("cli", `Writing ${colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2680
|
+
logger6.info("cli", `Writing ${colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2638
2681
|
return Promise.allSettled([
|
|
2639
2682
|
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2640
2683
|
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
@@ -2642,13 +2685,13 @@ async function debugFiles(ctx, options) {
|
|
|
2642
2685
|
}
|
|
2643
2686
|
})
|
|
2644
2687
|
);
|
|
2645
|
-
|
|
2688
|
+
logger6.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2646
2689
|
measureTotal();
|
|
2647
2690
|
}
|
|
2648
2691
|
|
|
2649
2692
|
// src/exec-command.ts
|
|
2650
2693
|
init_esm_shims();
|
|
2651
|
-
import { logger as
|
|
2694
|
+
import { logger as logger7 } from "@pandacss/logger";
|
|
2652
2695
|
import { spawnSync } from "child_process";
|
|
2653
2696
|
import getPackageManager from "preferred-pm";
|
|
2654
2697
|
async function execCommand(cmd, cwd) {
|
|
@@ -2660,14 +2703,14 @@ async function execCommand(cmd, cwd) {
|
|
|
2660
2703
|
}
|
|
2661
2704
|
const check = spawnSync(pm, args, { cwd, stdio: "pipe" });
|
|
2662
2705
|
if (check.status !== 0) {
|
|
2663
|
-
|
|
2706
|
+
logger7.error("exec", check.stderr.toString());
|
|
2664
2707
|
}
|
|
2665
2708
|
}
|
|
2666
2709
|
|
|
2667
2710
|
// src/generate.ts
|
|
2668
2711
|
init_esm_shims();
|
|
2669
|
-
import { logger as
|
|
2670
|
-
import { match } from "ts-pattern";
|
|
2712
|
+
import { logger as logger8 } from "@pandacss/logger";
|
|
2713
|
+
import { match as match2 } from "ts-pattern";
|
|
2671
2714
|
|
|
2672
2715
|
// src/load-context.ts
|
|
2673
2716
|
init_esm_shims();
|
|
@@ -2683,8 +2726,8 @@ var loadContext = async (config, configPath) => {
|
|
|
2683
2726
|
|
|
2684
2727
|
// src/generate.ts
|
|
2685
2728
|
async function build(ctx) {
|
|
2686
|
-
const { msg } = await
|
|
2687
|
-
|
|
2729
|
+
const { msg } = await emitArtfifactsAndCssChunks(ctx);
|
|
2730
|
+
logger8.info("css:emit", msg);
|
|
2688
2731
|
}
|
|
2689
2732
|
async function generate(config, configPath) {
|
|
2690
2733
|
const [ctxRef, loadCtx] = await loadContext(config, configPath);
|
|
@@ -2698,28 +2741,28 @@ async function generate(config, configPath) {
|
|
|
2698
2741
|
if (ctx.config.watch) {
|
|
2699
2742
|
const configWatcher = fs.watch({ include: dependencies });
|
|
2700
2743
|
configWatcher.on("change", async () => {
|
|
2701
|
-
|
|
2744
|
+
logger8.info("config:change", "Config changed, restarting...");
|
|
2702
2745
|
await loadCtx();
|
|
2703
2746
|
await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
|
|
2704
2747
|
return build(ctxRef.current);
|
|
2705
2748
|
});
|
|
2706
2749
|
const contentWatcher = fs.watch(ctx.config);
|
|
2707
2750
|
contentWatcher.on("all", async (event, file) => {
|
|
2708
|
-
|
|
2709
|
-
|
|
2751
|
+
logger8.info(`file:${event}`, file);
|
|
2752
|
+
match2(event).with("unlink", () => {
|
|
2710
2753
|
ctx.project.removeSourceFile(path2.abs(cwd, file));
|
|
2711
2754
|
ctx.chunks.rm(file);
|
|
2712
2755
|
}).with("change", async () => {
|
|
2713
2756
|
ctx.project.reloadSourceFile(file);
|
|
2714
2757
|
await writeFileChunk(ctxRef.current, file);
|
|
2715
|
-
return
|
|
2758
|
+
return bundleStyleChunksWithImports(ctxRef.current);
|
|
2716
2759
|
}).with("add", async () => {
|
|
2717
2760
|
ctx.project.createSourceFile(file);
|
|
2718
|
-
return
|
|
2761
|
+
return bundleStyleChunksWithImports(ctxRef.current);
|
|
2719
2762
|
}).otherwise(() => {
|
|
2720
2763
|
});
|
|
2721
2764
|
});
|
|
2722
|
-
|
|
2765
|
+
logger8.info("ctx:watch", ctx.messages.watch());
|
|
2723
2766
|
}
|
|
2724
2767
|
}
|
|
2725
2768
|
|
|
@@ -2751,7 +2794,7 @@ function setupGitIgnore(ctx) {
|
|
|
2751
2794
|
// src/setup-config.ts
|
|
2752
2795
|
init_esm_shims();
|
|
2753
2796
|
import { messages } from "@pandacss/generator";
|
|
2754
|
-
import { logger as
|
|
2797
|
+
import { logger as logger9, quote } from "@pandacss/logger";
|
|
2755
2798
|
import { writeFile as writeFile4 } from "fs-extra";
|
|
2756
2799
|
import { lookItUpSync as lookItUpSync3 } from "look-it-up";
|
|
2757
2800
|
import { outdent as outdent2 } from "outdent";
|
|
@@ -2765,9 +2808,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
2765
2808
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2766
2809
|
const isTs = lookItUpSync3("tsconfig.json", cwd);
|
|
2767
2810
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2768
|
-
|
|
2811
|
+
logger9.info("init:config", `creating panda config file: ${quote(file)}`);
|
|
2769
2812
|
if (!force && configFile) {
|
|
2770
|
-
|
|
2813
|
+
logger9.warn("init:config", messages.configExists(cmd));
|
|
2771
2814
|
} else {
|
|
2772
2815
|
const content = outdent2`
|
|
2773
2816
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2800,11 +2843,11 @@ syntax: '${syntax}'` : ""}
|
|
|
2800
2843
|
})
|
|
2801
2844
|
`;
|
|
2802
2845
|
await writeFile4(join2(cwd, file), content);
|
|
2803
|
-
|
|
2846
|
+
logger9.log(messages.thankYou());
|
|
2804
2847
|
}
|
|
2805
2848
|
}
|
|
2806
2849
|
async function setupPostcss(cwd) {
|
|
2807
|
-
|
|
2850
|
+
logger9.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
|
|
2808
2851
|
const content = outdent2`
|
|
2809
2852
|
module.exports = {
|
|
2810
2853
|
plugins: {
|
|
@@ -2817,13 +2860,13 @@ module.exports = {
|
|
|
2817
2860
|
|
|
2818
2861
|
// src/ship-files.ts
|
|
2819
2862
|
init_esm_shims();
|
|
2820
|
-
import { colors as colors2, logger as
|
|
2821
|
-
import { createParserResult } from "@pandacss/parser";
|
|
2863
|
+
import { colors as colors2, logger as logger10 } from "@pandacss/logger";
|
|
2864
|
+
import { createParserResult as createParserResult2 } from "@pandacss/parser";
|
|
2822
2865
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
2823
2866
|
import * as path from "path";
|
|
2824
2867
|
async function shipFiles(ctx, outfile) {
|
|
2825
2868
|
const files = ctx.getFiles();
|
|
2826
|
-
const extractResult =
|
|
2869
|
+
const extractResult = createParserResult2();
|
|
2827
2870
|
const filesWithCss = [];
|
|
2828
2871
|
files.forEach(async (file) => {
|
|
2829
2872
|
const result = ctx.project.parseSourceFile(file);
|
|
@@ -2835,32 +2878,33 @@ async function shipFiles(ctx, outfile) {
|
|
|
2835
2878
|
extractResult.merge(result);
|
|
2836
2879
|
filesWithCss.push(path.relative(ctx.config.cwd, file));
|
|
2837
2880
|
});
|
|
2838
|
-
|
|
2881
|
+
logger10.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2839
2882
|
const minify = ctx.config.minify;
|
|
2840
|
-
|
|
2883
|
+
logger10.info("cli", `Writing ${minify ? "[min] " : " "}${colors2.bold(outfile)}`);
|
|
2841
2884
|
const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
|
|
2842
2885
|
await writeFile5(outfile, output);
|
|
2843
|
-
|
|
2886
|
+
logger10.info("cli", "Done!");
|
|
2844
2887
|
}
|
|
2845
2888
|
export {
|
|
2846
2889
|
Builder,
|
|
2847
2890
|
analyzeTokens,
|
|
2848
2891
|
bundleCss,
|
|
2892
|
+
bundleMinimalFilesCss,
|
|
2849
2893
|
createContext,
|
|
2850
2894
|
debugFiles,
|
|
2851
|
-
|
|
2852
|
-
emitAndExtract,
|
|
2895
|
+
emitArtfifactsAndCssChunks,
|
|
2853
2896
|
emitArtifacts,
|
|
2854
2897
|
execCommand,
|
|
2855
|
-
extractCss,
|
|
2856
2898
|
extractFile,
|
|
2857
2899
|
findConfig,
|
|
2858
2900
|
generate,
|
|
2901
|
+
generateCssArtifactOfType,
|
|
2859
2902
|
loadConfigAndCreateContext,
|
|
2860
2903
|
parseDependency,
|
|
2861
2904
|
setupConfig,
|
|
2862
2905
|
setupGitIgnore,
|
|
2863
2906
|
setupPostcss,
|
|
2864
2907
|
shipFiles,
|
|
2865
|
-
writeAnalyzeJSON
|
|
2908
|
+
writeAnalyzeJSON,
|
|
2909
|
+
writeAndBundleCssChunks
|
|
2866
2910
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"pathe": "^1.1.1",
|
|
30
30
|
"pkg-types": "1.0.3",
|
|
31
31
|
"pluralize": "8.0.0",
|
|
32
|
-
"postcss": "8.4.
|
|
32
|
+
"postcss": "^8.4.31",
|
|
33
33
|
"preferred-pm": "^3.0.3",
|
|
34
34
|
"ts-morph": "19.0.0",
|
|
35
35
|
"ts-pattern": "5.0.5",
|
|
36
36
|
"tsconfck": "^2.1.2",
|
|
37
|
-
"@pandacss/config": "0.
|
|
38
|
-
"@pandacss/core": "0.
|
|
39
|
-
"@pandacss/error": "0.
|
|
40
|
-
"@pandacss/extractor": "0.
|
|
41
|
-
"@pandacss/generator": "0.
|
|
42
|
-
"@pandacss/is-valid-prop": "0.
|
|
43
|
-
"@pandacss/logger": "0.
|
|
44
|
-
"@pandacss/parser": "0.
|
|
45
|
-
"@pandacss/shared": "0.
|
|
46
|
-
"@pandacss/token-dictionary": "0.
|
|
47
|
-
"@pandacss/types": "0.
|
|
37
|
+
"@pandacss/config": "0.17.0",
|
|
38
|
+
"@pandacss/core": "0.17.0",
|
|
39
|
+
"@pandacss/error": "0.17.0",
|
|
40
|
+
"@pandacss/extractor": "0.17.0",
|
|
41
|
+
"@pandacss/generator": "0.17.0",
|
|
42
|
+
"@pandacss/is-valid-prop": "0.17.0",
|
|
43
|
+
"@pandacss/logger": "0.17.0",
|
|
44
|
+
"@pandacss/parser": "0.17.0",
|
|
45
|
+
"@pandacss/shared": "0.17.0",
|
|
46
|
+
"@pandacss/token-dictionary": "0.17.0",
|
|
47
|
+
"@pandacss/types": "0.17.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/fs-extra": "11.0.2",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/lodash.merge": "4.6.7",
|
|
54
54
|
"@types/pluralize": "0.0.30",
|
|
55
55
|
"boxen": "^7.1.1",
|
|
56
|
-
"@pandacss/fixture": "0.
|
|
56
|
+
"@pandacss/fixture": "0.17.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|