@pandacss/node 0.0.0-dev-20230611145407 → 0.0.0-dev-20230611160609
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 +3 -2
- package/dist/index.js +39 -127
- package/dist/index.mjs +14 -100
- package/package.json +13 -14
package/dist/index.d.ts
CHANGED
|
@@ -35,9 +35,10 @@ type PandaContext = Generator & {
|
|
|
35
35
|
output: ReturnType<typeof getOutputEngine>;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
type Options = {
|
|
39
39
|
onResult?: (file: string, result: ParserResultType) => void;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
|
+
declare function analyzeTokens(ctx: PandaContext, options?: Options): {
|
|
41
42
|
duration: {
|
|
42
43
|
extractTimeByFiles: {
|
|
43
44
|
[k: string]: number;
|
package/dist/index.js
CHANGED
|
@@ -39,80 +39,6 @@ var init_cjs_shims = __esm({
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
// ../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
|
|
43
|
-
var require_duplexer = __commonJS({
|
|
44
|
-
"../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js"(exports, module2) {
|
|
45
|
-
init_cjs_shims();
|
|
46
|
-
var Stream = require("stream");
|
|
47
|
-
var writeMethods = ["write", "end", "destroy"];
|
|
48
|
-
var readMethods = ["resume", "pause"];
|
|
49
|
-
var readEvents = ["data", "close"];
|
|
50
|
-
var slice = Array.prototype.slice;
|
|
51
|
-
module2.exports = duplex;
|
|
52
|
-
function forEach(arr, fn) {
|
|
53
|
-
if (arr.forEach) {
|
|
54
|
-
return arr.forEach(fn);
|
|
55
|
-
}
|
|
56
|
-
for (var i = 0; i < arr.length; i++) {
|
|
57
|
-
fn(arr[i], i);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function duplex(writer, reader) {
|
|
61
|
-
var stream2 = new Stream();
|
|
62
|
-
var ended = false;
|
|
63
|
-
forEach(writeMethods, proxyWriter);
|
|
64
|
-
forEach(readMethods, proxyReader);
|
|
65
|
-
forEach(readEvents, proxyStream);
|
|
66
|
-
reader.on("end", handleEnd);
|
|
67
|
-
writer.on("drain", function() {
|
|
68
|
-
stream2.emit("drain");
|
|
69
|
-
});
|
|
70
|
-
writer.on("error", reemit);
|
|
71
|
-
reader.on("error", reemit);
|
|
72
|
-
stream2.writable = writer.writable;
|
|
73
|
-
stream2.readable = reader.readable;
|
|
74
|
-
return stream2;
|
|
75
|
-
function proxyWriter(methodName) {
|
|
76
|
-
stream2[methodName] = method;
|
|
77
|
-
function method() {
|
|
78
|
-
return writer[methodName].apply(writer, arguments);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function proxyReader(methodName) {
|
|
82
|
-
stream2[methodName] = method;
|
|
83
|
-
function method() {
|
|
84
|
-
stream2.emit(methodName);
|
|
85
|
-
var func = reader[methodName];
|
|
86
|
-
if (func) {
|
|
87
|
-
return func.apply(reader, arguments);
|
|
88
|
-
}
|
|
89
|
-
reader.emit(methodName);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function proxyStream(methodName) {
|
|
93
|
-
reader.on(methodName, reemit2);
|
|
94
|
-
function reemit2() {
|
|
95
|
-
var args = slice.call(arguments);
|
|
96
|
-
args.unshift(methodName);
|
|
97
|
-
stream2.emit.apply(stream2, args);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function handleEnd() {
|
|
101
|
-
if (ended) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
ended = true;
|
|
105
|
-
var args = slice.call(arguments);
|
|
106
|
-
args.unshift("end");
|
|
107
|
-
stream2.emit.apply(stream2, args);
|
|
108
|
-
}
|
|
109
|
-
function reemit(err) {
|
|
110
|
-
stream2.emit("error", err);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
42
|
// ../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js
|
|
117
43
|
var require_eastasianwidth = __commonJS({
|
|
118
44
|
"../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js"(exports, module2) {
|
|
@@ -502,7 +428,9 @@ var import_core3 = require("@pandacss/core");
|
|
|
502
428
|
// src/analyze-tokens.ts
|
|
503
429
|
init_cjs_shims();
|
|
504
430
|
var import_logger = require("@pandacss/logger");
|
|
431
|
+
var import_filesize = require("filesize");
|
|
505
432
|
var import_promises = require("fs/promises");
|
|
433
|
+
var import_zlib = __toESM(require("zlib"));
|
|
506
434
|
|
|
507
435
|
// src/classify.ts
|
|
508
436
|
init_cjs_shims();
|
|
@@ -554,7 +482,7 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
554
482
|
}
|
|
555
483
|
if (type === "pattern") {
|
|
556
484
|
const pattern = ctx.patterns.getConfig(from.toLowerCase());
|
|
557
|
-
const patternProp = pattern
|
|
485
|
+
const patternProp = pattern?.properties?.[propName];
|
|
558
486
|
if (!patternProp)
|
|
559
487
|
return false;
|
|
560
488
|
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
@@ -767,39 +695,24 @@ var getMostUsedInMap = (map, pickCount) => {
|
|
|
767
695
|
};
|
|
768
696
|
|
|
769
697
|
// src/analyze-tokens.ts
|
|
770
|
-
var
|
|
771
|
-
|
|
772
|
-
// ../../node_modules/.pnpm/gzip-size@7.0.0/node_modules/gzip-size/index.js
|
|
773
|
-
init_cjs_shims();
|
|
774
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
775
|
-
var import_node_stream = __toESM(require("stream"), 1);
|
|
776
|
-
var import_node_zlib = __toESM(require("zlib"), 1);
|
|
777
|
-
var import_node_util = require("util");
|
|
778
|
-
var import_duplexer = __toESM(require_duplexer(), 1);
|
|
779
|
-
var getOptions = (options) => ({ level: 9, ...options });
|
|
780
|
-
var gzip = (0, import_node_util.promisify)(import_node_zlib.default.gzip);
|
|
781
|
-
function gzipSizeSync(input, options) {
|
|
782
|
-
return import_node_zlib.default.gzipSync(input, getOptions(options)).length;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
// src/analyze-tokens.ts
|
|
698
|
+
var gzipSizeSync = (code) => import_zlib.default.gzipSync(code, { level: import_zlib.default.constants.Z_BEST_COMPRESSION }).length;
|
|
786
699
|
function analyzeTokens(ctx, options = {}) {
|
|
787
|
-
const
|
|
788
|
-
const
|
|
789
|
-
const
|
|
790
|
-
|
|
700
|
+
const filesMap = /* @__PURE__ */ new Map();
|
|
701
|
+
const timesMap = /* @__PURE__ */ new Map();
|
|
702
|
+
const files = ctx.getFiles();
|
|
703
|
+
files.forEach((file) => {
|
|
791
704
|
const start2 = performance.now();
|
|
792
705
|
const result = ctx.project.parseSourceFile(file);
|
|
793
706
|
const extractMs = performance.now() - start2;
|
|
794
|
-
|
|
707
|
+
timesMap.set(file, extractMs);
|
|
795
708
|
import_logger.logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
796
709
|
if (result) {
|
|
797
|
-
|
|
710
|
+
filesMap.set(file, result);
|
|
798
711
|
options.onResult?.(file, result);
|
|
799
712
|
}
|
|
800
713
|
});
|
|
801
|
-
const totalMs = Array.from(
|
|
802
|
-
import_logger.logger.debug("analyze", `Analyzed ${
|
|
714
|
+
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
715
|
+
import_logger.logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
803
716
|
const minify = ctx.config.minify;
|
|
804
717
|
const chunkFiles = ctx.chunks.getFiles();
|
|
805
718
|
ctx.config.optimize = true;
|
|
@@ -809,18 +722,17 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
809
722
|
const minifiedCss = ctx.getCss({ files: chunkFiles });
|
|
810
723
|
ctx.config.minify = minify;
|
|
811
724
|
const start = performance.now();
|
|
812
|
-
const analysis = classifyTokens(ctx,
|
|
725
|
+
const analysis = classifyTokens(ctx, filesMap);
|
|
813
726
|
const classifyMs = performance.now() - start;
|
|
814
727
|
return Object.assign(
|
|
815
728
|
{
|
|
816
729
|
duration: {
|
|
817
|
-
extractTimeByFiles: Object.fromEntries(
|
|
730
|
+
extractTimeByFiles: Object.fromEntries(timesMap.entries()),
|
|
818
731
|
extractTotal: totalMs,
|
|
819
732
|
classify: classifyMs
|
|
820
733
|
},
|
|
821
734
|
fileSizes: {
|
|
822
735
|
lineCount: css.split("\n").length,
|
|
823
|
-
// rulesCount: css.split('{').length - 1, ?
|
|
824
736
|
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
825
737
|
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
826
738
|
gzip: {
|
|
@@ -885,15 +797,15 @@ var import_lil_fp = require("lil-fp");
|
|
|
885
797
|
// src/chunk-engine.ts
|
|
886
798
|
init_cjs_shims();
|
|
887
799
|
var import_core = require("@pandacss/core");
|
|
888
|
-
var getChunkEngine = ({ paths, config, runtime: { path: path2, fs
|
|
800
|
+
var getChunkEngine = ({ paths, config, runtime: { path: path2, fs } }) => ({
|
|
889
801
|
dir: path2.join(...paths.chunk),
|
|
890
802
|
readFile(file) {
|
|
891
803
|
const fileName = path2.join(...paths.chunk, this.format(file));
|
|
892
|
-
return
|
|
804
|
+
return fs.existsSync(fileName) ? fs.readFileSync(fileName) : "";
|
|
893
805
|
},
|
|
894
806
|
getFiles() {
|
|
895
|
-
const files =
|
|
896
|
-
return files.map((file) =>
|
|
807
|
+
const files = fs.existsSync(this.dir) ? fs.readDirSync(this.dir) : [];
|
|
808
|
+
return files.map((file) => fs.readFileSync(path2.join(this.dir, file)));
|
|
897
809
|
},
|
|
898
810
|
format(file) {
|
|
899
811
|
return path2.relative(config.cwd, file).replaceAll(path2.sep, "__").replace(path2.extname(file), ".css");
|
|
@@ -907,10 +819,10 @@ var getChunkEngine = ({ paths, config, runtime: { path: path2, fs: fs2 } }) => (
|
|
|
907
819
|
};
|
|
908
820
|
},
|
|
909
821
|
rm(file) {
|
|
910
|
-
return
|
|
822
|
+
return fs.rmFileSync(path2.join(...paths.chunk, this.format(file)));
|
|
911
823
|
},
|
|
912
824
|
empty() {
|
|
913
|
-
return
|
|
825
|
+
return fs.rmDirSync(this.dir);
|
|
914
826
|
},
|
|
915
827
|
get glob() {
|
|
916
828
|
return [`${this.dir}/**/*.css`];
|
|
@@ -993,20 +905,20 @@ process.on("uncaughtException", (reason) => {
|
|
|
993
905
|
|
|
994
906
|
// src/output-engine.ts
|
|
995
907
|
init_cjs_shims();
|
|
996
|
-
var getOutputEngine = ({ paths, runtime: { path: path2, fs
|
|
908
|
+
var getOutputEngine = ({ paths, runtime: { path: path2, fs } }) => ({
|
|
997
909
|
empty() {
|
|
998
|
-
|
|
910
|
+
fs.rmDirSync(path2.join(...paths.root));
|
|
999
911
|
},
|
|
1000
912
|
async write(output) {
|
|
1001
913
|
if (!output)
|
|
1002
914
|
return;
|
|
1003
915
|
const { dir = paths.root, files } = output;
|
|
1004
|
-
|
|
916
|
+
fs.ensureDirSync(path2.join(...dir));
|
|
1005
917
|
return Promise.all(
|
|
1006
918
|
files.map(async ({ file, code }) => {
|
|
1007
919
|
const absPath = path2.join(...dir, file);
|
|
1008
920
|
if (code) {
|
|
1009
|
-
return
|
|
921
|
+
return fs.writeFile(absPath, code);
|
|
1010
922
|
}
|
|
1011
923
|
})
|
|
1012
924
|
);
|
|
@@ -1021,14 +933,14 @@ var createContext = (conf) => (0, import_lil_fp.pipe)(
|
|
|
1021
933
|
(0, import_lil_fp.tap)(({ config, runtime }) => {
|
|
1022
934
|
config.cwd ||= runtime.cwd();
|
|
1023
935
|
}),
|
|
1024
|
-
import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs
|
|
936
|
+
import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs } }) => () => {
|
|
1025
937
|
const { include, exclude, cwd } = config;
|
|
1026
|
-
return
|
|
938
|
+
return fs.glob({ include, exclude, cwd });
|
|
1027
939
|
}),
|
|
1028
|
-
import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs
|
|
940
|
+
import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs }, parserOptions }) => {
|
|
1029
941
|
return (0, import_parser.createProject)({
|
|
1030
942
|
getFiles,
|
|
1031
|
-
readFile:
|
|
943
|
+
readFile: fs.readFileSync,
|
|
1032
944
|
parserOptions
|
|
1033
945
|
});
|
|
1034
946
|
}),
|
|
@@ -1442,9 +1354,9 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1442
1354
|
}
|
|
1443
1355
|
return min;
|
|
1444
1356
|
}
|
|
1445
|
-
function createSupportsColor(
|
|
1446
|
-
const level = _supportsColor(
|
|
1447
|
-
streamIsTTY:
|
|
1357
|
+
function createSupportsColor(stream, options = {}) {
|
|
1358
|
+
const level = _supportsColor(stream, {
|
|
1359
|
+
streamIsTTY: stream && stream.isTTY,
|
|
1448
1360
|
...options
|
|
1449
1361
|
});
|
|
1450
1362
|
return translateLevel(level);
|
|
@@ -2637,12 +2549,12 @@ async function debugFiles(ctx, options) {
|
|
|
2637
2549
|
const measureTotal = import_logger5.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2638
2550
|
ctx.config.minify = false;
|
|
2639
2551
|
ctx.config.optimize = true;
|
|
2640
|
-
const { fs
|
|
2552
|
+
const { fs, path: path2 } = ctx.runtime;
|
|
2641
2553
|
const outdir = options.outdir;
|
|
2642
2554
|
if (!options.dry && outdir) {
|
|
2643
|
-
|
|
2555
|
+
fs.ensureDirSync(outdir);
|
|
2644
2556
|
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/config.json`)}`);
|
|
2645
|
-
await
|
|
2557
|
+
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2646
2558
|
}
|
|
2647
2559
|
const filesWithCss = [];
|
|
2648
2560
|
await Promise.all(
|
|
@@ -2669,8 +2581,8 @@ async function debugFiles(ctx, options) {
|
|
|
2669
2581
|
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2670
2582
|
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2671
2583
|
return Promise.all([
|
|
2672
|
-
|
|
2673
|
-
|
|
2584
|
+
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(list, debugResultSerializer, 2)),
|
|
2585
|
+
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
2674
2586
|
]);
|
|
2675
2587
|
}
|
|
2676
2588
|
})
|
|
@@ -2733,18 +2645,18 @@ async function generate(config, configPath) {
|
|
|
2733
2645
|
const ctx = ctxRef.current;
|
|
2734
2646
|
await build(ctx);
|
|
2735
2647
|
const {
|
|
2736
|
-
runtime: { fs
|
|
2648
|
+
runtime: { fs, path: path2 },
|
|
2737
2649
|
dependencies,
|
|
2738
2650
|
config: { cwd }
|
|
2739
2651
|
} = ctx;
|
|
2740
2652
|
if (ctx.config.watch) {
|
|
2741
|
-
const configWatcher =
|
|
2653
|
+
const configWatcher = fs.watch({ include: dependencies });
|
|
2742
2654
|
configWatcher.on("change", async () => {
|
|
2743
2655
|
import_logger7.logger.info("config:change", "Config changed, restarting...");
|
|
2744
2656
|
await loadCtx();
|
|
2745
2657
|
return build(ctxRef.current);
|
|
2746
2658
|
});
|
|
2747
|
-
const contentWatcher =
|
|
2659
|
+
const contentWatcher = fs.watch(ctx.config);
|
|
2748
2660
|
contentWatcher.on("all", async (event, file) => {
|
|
2749
2661
|
import_logger7.logger.info(`file:${event}`, file);
|
|
2750
2662
|
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
package/dist/index.mjs
CHANGED
|
@@ -40,80 +40,6 @@ var init_esm_shims = __esm({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// ../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
|
|
44
|
-
var require_duplexer = __commonJS({
|
|
45
|
-
"../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js"(exports, module) {
|
|
46
|
-
init_esm_shims();
|
|
47
|
-
var Stream = __require("stream");
|
|
48
|
-
var writeMethods = ["write", "end", "destroy"];
|
|
49
|
-
var readMethods = ["resume", "pause"];
|
|
50
|
-
var readEvents = ["data", "close"];
|
|
51
|
-
var slice = Array.prototype.slice;
|
|
52
|
-
module.exports = duplex;
|
|
53
|
-
function forEach(arr, fn) {
|
|
54
|
-
if (arr.forEach) {
|
|
55
|
-
return arr.forEach(fn);
|
|
56
|
-
}
|
|
57
|
-
for (var i = 0; i < arr.length; i++) {
|
|
58
|
-
fn(arr[i], i);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function duplex(writer, reader) {
|
|
62
|
-
var stream = new Stream();
|
|
63
|
-
var ended = false;
|
|
64
|
-
forEach(writeMethods, proxyWriter);
|
|
65
|
-
forEach(readMethods, proxyReader);
|
|
66
|
-
forEach(readEvents, proxyStream);
|
|
67
|
-
reader.on("end", handleEnd);
|
|
68
|
-
writer.on("drain", function() {
|
|
69
|
-
stream.emit("drain");
|
|
70
|
-
});
|
|
71
|
-
writer.on("error", reemit);
|
|
72
|
-
reader.on("error", reemit);
|
|
73
|
-
stream.writable = writer.writable;
|
|
74
|
-
stream.readable = reader.readable;
|
|
75
|
-
return stream;
|
|
76
|
-
function proxyWriter(methodName) {
|
|
77
|
-
stream[methodName] = method;
|
|
78
|
-
function method() {
|
|
79
|
-
return writer[methodName].apply(writer, arguments);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function proxyReader(methodName) {
|
|
83
|
-
stream[methodName] = method;
|
|
84
|
-
function method() {
|
|
85
|
-
stream.emit(methodName);
|
|
86
|
-
var func = reader[methodName];
|
|
87
|
-
if (func) {
|
|
88
|
-
return func.apply(reader, arguments);
|
|
89
|
-
}
|
|
90
|
-
reader.emit(methodName);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function proxyStream(methodName) {
|
|
94
|
-
reader.on(methodName, reemit2);
|
|
95
|
-
function reemit2() {
|
|
96
|
-
var args = slice.call(arguments);
|
|
97
|
-
args.unshift(methodName);
|
|
98
|
-
stream.emit.apply(stream, args);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function handleEnd() {
|
|
102
|
-
if (ended) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
ended = true;
|
|
106
|
-
var args = slice.call(arguments);
|
|
107
|
-
args.unshift("end");
|
|
108
|
-
stream.emit.apply(stream, args);
|
|
109
|
-
}
|
|
110
|
-
function reemit(err) {
|
|
111
|
-
stream.emit("error", err);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
43
|
// ../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js
|
|
118
44
|
var require_eastasianwidth = __commonJS({
|
|
119
45
|
"../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js"(exports, module) {
|
|
@@ -480,7 +406,9 @@ import { discardDuplicate as discardDuplicate2 } from "@pandacss/core";
|
|
|
480
406
|
// src/analyze-tokens.ts
|
|
481
407
|
init_esm_shims();
|
|
482
408
|
import { logger } from "@pandacss/logger";
|
|
409
|
+
import { filesize } from "filesize";
|
|
483
410
|
import { writeFile } from "fs/promises";
|
|
411
|
+
import zlib from "zlib";
|
|
484
412
|
|
|
485
413
|
// src/classify.ts
|
|
486
414
|
init_esm_shims();
|
|
@@ -532,7 +460,7 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
532
460
|
}
|
|
533
461
|
if (type === "pattern") {
|
|
534
462
|
const pattern = ctx.patterns.getConfig(from.toLowerCase());
|
|
535
|
-
const patternProp = pattern
|
|
463
|
+
const patternProp = pattern?.properties?.[propName];
|
|
536
464
|
if (!patternProp)
|
|
537
465
|
return false;
|
|
538
466
|
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
@@ -745,37 +673,24 @@ var getMostUsedInMap = (map, pickCount) => {
|
|
|
745
673
|
};
|
|
746
674
|
|
|
747
675
|
// src/analyze-tokens.ts
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
// ../../node_modules/.pnpm/gzip-size@7.0.0/node_modules/gzip-size/index.js
|
|
751
|
-
init_esm_shims();
|
|
752
|
-
var import_duplexer = __toESM(require_duplexer(), 1);
|
|
753
|
-
import zlib from "node:zlib";
|
|
754
|
-
import { promisify } from "node:util";
|
|
755
|
-
var getOptions = (options) => ({ level: 9, ...options });
|
|
756
|
-
var gzip = promisify(zlib.gzip);
|
|
757
|
-
function gzipSizeSync(input, options) {
|
|
758
|
-
return zlib.gzipSync(input, getOptions(options)).length;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// src/analyze-tokens.ts
|
|
676
|
+
var gzipSizeSync = (code) => zlib.gzipSync(code, { level: zlib.constants.Z_BEST_COMPRESSION }).length;
|
|
762
677
|
function analyzeTokens(ctx, options = {}) {
|
|
763
|
-
const
|
|
764
|
-
const
|
|
765
|
-
const
|
|
766
|
-
|
|
678
|
+
const filesMap = /* @__PURE__ */ new Map();
|
|
679
|
+
const timesMap = /* @__PURE__ */ new Map();
|
|
680
|
+
const files = ctx.getFiles();
|
|
681
|
+
files.forEach((file) => {
|
|
767
682
|
const start2 = performance.now();
|
|
768
683
|
const result = ctx.project.parseSourceFile(file);
|
|
769
684
|
const extractMs = performance.now() - start2;
|
|
770
|
-
|
|
685
|
+
timesMap.set(file, extractMs);
|
|
771
686
|
logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
772
687
|
if (result) {
|
|
773
|
-
|
|
688
|
+
filesMap.set(file, result);
|
|
774
689
|
options.onResult?.(file, result);
|
|
775
690
|
}
|
|
776
691
|
});
|
|
777
|
-
const totalMs = Array.from(
|
|
778
|
-
logger.debug("analyze", `Analyzed ${
|
|
692
|
+
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
693
|
+
logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
779
694
|
const minify = ctx.config.minify;
|
|
780
695
|
const chunkFiles = ctx.chunks.getFiles();
|
|
781
696
|
ctx.config.optimize = true;
|
|
@@ -785,18 +700,17 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
785
700
|
const minifiedCss = ctx.getCss({ files: chunkFiles });
|
|
786
701
|
ctx.config.minify = minify;
|
|
787
702
|
const start = performance.now();
|
|
788
|
-
const analysis = classifyTokens(ctx,
|
|
703
|
+
const analysis = classifyTokens(ctx, filesMap);
|
|
789
704
|
const classifyMs = performance.now() - start;
|
|
790
705
|
return Object.assign(
|
|
791
706
|
{
|
|
792
707
|
duration: {
|
|
793
|
-
extractTimeByFiles: Object.fromEntries(
|
|
708
|
+
extractTimeByFiles: Object.fromEntries(timesMap.entries()),
|
|
794
709
|
extractTotal: totalMs,
|
|
795
710
|
classify: classifyMs
|
|
796
711
|
},
|
|
797
712
|
fileSizes: {
|
|
798
713
|
lineCount: css.split("\n").length,
|
|
799
|
-
// rulesCount: css.split('{').length - 1, ?
|
|
800
714
|
normal: filesize(Buffer.byteLength(css, "utf-8")),
|
|
801
715
|
minified: filesize(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
802
716
|
gzip: {
|
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-20230611160609",
|
|
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-
|
|
36
|
-
"@pandacss/core": "0.0.0-dev-
|
|
37
|
-
"@pandacss/error": "0.0.0-dev-
|
|
38
|
-
"@pandacss/extractor": "0.0.0-dev-
|
|
39
|
-
"@pandacss/generator": "0.0.0-dev-
|
|
40
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
41
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
42
|
-
"@pandacss/parser": "0.0.0-dev-
|
|
43
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
44
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
45
|
-
"@pandacss/types": "0.0.0-dev-
|
|
35
|
+
"@pandacss/config": "0.0.0-dev-20230611160609",
|
|
36
|
+
"@pandacss/core": "0.0.0-dev-20230611160609",
|
|
37
|
+
"@pandacss/error": "0.0.0-dev-20230611160609",
|
|
38
|
+
"@pandacss/extractor": "0.0.0-dev-20230611160609",
|
|
39
|
+
"@pandacss/generator": "0.0.0-dev-20230611160609",
|
|
40
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230611160609",
|
|
41
|
+
"@pandacss/logger": "0.0.0-dev-20230611160609",
|
|
42
|
+
"@pandacss/parser": "0.0.0-dev-20230611160609",
|
|
43
|
+
"@pandacss/shared": "0.0.0-dev-20230611160609",
|
|
44
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230611160609",
|
|
45
|
+
"@pandacss/types": "0.0.0-dev-20230611160609"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/fs-extra": "11.0.1",
|
|
@@ -51,8 +51,7 @@
|
|
|
51
51
|
"@types/lodash.merge": "4.6.7",
|
|
52
52
|
"@types/pluralize": "0.0.29",
|
|
53
53
|
"boxen": "^7.1.0",
|
|
54
|
-
"
|
|
55
|
-
"@pandacss/fixture": "0.0.0-dev-20230611145407"
|
|
54
|
+
"@pandacss/fixture": "0.0.0-dev-20230611160609"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
57
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|