qstd 0.2.11 → 0.2.13

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.
@@ -547,11 +547,18 @@ var hexColor = () => {
547
547
  var log_exports = {};
548
548
  __export(log_exports, {
549
549
  error: () => error,
550
+ header: () => header,
550
551
  info: () => info,
552
+ label: () => label,
551
553
  log: () => log,
554
+ startTimer: () => startTimer,
552
555
  warn: () => warn
553
556
  });
554
557
  var stringify = (value) => JSON.stringify(value, null, 2);
558
+ var startTimer = () => {
559
+ const start = Date.now();
560
+ return () => Date.now() - start;
561
+ };
555
562
  var log = (...values) => {
556
563
  console.log(...values.map(stringify));
557
564
  };
@@ -564,6 +571,27 @@ var warn = (...values) => {
564
571
  var error = (...values) => {
565
572
  console.log("[error]", ...values.map(stringify));
566
573
  };
574
+ var header = (message) => {
575
+ console.log(`========== ${message} ==========`);
576
+ };
577
+ var label = (name) => ({
578
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
579
+ info: (...values) => {
580
+ console.log(`[${name}]`, ...values.map(stringify));
581
+ },
582
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
583
+ warn: (...values) => {
584
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
585
+ },
586
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
587
+ error: (...values) => {
588
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
589
+ },
590
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
591
+ header: (message) => {
592
+ console.log(`[${name}] ========== ${message} ==========`);
593
+ }
594
+ });
567
595
 
568
596
  // src/client/dom.ts
569
597
  var dom_exports = {};
@@ -545,11 +545,18 @@ var hexColor = () => {
545
545
  var log_exports = {};
546
546
  __export(log_exports, {
547
547
  error: () => error,
548
+ header: () => header,
548
549
  info: () => info,
550
+ label: () => label,
549
551
  log: () => log,
552
+ startTimer: () => startTimer,
550
553
  warn: () => warn
551
554
  });
552
555
  var stringify = (value) => JSON.stringify(value, null, 2);
556
+ var startTimer = () => {
557
+ const start = Date.now();
558
+ return () => Date.now() - start;
559
+ };
553
560
  var log = (...values) => {
554
561
  console.log(...values.map(stringify));
555
562
  };
@@ -562,6 +569,27 @@ var warn = (...values) => {
562
569
  var error = (...values) => {
563
570
  console.log("[error]", ...values.map(stringify));
564
571
  };
572
+ var header = (message) => {
573
+ console.log(`========== ${message} ==========`);
574
+ };
575
+ var label = (name) => ({
576
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
577
+ info: (...values) => {
578
+ console.log(`[${name}]`, ...values.map(stringify));
579
+ },
580
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
581
+ warn: (...values) => {
582
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
583
+ },
584
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
585
+ error: (...values) => {
586
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
587
+ },
588
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
589
+ header: (message) => {
590
+ console.log(`[${name}] ========== ${message} ==========`);
591
+ }
592
+ });
565
593
 
566
594
  // src/client/dom.ts
567
595
  var dom_exports = {};
@@ -1,8 +1,15 @@
1
+ import type { Readable } from "node:stream";
1
2
  /**
2
3
  * Read file contents as string
3
4
  * @param filePath
4
5
  * @param encoding
5
6
  * @returns
6
7
  */
7
- export declare const readFile: (filePath: string, encoding?: BufferEncoding) => string;
8
+ export declare const readFile: (filePath: string, encoding?: BufferEncoding) => Promise<string>;
9
+ /**
10
+ * Write a readable stream to a file
11
+ * @param filepath - Path to write the file to
12
+ * @param buffer - Readable stream to write
13
+ */
14
+ export declare const writeBufferToFile: (filepath: string, buffer: Readable | undefined) => Promise<void>;
8
15
  //# sourceMappingURL=file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/server/file.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,WAAU,cAAwB,KACjC,MAEF,CAAC"}
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/server/file.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,WAAU,cAAwB,KACjC,OAAO,CAAC,MAAM,CAEhB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,MAAM,EAChB,QAAQ,QAAQ,GAAG,SAAS,kBAO7B,CAAC"}
@@ -3,10 +3,6 @@
3
3
  var dateFns = require('date-fns');
4
4
  var fs = require('fs');
5
5
 
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var fs__default = /*#__PURE__*/_interopDefault(fs);
9
-
10
6
  var __defProp = Object.defineProperty;
11
7
  var __export = (target, all) => {
12
8
  for (var name in all)
@@ -552,11 +548,18 @@ var hexColor = () => {
552
548
  var log_exports = {};
553
549
  __export(log_exports, {
554
550
  error: () => error,
551
+ header: () => header,
555
552
  info: () => info,
553
+ label: () => label,
556
554
  log: () => log,
555
+ startTimer: () => startTimer,
557
556
  warn: () => warn
558
557
  });
559
558
  var stringify = (value) => JSON.stringify(value, null, 2);
559
+ var startTimer = () => {
560
+ const start = Date.now();
561
+ return () => Date.now() - start;
562
+ };
560
563
  var log = (...values) => {
561
564
  console.log(...values.map(stringify));
562
565
  };
@@ -569,14 +572,43 @@ var warn = (...values) => {
569
572
  var error = (...values) => {
570
573
  console.log("[error]", ...values.map(stringify));
571
574
  };
575
+ var header = (message) => {
576
+ console.log(`========== ${message} ==========`);
577
+ };
578
+ var label = (name) => ({
579
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
580
+ info: (...values) => {
581
+ console.log(`[${name}]`, ...values.map(stringify));
582
+ },
583
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
584
+ warn: (...values) => {
585
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
586
+ },
587
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
588
+ error: (...values) => {
589
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
590
+ },
591
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
592
+ header: (message) => {
593
+ console.log(`[${name}] ========== ${message} ==========`);
594
+ }
595
+ });
572
596
 
573
597
  // src/server/file.ts
574
598
  var file_exports = {};
575
599
  __export(file_exports, {
576
- readFile: () => readFile
600
+ readFile: () => readFile,
601
+ writeBufferToFile: () => writeBufferToFile
577
602
  });
578
- var readFile = (filePath, encoding = "utf-8") => {
579
- return fs__default.default.readFileSync(filePath, encoding);
603
+ var readFile = async (filePath, encoding = "utf-8") => {
604
+ return fs.promises.readFile(filePath, encoding);
605
+ };
606
+ var writeBufferToFile = async (filepath, buffer) => {
607
+ const chunks = [];
608
+ for await (const chunk2 of buffer) {
609
+ chunks.push(chunk2);
610
+ }
611
+ await fs.promises.writeFile(filepath, Buffer.concat(chunks));
580
612
  };
581
613
 
582
614
  exports.Dict = dict_exports;
@@ -1,5 +1,5 @@
1
1
  import { format, formatDistanceToNow, formatISO, isSameYear, isSameMonth, isSameDay, addSeconds, addMinutes, addHours, addDays, addWeeks, addBusinessDays, addMonths, addYears } from 'date-fns';
2
- import fs from 'fs';
2
+ import { promises } from 'fs';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -546,11 +546,18 @@ var hexColor = () => {
546
546
  var log_exports = {};
547
547
  __export(log_exports, {
548
548
  error: () => error,
549
+ header: () => header,
549
550
  info: () => info,
551
+ label: () => label,
550
552
  log: () => log,
553
+ startTimer: () => startTimer,
551
554
  warn: () => warn
552
555
  });
553
556
  var stringify = (value) => JSON.stringify(value, null, 2);
557
+ var startTimer = () => {
558
+ const start = Date.now();
559
+ return () => Date.now() - start;
560
+ };
554
561
  var log = (...values) => {
555
562
  console.log(...values.map(stringify));
556
563
  };
@@ -563,14 +570,43 @@ var warn = (...values) => {
563
570
  var error = (...values) => {
564
571
  console.log("[error]", ...values.map(stringify));
565
572
  };
573
+ var header = (message) => {
574
+ console.log(`========== ${message} ==========`);
575
+ };
576
+ var label = (name) => ({
577
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
578
+ info: (...values) => {
579
+ console.log(`[${name}]`, ...values.map(stringify));
580
+ },
581
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
582
+ warn: (...values) => {
583
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
584
+ },
585
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
586
+ error: (...values) => {
587
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
588
+ },
589
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
590
+ header: (message) => {
591
+ console.log(`[${name}] ========== ${message} ==========`);
592
+ }
593
+ });
566
594
 
567
595
  // src/server/file.ts
568
596
  var file_exports = {};
569
597
  __export(file_exports, {
570
- readFile: () => readFile
598
+ readFile: () => readFile,
599
+ writeBufferToFile: () => writeBufferToFile
571
600
  });
572
- var readFile = (filePath, encoding = "utf-8") => {
573
- return fs.readFileSync(filePath, encoding);
601
+ var readFile = async (filePath, encoding = "utf-8") => {
602
+ return promises.readFile(filePath, encoding);
603
+ };
604
+ var writeBufferToFile = async (filepath, buffer) => {
605
+ const chunks = [];
606
+ for await (const chunk2 of buffer) {
607
+ chunks.push(chunk2);
608
+ }
609
+ await promises.writeFile(filepath, Buffer.concat(chunks));
574
610
  };
575
611
 
576
612
  export { dict_exports as Dict, file_exports as File, flow_exports as Flow, int_exports as Int, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
@@ -1,5 +1,98 @@
1
+ /**
2
+ * Usage Examples:
3
+ *
4
+ * ```typescript // Basic logging
5
+ * Log.info("stuff"); // [info] "stuff"
6
+ * Log.warn("uh oh"); // [warn] "uh oh"
7
+ * Log.error("bad"); // [error] "bad"
8
+ *
9
+ * // Standalone header
10
+ * Log.header("STARTING"); // ========== STARTING ==========
11
+ *
12
+ * // Scoped logger
13
+ * const log = Log.label("audio-processor");
14
+ * log.info("something"); // [audio-processor] "something"
15
+ * log.warn("hmm"); // [audio-processor] [warn] "hmm"
16
+ * log.error("failed"); // [audio-processor] [error] "failed"
17
+ * log.header("HANDLER START"); // [audio-processor] ========== HANDLER START ==========
18
+ *
19
+ */
20
+ /**
21
+ * Starts a timer and returns a function that returns elapsed milliseconds.
22
+ * @returns A function that returns the elapsed time in ms since the timer started
23
+ * @example
24
+ * ```typescript // Timer
25
+ * const elapsed = Log.startTimer();
26
+ * // ... do work ...
27
+ * log.header(`COMPLETE (${elapsed()}ms)`); // ========== COMPLETE (123ms) ==========```
28
+ */
29
+ export declare const startTimer: () => () => number;
30
+ /**
31
+ * Logs values to the console (no prefix).
32
+ * @param values - Values to log (will be JSON stringified)
33
+ * @example
34
+ * ```typescript
35
+ * log("hello"); // "hello"
36
+ * ```
37
+ */
1
38
  export declare const log: (...values: unknown[]) => void;
39
+ /**
40
+ * Logs values with [info] prefix.
41
+ * @param values - Values to log (will be JSON stringified)
42
+ * @example
43
+ * ```typescript
44
+ * info("stuff"); // [info] "stuff"
45
+ * ```
46
+ */
2
47
  export declare const info: (...values: unknown[]) => void;
48
+ /**
49
+ * Logs values with [warn] prefix.
50
+ * @param values - Values to log (will be JSON stringified)
51
+ * @example
52
+ * ```typescript
53
+ * warn("uh oh"); // [warn] "uh oh"
54
+ * ```
55
+ */
3
56
  export declare const warn: (...values: unknown[]) => void;
57
+ /**
58
+ * Logs values with [error] prefix.
59
+ * @param values - Values to log (will be JSON stringified)
60
+ * @example
61
+ * ```typescript
62
+ * error("bad"); // [error] "bad"
63
+ * ```
64
+ */
4
65
  export declare const error: (...values: unknown[]) => void;
66
+ /**
67
+ * Logs a message wrapped in header decoration.
68
+ * @param message - The header message
69
+ * @example
70
+ * ```typescript
71
+ * header("STARTING"); // ========== STARTING ==========
72
+ * ```
73
+ */
74
+ export declare const header: (message: string) => void;
75
+ /**
76
+ * Creates a scoped logger with a label prefix.
77
+ * @param name - The label to prefix all log messages with
78
+ * @returns A logger object with info, warn, error, and header methods
79
+ * @example
80
+ * ```typescript
81
+ * const log = label("audio-processor");
82
+ * log.info("something"); // [audio-processor] "something"
83
+ * log.warn("hmm"); // [audio-processor] [warn] "hmm"
84
+ * log.error("failed"); // [audio-processor] [error] "failed"
85
+ * log.header("HANDLER START"); // [audio-processor] ========== HANDLER START ==========
86
+ * ```
87
+ */
88
+ export declare const label: (name: string) => {
89
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
90
+ info: (...values: unknown[]) => void;
91
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
92
+ warn: (...values: unknown[]) => void;
93
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
94
+ error: (...values: unknown[]) => void;
95
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
96
+ header: (message: string) => void;
97
+ };
5
98
  //# sourceMappingURL=log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/shared/log.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEvC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEzC,CAAC"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/shared/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,oBAWtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEvC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,SAErC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM;IAChC,iEAAiE;sBAC/C,OAAO,EAAE;IAG3B,+EAA+E;sBAC7D,OAAO,EAAE;IAG3B,iFAAiF;uBAC9D,OAAO,EAAE;IAG5B,iGAAiG;sBAC/E,MAAM;CAGxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qstd",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",
@@ -41,6 +41,24 @@
41
41
  "sideEffects": [
42
42
  "dist/react/index.css"
43
43
  ],
44
+ "scripts": {
45
+ "build": "panda codegen && panda cssgen && tsup && tsc -p tsconfig.build.json && node scripts/inject-css-import.js",
46
+ "build:js": "tsup",
47
+ "build:types": "tsc -p tsconfig.build.json",
48
+ "dev": "tsup --watch",
49
+ "prepublishOnly": "pnpm build",
50
+ "prepare:local": "pnpm build && cd playground && pnpm prepare",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest",
53
+ "test:all": "pnpx tsx tests/test-all.ts",
54
+ "test:block": "node tests/test-block.tsx",
55
+ "test:playground": "node tests/playground-e2e.mjs",
56
+ "typecheck": "tsc --noEmit",
57
+ "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
58
+ "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
59
+ "analyze:tsserver": "bash performance/analyze-tsserver.sh",
60
+ "lint": "eslint ."
61
+ },
44
62
  "peerDependencies": {
45
63
  "react": "^18.0.0 || ^19.0.0",
46
64
  "react-dom": "^18.0.0 || ^19.0.0"
@@ -96,22 +114,5 @@
96
114
  "bugs": {
97
115
  "url": "https://github.com/55cancri/qstd/issues"
98
116
  },
99
- "homepage": "https://github.com/55cancri/qstd#readme",
100
- "scripts": {
101
- "build": "panda codegen && panda cssgen && tsup && tsc -p tsconfig.build.json && node scripts/inject-css-import.js",
102
- "build:js": "tsup",
103
- "build:types": "tsc -p tsconfig.build.json",
104
- "dev": "tsup --watch",
105
- "prepare:local": "pnpm build && cd playground && pnpm prepare",
106
- "test": "vitest run",
107
- "test:watch": "vitest",
108
- "test:all": "pnpx tsx tests/test-all.ts",
109
- "test:block": "node tests/test-block.tsx",
110
- "test:playground": "node tests/playground-e2e.mjs",
111
- "typecheck": "tsc --noEmit",
112
- "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
113
- "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
114
- "analyze:tsserver": "bash performance/analyze-tsserver.sh",
115
- "lint": "eslint ."
116
- }
117
- }
117
+ "homepage": "https://github.com/55cancri/qstd#readme"
118
+ }