@logtape/pretty 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +5 -1
- package/dist/formatter.cjs +2 -17
- package/dist/formatter.d.cts.map +1 -1
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +2 -17
- package/dist/formatter.js.map +1 -1
- package/dist/terminal.cjs +3 -5
- package/dist/terminal.js +0 -2
- package/dist/terminal.js.map +1 -1
- package/dist/util.cjs +9 -0
- package/dist/util.d.cts +12 -0
- package/dist/util.d.cts.map +1 -0
- package/dist/util.d.ts +12 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.deno.cjs +16 -0
- package/dist/util.deno.d.cts +12 -0
- package/dist/util.deno.d.cts.map +1 -0
- package/dist/util.deno.d.ts +12 -0
- package/dist/util.deno.d.ts.map +1 -0
- package/dist/util.deno.js +16 -0
- package/dist/util.deno.js.map +1 -0
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -0
- package/dist/util.node.cjs +10 -0
- package/dist/util.node.d.cts +12 -0
- package/dist/util.node.d.cts.map +1 -0
- package/dist/util.node.d.ts +12 -0
- package/dist/util.node.d.ts.map +1 -0
- package/dist/util.node.js +10 -0
- package/dist/util.node.js.map +1 -0
- package/formatter.ts +1 -24
- package/package.json +26 -2
- package/terminal.ts +2 -2
- package/tsdown.config.ts +15 -2
- package/util.deno.ts +19 -0
- package/util.node.ts +12 -0
- package/util.ts +11 -0
package/deno.json
CHANGED
package/dist/formatter.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_terminal = require('./terminal.cjs');
|
|
|
3
3
|
const require_truncate = require('./truncate.cjs');
|
|
4
4
|
const require_wcwidth = require('./wcwidth.cjs');
|
|
5
5
|
const require_wordwrap = require('./wordwrap.cjs');
|
|
6
|
-
const
|
|
6
|
+
const __util = require_rolldown_runtime.__toESM(require("#util"));
|
|
7
7
|
|
|
8
8
|
//#region formatter.ts
|
|
9
9
|
/**
|
|
@@ -133,21 +133,6 @@ function normalizeIconSpacing(iconMap) {
|
|
|
133
133
|
return Object.fromEntries(entries.map(([level, icon]) => [level, icon + " ".repeat(maxWidth - require_wcwidth.getDisplayWidth(icon))]));
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* Platform-specific inspect function. Uses Node.js `util.inspect()` which
|
|
137
|
-
* is available in both Deno and Node.js environments. For browser environments,
|
|
138
|
-
* it falls back to {@link JSON.stringify}.
|
|
139
|
-
*
|
|
140
|
-
* @param value The value to inspect.
|
|
141
|
-
* @param options The options for inspecting the value.
|
|
142
|
-
* @returns The string representation of the value.
|
|
143
|
-
*/
|
|
144
|
-
const inspect = typeof document !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" ? (v) => JSON.stringify(v) : (v, opts) => (0, node_util.inspect)(v, {
|
|
145
|
-
maxArrayLength: 10,
|
|
146
|
-
maxStringLength: 80,
|
|
147
|
-
compact: true,
|
|
148
|
-
...opts
|
|
149
|
-
});
|
|
150
|
-
/**
|
|
151
136
|
* Creates a beautiful console formatter optimized for local development.
|
|
152
137
|
*
|
|
153
138
|
* This formatter provides a Signale-inspired visual design with colorful icons,
|
|
@@ -311,7 +296,7 @@ function getPrettyFormatter(options = {}) {
|
|
|
311
296
|
for (let i = 0; i < record.message.length; i++) if (i % 2 === 0) message += record.message[i];
|
|
312
297
|
else {
|
|
313
298
|
const value = record.message[i];
|
|
314
|
-
const inspected = inspect(value, {
|
|
299
|
+
const inspected = (0, __util.inspect)(value, {
|
|
315
300
|
colors: useColors,
|
|
316
301
|
...inspectOptions
|
|
317
302
|
});
|
package/dist/formatter.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.cts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQ0E;AAiChE,cAPJ,MAqBI,EAAA;EAKE,SAAK,KAAA,EAAA,WACA;EAsBL,SAAA,IAAA,EAAA,WA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;;6BAyBK,QAAQ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAqCjB;;;;;;;;;;;;;;;;;;8BAmBG;;;;;;;;;;;;;;;;;;;2BAoBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA+BG;;;;;;;;;;;;;;;;;0BAkBJ;;;;;;;;;;;;;;;;;;;0BAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiJV,kBAAA,WACL,yBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4VU,iBAAiB"}
|
package/dist/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQ0E;AAiChE,cAPJ,MAqBI,EAAA;EAKE,SAAK,KAAA,EAAA,WACA;EAsBL,SAAA,IAAA,EAAA,WAAgB;EAAA,SAAA,GAAA,EAAA,WAAA;EAAA,SAA0B,MAAA,EAAA,WAAA;EAAK,SAA5B,SAAA,EAAA,WAAA;EAAG,SAAA,aAAA,EAAA,WAAA;AAalC,CAAA;;;;AAA8D,cAlDxD,UAkDwD,EAAA;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQ0E;AAiChE,cAPJ,MAqBI,EAAA;EAKE,SAAK,KAAA,EAAA,WACA;EAsBL,SAAA,IAAA,EAAA,WAAgB;EAAA,SAAA,GAAA,EAAA,WAAA;EAAA,SAA0B,MAAA,EAAA,WAAA;EAAK,SAA5B,SAAA,EAAA,WAAA;EAAG,SAAA,aAAA,EAAA,WAAA;AAalC,CAAA;;;;AAA8D,cAlDxD,UAkDwD,EAAA;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7 @@ import { getOptimalWordWrapWidth } from "./terminal.js";
|
|
|
2
2
|
import { truncateCategory } from "./truncate.js";
|
|
3
3
|
import { getDisplayWidth } from "./wcwidth.js";
|
|
4
4
|
import { wrapText } from "./wordwrap.js";
|
|
5
|
-
import { inspect } from "
|
|
5
|
+
import { inspect } from "#util";
|
|
6
6
|
|
|
7
7
|
//#region formatter.ts
|
|
8
8
|
/**
|
|
@@ -132,21 +132,6 @@ function normalizeIconSpacing(iconMap) {
|
|
|
132
132
|
return Object.fromEntries(entries.map(([level, icon]) => [level, icon + " ".repeat(maxWidth - getDisplayWidth(icon))]));
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
-
* Platform-specific inspect function. Uses Node.js `util.inspect()` which
|
|
136
|
-
* is available in both Deno and Node.js environments. For browser environments,
|
|
137
|
-
* it falls back to {@link JSON.stringify}.
|
|
138
|
-
*
|
|
139
|
-
* @param value The value to inspect.
|
|
140
|
-
* @param options The options for inspecting the value.
|
|
141
|
-
* @returns The string representation of the value.
|
|
142
|
-
*/
|
|
143
|
-
const inspect$1 = typeof document !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" ? (v) => JSON.stringify(v) : (v, opts) => inspect(v, {
|
|
144
|
-
maxArrayLength: 10,
|
|
145
|
-
maxStringLength: 80,
|
|
146
|
-
compact: true,
|
|
147
|
-
...opts
|
|
148
|
-
});
|
|
149
|
-
/**
|
|
150
135
|
* Creates a beautiful console formatter optimized for local development.
|
|
151
136
|
*
|
|
152
137
|
* This formatter provides a Signale-inspired visual design with colorful icons,
|
|
@@ -310,7 +295,7 @@ function getPrettyFormatter(options = {}) {
|
|
|
310
295
|
for (let i = 0; i < record.message.length; i++) if (i % 2 === 0) message += record.message[i];
|
|
311
296
|
else {
|
|
312
297
|
const value = record.message[i];
|
|
313
|
-
const inspected = inspect
|
|
298
|
+
const inspected = inspect(value, {
|
|
314
299
|
colors: useColors,
|
|
315
300
|
...inspectOptions
|
|
316
301
|
});
|
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","names":["color: Color","style: Style","categoryColorMap: CategoryColorMap","patterns: CategoryPattern[]","category: readonly string[]","prefix: readonly string[]","defaultIcons: Record<LogLevel, string>","iconMap: Record<LogLevel, string>","inspect: (value: unknown, options?: { colors?: boolean }) => string","options: PrettyFormatterOptions","baseIconMap: Record<LogLevel, string>","resolvedLevelColors: Record<LogLevel, Color>","levelMappings: Record<string, Record<LogLevel, string>>","level: LogLevel","timestampFormatters: Record<string, (ts: number) => string>","timestampFn: ((ts: number) => string | null) | null","wordWrapWidth: number","allLevels: LogLevel[]","record: LogRecord","prettyFormatter: TextFormatter"],"sources":["../formatter.ts"],"sourcesContent":["import type {\n LogLevel,\n LogRecord,\n TextFormatter,\n TextFormatterOptions,\n} from \"@logtape/logtape\";\nimport { inspect as nodeInspect } from \"node:util\";\nimport { getOptimalWordWrapWidth } from \"./terminal.ts\";\nimport { truncateCategory, type TruncationStrategy } from \"./truncate.ts\";\nimport { getDisplayWidth } from \"./wcwidth.ts\";\nimport { wrapText } from \"./wordwrap.ts\";\n\n/**\n * ANSI escape codes for styling\n */\nconst RESET = \"\\x1b[0m\";\nconst DIM = \"\\x1b[2m\";\n\n// Default true color values (referenced in JSDoc)\nconst defaultColors = {\n trace: \"rgb(167,139,250)\", // Light purple\n debug: \"rgb(96,165,250)\", // Light blue\n info: \"rgb(52,211,153)\", // Emerald\n warning: \"rgb(251,191,36)\", // Amber\n error: \"rgb(248,113,113)\", // Light red\n fatal: \"rgb(220,38,38)\", // Dark red\n category: \"rgb(100,116,139)\", // Slate\n message: \"rgb(148,163,184)\", // Light slate\n timestamp: \"rgb(100,116,139)\", // Slate\n} as const;\n\n/**\n * ANSI style codes\n */\nconst styles = {\n reset: RESET,\n bold: \"\\x1b[1m\",\n dim: DIM,\n italic: \"\\x1b[3m\",\n underline: \"\\x1b[4m\",\n strikethrough: \"\\x1b[9m\",\n} as const;\n\n/**\n * Standard ANSI colors (16-color)\n */\nconst ansiColors = {\n black: \"\\x1b[30m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n white: \"\\x1b[37m\",\n} as const;\n\n/**\n * Color type definition\n */\nexport type Color =\n | keyof typeof ansiColors\n | `rgb(${number},${number},${number})`\n | `#${string}`\n | null;\n\n/**\n * Category color mapping for prefix-based coloring.\n *\n * Maps category prefixes (as arrays) to colors. The formatter will match\n * categories against these prefixes and use the corresponding color.\n * Longer/more specific prefixes take precedence over shorter ones.\n *\n * @example\n * ```typescript\n * new Map([\n * [[\"app\", \"auth\"], \"#ff6b6b\"], // app.auth.* -> red\n * [[\"app\", \"db\"], \"#4ecdc4\"], // app.db.* -> teal\n * [[\"app\"], \"#45b7d1\"], // app.* (fallback) -> blue\n * [[\"lib\"], \"#96ceb4\"], // lib.* -> green\n * ])\n * ```\n */\nexport type CategoryColorMap = Map<readonly string[], Color>;\n\n/**\n * Internal representation of category prefix patterns\n */\ntype CategoryPattern = {\n prefix: readonly string[];\n color: Color;\n};\n\n/**\n * Style type definition - supports single styles, arrays of styles, or null\n */\nexport type Style = keyof typeof styles | (keyof typeof styles)[] | null;\n\n// Pre-compiled regex patterns for color parsing\nconst RGB_PATTERN = /^rgb\\((\\d+),(\\d+),(\\d+)\\)$/;\nconst HEX_PATTERN = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\n\n/**\n * Helper function to convert color to ANSI escape code\n */\nfunction colorToAnsi(color: Color): string {\n if (color === null) return \"\";\n if (color in ansiColors) {\n return ansiColors[color as keyof typeof ansiColors];\n }\n\n // Handle rgb() format\n const rgbMatch = color.match(RGB_PATTERN);\n if (rgbMatch) {\n const [, r, g, b] = rgbMatch;\n return `\\x1b[38;2;${r};${g};${b}m`;\n }\n\n // Handle hex format (#rrggbb or #rgb)\n const hexMatch = color.match(HEX_PATTERN);\n if (hexMatch) {\n let hex = hexMatch[1];\n // Convert 3-digit hex to 6-digit\n if (hex.length === 3) {\n hex = hex.split(\"\").map((c) => c + c).join(\"\");\n }\n const r = parseInt(hex.substr(0, 2), 16);\n const g = parseInt(hex.substr(2, 2), 16);\n const b = parseInt(hex.substr(4, 2), 16);\n return `\\x1b[38;2;${r};${g};${b}m`;\n }\n\n return \"\";\n}\n\n/**\n * Helper function to convert style to ANSI escape code\n */\nfunction styleToAnsi(style: Style): string {\n if (style === null) return \"\";\n if (Array.isArray(style)) {\n return style.map((s) => styles[s] || \"\").join(\"\");\n }\n return styles[style] || \"\";\n}\n\n/**\n * Converts a category color map to internal patterns and sorts them by specificity.\n * More specific (longer) prefixes come first for proper matching precedence.\n */\nfunction prepareCategoryPatterns(\n categoryColorMap: CategoryColorMap,\n): CategoryPattern[] {\n const patterns: CategoryPattern[] = [];\n\n for (const [prefix, color] of categoryColorMap) {\n patterns.push({ prefix, color });\n }\n\n // Sort by prefix length (descending) for most-specific-first matching\n return patterns.sort((a, b) => b.prefix.length - a.prefix.length);\n}\n\n/**\n * Matches a category against category color patterns.\n * Returns the color of the first matching pattern, or null if no match.\n */\nfunction matchCategoryColor(\n category: readonly string[],\n patterns: CategoryPattern[],\n): Color {\n for (const pattern of patterns) {\n if (categoryMatches(category, pattern.prefix)) {\n return pattern.color;\n }\n }\n return null;\n}\n\n/**\n * Checks if a category matches a prefix pattern.\n * A category matches if it starts with all segments of the prefix.\n */\nfunction categoryMatches(\n category: readonly string[],\n prefix: readonly string[],\n): boolean {\n if (prefix.length > category.length) {\n return false;\n }\n\n for (let i = 0; i < prefix.length; i++) {\n if (category[i] !== prefix[i]) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Default icons for each log level\n */\nconst defaultIcons: Record<LogLevel, string> = {\n trace: \"🔍\",\n debug: \"🐛\",\n info: \"✨\",\n warning: \"⚡\",\n error: \"❌\",\n fatal: \"💀\",\n};\n\n/**\n * Normalize icon spacing to ensure consistent column alignment.\n *\n * All icons will be padded with spaces to match the width of the widest icon,\n * ensuring consistent prefix alignment across all log levels.\n *\n * @param iconMap The icon mapping to normalize\n * @returns A new icon map with consistent spacing\n */\nfunction normalizeIconSpacing(\n iconMap: Record<LogLevel, string>,\n): Record<LogLevel, string> {\n const entries = Object.entries(iconMap) as Array<[LogLevel, string]>;\n const maxWidth = Math.max(\n ...entries.map(([, icon]) => getDisplayWidth(icon)),\n );\n\n return Object.fromEntries(\n entries.map(([level, icon]) => [\n level,\n icon + \" \".repeat(maxWidth - getDisplayWidth(icon)),\n ]),\n ) as Record<LogLevel, string>;\n}\n\n/**\n * Platform-specific inspect function. Uses Node.js `util.inspect()` which\n * is available in both Deno and Node.js environments. For browser environments,\n * it falls back to {@link JSON.stringify}.\n *\n * @param value The value to inspect.\n * @param options The options for inspecting the value.\n * @returns The string representation of the value.\n */\nconst inspect: (value: unknown, options?: { colors?: boolean }) => string =\n // @ts-ignore: Browser detection\n typeof document !== \"undefined\" ||\n // @ts-ignore: React Native detection\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\"\n ? (v) => JSON.stringify(v)\n : (v, opts) =>\n nodeInspect(v, {\n maxArrayLength: 10,\n maxStringLength: 80,\n compact: true,\n ...opts,\n });\n\n/**\n * Configuration options for the pretty formatter.\n *\n * This interface extends the base text formatter options while providing\n * extensive customization options for visual styling, layout control, and\n * development-focused features. It offers granular control over colors,\n * styles, and formatting similar to the ANSI color formatter.\n *\n * @since 1.0.0\n */\nexport interface PrettyFormatterOptions\n extends Omit<TextFormatterOptions, \"category\" | \"value\" | \"format\"> {\n /**\n * Color for timestamp display when timestamps are enabled.\n *\n * Supports true color RGB values, hex colors, or ANSI color names.\n * Set to `null` to disable timestamp coloring.\n *\n * @example\n * ```typescript\n * timestampColor: \"#888888\" // Hex color\n * timestampColor: \"rgb(128,128,128)\" // RGB color\n * timestampColor: \"cyan\" // ANSI color name\n * timestampColor: null // No color\n * ```\n *\n * @default `\"rgb(100,116,139)\"` (slate gray)\n */\n readonly timestampColor?: Color;\n\n /**\n * Visual style applied to timestamp text.\n *\n * Controls text appearance like boldness, dimming, etc.\n * Supports single styles, multiple styles combined, or no styling.\n * Combines with `timestampColor` for full styling control.\n *\n * @example\n * ```typescript\n * timestampStyle: \"dim\" // Single style: dimmed text\n * timestampStyle: \"bold\" // Single style: bold text\n * timestampStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * timestampStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * timestampStyle: null // No styling\n * ```\n *\n * @default `\"dim\"`\n */\n readonly timestampStyle?: Style;\n\n /**\n * Custom colors for each log level.\n *\n * Allows fine-grained control over level appearance. Each level can have\n * its own color scheme. Unspecified levels use built-in defaults.\n * Set individual levels to `null` to disable coloring for that level.\n *\n * @example\n * ```typescript\n * levelColors: {\n * info: \"#00ff00\", // Bright green for info\n * error: \"#ff0000\", // Bright red for errors\n * warning: \"orange\", // ANSI orange for warnings\n * debug: null, // No color for debug\n * }\n * ```\n *\n * @default Built-in color scheme (purple trace, blue debug, green info, amber warning, red error, dark red fatal)\n */\n readonly levelColors?: Partial<Record<LogLevel, Color>>;\n\n /**\n * Visual style applied to log level text.\n *\n * Controls the appearance of the level indicator (e.g., \"info\", \"error\").\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to level-specific colors.\n *\n * @example\n * ```typescript\n * levelStyle: \"bold\" // Single style: bold level text\n * levelStyle: \"underline\" // Single style: underlined level text\n * levelStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * levelStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * levelStyle: null // No additional styling\n * ```\n *\n * @default `\"underline\"`\n */\n readonly levelStyle?: Style;\n\n /**\n * Icon configuration for each log level.\n *\n * Controls the emoji/symbol displayed before each log entry.\n * Provides visual quick-identification of log severity.\n *\n * - `true`: Use built-in emoji set (🔍 trace, 🐛 debug, ✨ info, ⚠️ warning, ❌ error, 💀 fatal)\n * - `false`: Disable all icons for clean text-only output\n * - Object: Custom icon mapping, falls back to defaults for unspecified levels\n *\n * @example\n * ```typescript\n * icons: true // Use default emoji set\n * icons: false // No icons\n * icons: {\n * info: \"ℹ️\", // Custom info icon\n * error: \"🔥\", // Custom error icon\n * warning: \"⚡\", // Custom warning icon\n * }\n * ```\n *\n * @default `true` (use default emoji icons)\n */\n readonly icons?: boolean | Partial<Record<LogLevel, string>>;\n\n /**\n * Character(s) used to separate category hierarchy levels.\n *\n * Categories are hierarchical (e.g., [\"app\", \"auth\", \"jwt\"]) and this\n * separator joins them for display (e.g., \"app.auth.jwt\").\n *\n * @example\n * ```typescript\n * categorySeparator: \"·\" // app·auth·jwt\n * categorySeparator: \".\" // app.auth.jwt\n * categorySeparator: \":\" // app:auth:jwt\n * categorySeparator: \" > \" // app > auth > jwt\n * categorySeparator: \"::\" // app::auth::jwt\n * ```\n *\n * @default `\"·\"` (interpunct)\n */\n readonly categorySeparator?: string;\n\n /**\n * Default color for category display.\n *\n * Used as fallback when no specific color is found in `categoryColorMap`.\n * Controls the visual appearance of the category hierarchy display.\n *\n * @example\n * ```typescript\n * categoryColor: \"#666666\" // Gray categories\n * categoryColor: \"blue\" // Blue categories\n * categoryColor: \"rgb(100,150,200)\" // Light blue categories\n * categoryColor: null // No coloring\n * ```\n *\n * @default `\"rgb(100,116,139)\"` (slate gray)\n */\n readonly categoryColor?: Color;\n\n /**\n * Category-specific color mapping based on prefixes.\n *\n * Maps category prefixes (as arrays) to colors for visual grouping.\n * More specific (longer) prefixes take precedence over shorter ones.\n * If no prefix matches, falls back to the default `categoryColor`.\n *\n * @example\n * ```typescript\n * new Map([\n * [[\"app\", \"auth\"], \"#ff6b6b\"], // app.auth.* -> red\n * [[\"app\", \"db\"], \"#4ecdc4\"], // app.db.* -> teal\n * [[\"app\"], \"#45b7d1\"], // app.* (fallback) -> blue\n * [[\"lib\"], \"#96ceb4\"], // lib.* -> green\n * ])\n * ```\n */\n readonly categoryColorMap?: CategoryColorMap;\n\n /**\n * Visual style applied to category text.\n *\n * Controls the appearance of the category hierarchy display.\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to category colors from `categoryColor` or `categoryColorMap`.\n *\n * @example\n * ```typescript\n * categoryStyle: \"dim\" // Single style: dimmed category text\n * categoryStyle: \"italic\" // Single style: italic category text\n * categoryStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * categoryStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * categoryStyle: null // No additional styling\n * ```\n *\n * @default `[\"dim\", \"italic\"]` (dimmed for subtle appearance)\n */\n readonly categoryStyle?: Style;\n\n /**\n * Maximum display width for category names.\n *\n * Controls layout consistency by limiting category width.\n * Long categories are truncated according to `categoryTruncate` strategy.\n *\n * @default `20`\n */\n readonly categoryWidth?: number;\n\n /**\n * Strategy for truncating long category names.\n *\n * When categories exceed `categoryWidth`, this controls how truncation works.\n * Smart truncation preserves important context while maintaining layout.\n *\n * - `\"middle\"`: Keep first and last parts (e.g., \"app.server…auth.jwt\")\n * - `\"end\"`: Truncate at the end (e.g., \"app.server.middleware…\")\n * - `false`: No truncation (ignores `categoryWidth`)\n *\n * @example\n * ```typescript\n * categoryTruncate: \"middle\" // app.server…jwt (preserves context)\n * categoryTruncate: \"end\" // app.server.midd… (linear truncation)\n * categoryTruncate: false // app.server.middleware.auth.jwt (full)\n * ```\n *\n * @default `\"middle\"` (smart context-preserving truncation)\n */\n readonly categoryTruncate?: TruncationStrategy;\n\n /**\n * Color for log message text content.\n *\n * Controls the visual appearance of the actual log message content.\n * Does not affect structured values, which use syntax highlighting.\n *\n * @example\n * ```typescript\n * messageColor: \"#ffffff\" // White message text\n * messageColor: \"green\" // Green message text\n * messageColor: \"rgb(200,200,200)\" // Light gray message text\n * messageColor: null // No coloring\n * ```\n *\n * @default `\"rgb(148,163,184)\"` (light slate gray)\n */\n readonly messageColor?: Color;\n\n /**\n * Visual style applied to log message text.\n *\n * Controls the appearance of the log message content.\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to `messageColor`.\n *\n * @example\n * ```typescript\n * messageStyle: \"dim\" // Single style: dimmed message text\n * messageStyle: \"italic\" // Single style: italic message text\n * messageStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * messageStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * messageStyle: null // No additional styling\n * ```\n *\n * @default `\"dim\"` (dimmed for subtle readability)\n */\n readonly messageStyle?: Style;\n\n /**\n * Global color control for the entire formatter.\n *\n * Master switch to enable/disable all color output.\n * When disabled, produces clean monochrome output suitable for\n * non-color terminals or when colors are not desired.\n *\n * @example\n * ```typescript\n * colors: true // Full color output (default)\n * colors: false // Monochrome output only\n * ```\n *\n * @default `true` (colors enabled)\n */\n readonly colors?: boolean;\n\n /**\n * Column alignment for consistent visual layout.\n *\n * When enabled, ensures all log components (icons, levels, categories)\n * align consistently across multiple log entries, creating a clean\n * tabular appearance.\n *\n * @example\n * ```typescript\n * align: true // Aligned columns (default)\n * align: false // Compact, non-aligned output\n * ```\n *\n * @default `true` (alignment enabled)\n */\n readonly align?: boolean;\n\n /**\n * Configuration for structured value inspection and rendering.\n *\n * Controls how objects, arrays, and other complex values are displayed\n * within log messages. Uses Node.js `util.inspect()` style options.\n *\n * @example\n * ```typescript\n * inspectOptions: {\n * depth: 3, // Show 3 levels of nesting\n * colors: false, // Disable value syntax highlighting\n * compact: true, // Use compact object display\n * }\n * ```\n *\n * @default `{}` (use built-in defaults: depth=unlimited, colors=auto, compact=true)\n */\n readonly inspectOptions?: {\n /**\n * Maximum depth to traverse when inspecting nested objects.\n * @default Infinity (no depth limit)\n */\n readonly depth?: number;\n\n /**\n * Whether to use syntax highlighting colors for inspected values.\n * @default Inherited from global `colors` setting\n */\n readonly colors?: boolean;\n\n /**\n * Whether to use compact formatting for objects and arrays.\n * @default `true` (compact formatting)\n */\n readonly compact?: boolean;\n };\n\n /**\n * Enable word wrapping for long messages.\n *\n * When enabled, long messages will be wrapped at the specified width,\n * with continuation lines aligned to the message column position.\n *\n * - `true`: Auto-detect terminal width when attached to a terminal,\n * fallback to 80 columns when not in a terminal or detection fails\n * - `number`: Use the specified width in columns\n * - `false`: Disable word wrapping\n *\n * @example\n * ```typescript\n * // Auto-detect terminal width (recommended)\n * wordWrap: true\n *\n * // Custom wrap width\n * wordWrap: 120\n *\n * // Disable word wrapping (default)\n * wordWrap: false\n * ```\n *\n * @default `true` (auto-detect terminal width)\n * @since 1.0.0\n */\n readonly wordWrap?: boolean | number;\n}\n\n/**\n * Creates a beautiful console formatter optimized for local development.\n *\n * This formatter provides a Signale-inspired visual design with colorful icons,\n * smart category truncation, dimmed styling, and perfect column alignment.\n * It's specifically designed for development environments that support true colors\n * and Unicode characters.\n *\n * The formatter features:\n * - Emoji icons for each log level (🔍 trace, 🐛 debug, ✨ info, etc.)\n * - True color support with rich color schemes\n * - Intelligent category truncation for long hierarchical categories\n * - Optional timestamp display with multiple formats\n * - Configurable alignment and styling options\n * - Enhanced value rendering with syntax highlighting\n *\n * @param options Configuration options for customizing the formatter behavior.\n * @returns A text formatter function that can be used with LogTape sinks.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getConsoleSink } from \"@logtape/logtape/sink\";\n * import { getPrettyFormatter } from \"@logtape/pretty\";\n *\n * await configure({\n * sinks: {\n * console: getConsoleSink({\n * formatter: getPrettyFormatter({\n * timestamp: \"time\",\n * categoryWidth: 25,\n * icons: {\n * info: \"📘\",\n * error: \"🔥\"\n * }\n * })\n * })\n * }\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport function getPrettyFormatter(\n options: PrettyFormatterOptions = {},\n): TextFormatter {\n // Extract options with defaults\n const {\n timestamp = \"none\",\n timestampColor = \"rgb(100,116,139)\",\n timestampStyle = \"dim\",\n level: levelFormat = \"full\",\n levelColors = {},\n levelStyle = \"underline\",\n icons = true,\n categorySeparator = \"·\",\n categoryColor = \"rgb(100,116,139)\",\n categoryColorMap = new Map(),\n categoryStyle = [\"dim\", \"italic\"],\n categoryWidth = 20,\n categoryTruncate = \"middle\",\n messageColor = \"rgb(148,163,184)\",\n messageStyle = \"dim\",\n colors: useColors = true,\n align = true,\n inspectOptions = {},\n wordWrap = true,\n } = options;\n\n // Resolve icons\n const baseIconMap: Record<LogLevel, string> = icons === false\n ? { trace: \"\", debug: \"\", info: \"\", warning: \"\", error: \"\", fatal: \"\" }\n : icons === true\n ? defaultIcons\n : { ...defaultIcons, ...(icons as Partial<Record<LogLevel, string>>) };\n\n // Normalize icon spacing for consistent alignment\n const iconMap = normalizeIconSpacing(baseIconMap);\n\n // Resolve level colors with defaults\n const resolvedLevelColors: Record<LogLevel, Color> = {\n trace: defaultColors.trace,\n debug: defaultColors.debug,\n info: defaultColors.info,\n warning: defaultColors.warning,\n error: defaultColors.error,\n fatal: defaultColors.fatal,\n ...levelColors,\n };\n\n // Level formatter function with optimized mappings\n const levelMappings: Record<string, Record<LogLevel, string>> = {\n \"ABBR\": {\n trace: \"TRC\",\n debug: \"DBG\",\n info: \"INF\",\n warning: \"WRN\",\n error: \"ERR\",\n fatal: \"FTL\",\n },\n \"L\": {\n trace: \"T\",\n debug: \"D\",\n info: \"I\",\n warning: \"W\",\n error: \"E\",\n fatal: \"F\",\n },\n \"abbr\": {\n trace: \"trc\",\n debug: \"dbg\",\n info: \"inf\",\n warning: \"wrn\",\n error: \"err\",\n fatal: \"ftl\",\n },\n \"l\": {\n trace: \"t\",\n debug: \"d\",\n info: \"i\",\n warning: \"w\",\n error: \"e\",\n fatal: \"f\",\n },\n };\n\n const formatLevel = (level: LogLevel): string => {\n if (typeof levelFormat === \"function\") {\n return levelFormat(level);\n }\n\n if (levelFormat === \"FULL\") return level.toUpperCase();\n if (levelFormat === \"full\") return level;\n\n return levelMappings[levelFormat]?.[level] ?? level;\n };\n\n // Timestamp formatters lookup table\n const timestampFormatters: Record<string, (ts: number) => string> = {\n \"date-time-timezone\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \" +00:00\");\n },\n \"date-time-tz\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \" +00\");\n },\n \"date-time\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \"\");\n },\n \"time-timezone\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \" +00:00\");\n },\n \"time-tz\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \" +00\");\n },\n \"time\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \"\");\n },\n \"date\": (ts) => new Date(ts).toISOString().replace(/T.*/, \"\"),\n \"rfc3339\": (ts) => new Date(ts).toISOString(),\n };\n\n // Resolve timestamp formatter\n let timestampFn: ((ts: number) => string | null) | null = null;\n if (timestamp === \"none\" || timestamp === \"disabled\") {\n timestampFn = null;\n } else if (typeof timestamp === \"function\") {\n timestampFn = timestamp;\n } else {\n timestampFn = timestampFormatters[timestamp as string] ?? null;\n }\n\n // Configure word wrap settings\n const wordWrapEnabled = wordWrap !== false;\n let wordWrapWidth: number;\n\n if (typeof wordWrap === \"number\") {\n wordWrapWidth = wordWrap;\n } else if (wordWrap === true) {\n // Auto-detect terminal width\n wordWrapWidth = getOptimalWordWrapWidth(80);\n } else {\n wordWrapWidth = 80; // Default fallback\n }\n\n // Prepare category color patterns for matching\n const categoryPatterns = prepareCategoryPatterns(categoryColorMap);\n\n // Calculate level width based on format\n const allLevels: LogLevel[] = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warning\",\n \"error\",\n \"fatal\",\n ];\n const levelWidth = Math.max(...allLevels.map((l) => formatLevel(l).length));\n\n return (record: LogRecord): string => {\n // Calculate the prefix parts first to determine message column position\n const icon = iconMap[record.level] || \"\";\n const level = formatLevel(record.level);\n const categoryStr = truncateCategory(\n record.category,\n categoryWidth,\n categorySeparator,\n categoryTruncate,\n );\n\n // Format message with values - handle color reset/reapply for interpolated values\n let message = \"\";\n const messageColorCode = useColors ? colorToAnsi(messageColor) : \"\";\n const messageStyleCode = useColors ? styleToAnsi(messageStyle) : \"\";\n const messagePrefix = useColors\n ? `${messageStyleCode}${messageColorCode}`\n : \"\";\n\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n message += record.message[i];\n } else {\n const value = record.message[i];\n const inspected = inspect(value, {\n colors: useColors,\n ...inspectOptions,\n });\n\n // Handle multiline interpolated values properly\n if (inspected.includes(\"\\n\")) {\n const lines = inspected.split(\"\\n\");\n\n const formattedLines = lines.map((line, index) => {\n if (index === 0) {\n // First line: reset formatting, add the line, then reapply\n if (useColors && (messageColorCode || messageStyleCode)) {\n return `${RESET}${line}${messagePrefix}`;\n } else {\n return line;\n }\n } else {\n // Continuation lines: just apply formatting, let wrapText handle indentation\n if (useColors && (messageColorCode || messageStyleCode)) {\n return `${line}${messagePrefix}`;\n } else {\n return line;\n }\n }\n });\n message += formattedLines.join(\"\\n\");\n } else {\n // Single line - handle normally\n if (useColors && (messageColorCode || messageStyleCode)) {\n message += `${RESET}${inspected}${messagePrefix}`;\n } else {\n message += inspected;\n }\n }\n }\n }\n\n // Parts are already calculated above\n\n // Determine category color (with prefix matching)\n const finalCategoryColor = useColors\n ? (matchCategoryColor(record.category, categoryPatterns) || categoryColor)\n : null;\n\n // Apply colors and styling\n const formattedIcon = icon;\n let formattedLevel = level;\n let formattedCategory = categoryStr;\n let formattedMessage = message;\n let formattedTimestamp = \"\";\n\n if (useColors) {\n // Apply level color and style\n const levelColorCode = colorToAnsi(resolvedLevelColors[record.level]);\n const levelStyleCode = styleToAnsi(levelStyle);\n formattedLevel = `${levelStyleCode}${levelColorCode}${level}${RESET}`;\n\n // Apply category color and style (with prefix matching)\n const categoryColorCode = colorToAnsi(finalCategoryColor);\n const categoryStyleCode = styleToAnsi(categoryStyle);\n formattedCategory =\n `${categoryStyleCode}${categoryColorCode}${categoryStr}${RESET}`;\n\n // Apply message color and style (already handled in message building above)\n formattedMessage = `${messagePrefix}${message}${RESET}`;\n }\n\n // Format timestamp if needed\n if (timestampFn) {\n const ts = timestampFn(record.timestamp);\n if (ts !== null) {\n if (useColors) {\n const timestampColorCode = colorToAnsi(timestampColor);\n const timestampStyleCode = styleToAnsi(timestampStyle);\n formattedTimestamp =\n `${timestampStyleCode}${timestampColorCode}${ts}${RESET} `;\n } else {\n formattedTimestamp = `${ts} `;\n }\n }\n }\n\n // Build the final output with alignment\n if (align) {\n // Calculate padding accounting for ANSI escape sequences\n const levelColorLength = useColors\n ? (colorToAnsi(resolvedLevelColors[record.level]).length +\n styleToAnsi(levelStyle).length + RESET.length)\n : 0;\n const categoryColorLength = useColors\n ? (colorToAnsi(finalCategoryColor).length +\n styleToAnsi(categoryStyle).length + RESET.length)\n : 0;\n\n const paddedLevel = formattedLevel.padEnd(levelWidth + levelColorLength);\n const paddedCategory = formattedCategory.padEnd(\n categoryWidth + categoryColorLength,\n );\n\n let result =\n `${formattedTimestamp}${formattedIcon} ${paddedLevel} ${paddedCategory} ${formattedMessage}`;\n\n // Apply word wrapping if enabled, or if there are multiline interpolated values\n if (wordWrapEnabled || message.includes(\"\\n\")) {\n result = wrapText(\n result,\n wordWrapEnabled ? wordWrapWidth : Infinity,\n message,\n );\n }\n\n return result + \"\\n\";\n } else {\n let result =\n `${formattedTimestamp}${formattedIcon} ${formattedLevel} ${formattedCategory} ${formattedMessage}`;\n\n // Apply word wrapping if enabled, or if there are multiline interpolated values\n if (wordWrapEnabled || message.includes(\"\\n\")) {\n result = wrapText(\n result,\n wordWrapEnabled ? wordWrapWidth : Infinity,\n message,\n );\n }\n\n return result + \"\\n\";\n }\n };\n}\n\n/**\n * A pre-configured beautiful console formatter for local development.\n *\n * This is a ready-to-use instance of the pretty formatter with sensible defaults\n * for most development scenarios. It provides immediate visual enhancement to\n * your logs without requiring any configuration.\n *\n * Features enabled by default:\n * - Emoji icons for all log levels\n * - True color support with rich color schemes\n * - Dimmed text styling for better readability\n * - Smart category truncation (20 characters max)\n * - Perfect column alignment\n * - No timestamp display (cleaner for development)\n *\n * For custom configuration, use {@link getPrettyFormatter} instead.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getConsoleSink } from \"@logtape/logtape/sink\";\n * import { prettyFormatter } from \"@logtape/pretty\";\n *\n * await configure({\n * sinks: {\n * console: getConsoleSink({\n * formatter: prettyFormatter\n * })\n * }\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport const prettyFormatter: TextFormatter = getPrettyFormatter();\n"],"mappings":";;;;;;;;;;AAeA,MAAM,QAAQ;AACd,MAAM,MAAM;AAGZ,MAAM,gBAAgB;CACpB,OAAO;CACP,OAAO;CACP,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,UAAU;CACV,SAAS;CACT,WAAW;AACZ;;;;AAKD,MAAM,SAAS;CACb,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACR,WAAW;CACX,eAAe;AAChB;;;;AAKD,MAAM,aAAa;CACjB,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;AACR;AA4CD,MAAM,cAAc;AACpB,MAAM,cAAc;;;;AAKpB,SAAS,YAAYA,OAAsB;AACzC,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,SAAS,WACX,QAAO,WAAW;CAIpB,MAAM,WAAW,MAAM,MAAM,YAAY;AACzC,KAAI,UAAU;EACZ,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG;AACpB,UAAQ,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE;CACjC;CAGD,MAAM,WAAW,MAAM,MAAM,YAAY;AACzC,KAAI,UAAU;EACZ,IAAI,MAAM,SAAS;AAEnB,MAAI,IAAI,WAAW,EACjB,OAAM,IAAI,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAA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,YACpB,YAAY,oBAAoB,OAAO,OAAO,CAAC,SAChD,YAAY,WAAW,CAAC,SAAS,MAAM,SACvC;GACJ,MAAM,sBAAsB,YACvB,YAAY,mBAAmB,CAAC,SACjC,YAAY,cAAc,CAAC,SAAS,MAAM,SAC1C;GAEJ,MAAM,cAAc,eAAe,OAAO,aAAa,iBAAiB;GACxE,MAAM,iBAAiB,kBAAkB,OACvC,gBAAgB,oBACjB;GAED,IAAI,UACD,EAAE,mBAAmB,EAAE,cAAc,GAAG,YAAY,GAAG,eAAe,GAAG,iBAAiB;AAG7F,OAAI,mBAAmB,QAAQ,SAAS,KAAK,CAC3C,UAAS,SACP,QACA,kBAAkB,gBAAgB,UAClC,QACD;AAGH,UAAO,SAAS;EACjB,OAAM;GACL,IAAI,UACD,EAAE,mBAAmB,EAAE,cAAc,GAAG,eAAe,GAAG,kBAAkB,GAAG,iBAAiB;AAGnG,OAAI,mBAAmB,QAAQ,SAAS,KAAK,CAC3C,UAAS,SACP,QACA,kBAAkB,gBAAgB,UAClC,QACD;AAGH,UAAO,SAAS;EACjB;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCD,MAAaC,kBAAiC,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"formatter.js","names":["color: Color","style: Style","categoryColorMap: CategoryColorMap","patterns: CategoryPattern[]","category: readonly string[]","prefix: readonly string[]","defaultIcons: Record<LogLevel, string>","iconMap: Record<LogLevel, string>","options: PrettyFormatterOptions","baseIconMap: Record<LogLevel, string>","resolvedLevelColors: Record<LogLevel, Color>","levelMappings: Record<string, Record<LogLevel, string>>","level: LogLevel","timestampFormatters: Record<string, (ts: number) => string>","timestampFn: ((ts: number) => string | null) | null","wordWrapWidth: number","allLevels: LogLevel[]","record: LogRecord","prettyFormatter: TextFormatter"],"sources":["../formatter.ts"],"sourcesContent":["import type {\n LogLevel,\n LogRecord,\n TextFormatter,\n TextFormatterOptions,\n} from \"@logtape/logtape\";\nimport { inspect } from \"#util\";\nimport { getOptimalWordWrapWidth } from \"./terminal.ts\";\nimport { truncateCategory, type TruncationStrategy } from \"./truncate.ts\";\nimport { getDisplayWidth } from \"./wcwidth.ts\";\nimport { wrapText } from \"./wordwrap.ts\";\n\n/**\n * ANSI escape codes for styling\n */\nconst RESET = \"\\x1b[0m\";\nconst DIM = \"\\x1b[2m\";\n\n// Default true color values (referenced in JSDoc)\nconst defaultColors = {\n trace: \"rgb(167,139,250)\", // Light purple\n debug: \"rgb(96,165,250)\", // Light blue\n info: \"rgb(52,211,153)\", // Emerald\n warning: \"rgb(251,191,36)\", // Amber\n error: \"rgb(248,113,113)\", // Light red\n fatal: \"rgb(220,38,38)\", // Dark red\n category: \"rgb(100,116,139)\", // Slate\n message: \"rgb(148,163,184)\", // Light slate\n timestamp: \"rgb(100,116,139)\", // Slate\n} as const;\n\n/**\n * ANSI style codes\n */\nconst styles = {\n reset: RESET,\n bold: \"\\x1b[1m\",\n dim: DIM,\n italic: \"\\x1b[3m\",\n underline: \"\\x1b[4m\",\n strikethrough: \"\\x1b[9m\",\n} as const;\n\n/**\n * Standard ANSI colors (16-color)\n */\nconst ansiColors = {\n black: \"\\x1b[30m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n white: \"\\x1b[37m\",\n} as const;\n\n/**\n * Color type definition\n */\nexport type Color =\n | keyof typeof ansiColors\n | `rgb(${number},${number},${number})`\n | `#${string}`\n | null;\n\n/**\n * Category color mapping for prefix-based coloring.\n *\n * Maps category prefixes (as arrays) to colors. The formatter will match\n * categories against these prefixes and use the corresponding color.\n * Longer/more specific prefixes take precedence over shorter ones.\n *\n * @example\n * ```typescript\n * new Map([\n * [[\"app\", \"auth\"], \"#ff6b6b\"], // app.auth.* -> red\n * [[\"app\", \"db\"], \"#4ecdc4\"], // app.db.* -> teal\n * [[\"app\"], \"#45b7d1\"], // app.* (fallback) -> blue\n * [[\"lib\"], \"#96ceb4\"], // lib.* -> green\n * ])\n * ```\n */\nexport type CategoryColorMap = Map<readonly string[], Color>;\n\n/**\n * Internal representation of category prefix patterns\n */\ntype CategoryPattern = {\n prefix: readonly string[];\n color: Color;\n};\n\n/**\n * Style type definition - supports single styles, arrays of styles, or null\n */\nexport type Style = keyof typeof styles | (keyof typeof styles)[] | null;\n\n// Pre-compiled regex patterns for color parsing\nconst RGB_PATTERN = /^rgb\\((\\d+),(\\d+),(\\d+)\\)$/;\nconst HEX_PATTERN = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\n\n/**\n * Helper function to convert color to ANSI escape code\n */\nfunction colorToAnsi(color: Color): string {\n if (color === null) return \"\";\n if (color in ansiColors) {\n return ansiColors[color as keyof typeof ansiColors];\n }\n\n // Handle rgb() format\n const rgbMatch = color.match(RGB_PATTERN);\n if (rgbMatch) {\n const [, r, g, b] = rgbMatch;\n return `\\x1b[38;2;${r};${g};${b}m`;\n }\n\n // Handle hex format (#rrggbb or #rgb)\n const hexMatch = color.match(HEX_PATTERN);\n if (hexMatch) {\n let hex = hexMatch[1];\n // Convert 3-digit hex to 6-digit\n if (hex.length === 3) {\n hex = hex.split(\"\").map((c) => c + c).join(\"\");\n }\n const r = parseInt(hex.substr(0, 2), 16);\n const g = parseInt(hex.substr(2, 2), 16);\n const b = parseInt(hex.substr(4, 2), 16);\n return `\\x1b[38;2;${r};${g};${b}m`;\n }\n\n return \"\";\n}\n\n/**\n * Helper function to convert style to ANSI escape code\n */\nfunction styleToAnsi(style: Style): string {\n if (style === null) return \"\";\n if (Array.isArray(style)) {\n return style.map((s) => styles[s] || \"\").join(\"\");\n }\n return styles[style] || \"\";\n}\n\n/**\n * Converts a category color map to internal patterns and sorts them by specificity.\n * More specific (longer) prefixes come first for proper matching precedence.\n */\nfunction prepareCategoryPatterns(\n categoryColorMap: CategoryColorMap,\n): CategoryPattern[] {\n const patterns: CategoryPattern[] = [];\n\n for (const [prefix, color] of categoryColorMap) {\n patterns.push({ prefix, color });\n }\n\n // Sort by prefix length (descending) for most-specific-first matching\n return patterns.sort((a, b) => b.prefix.length - a.prefix.length);\n}\n\n/**\n * Matches a category against category color patterns.\n * Returns the color of the first matching pattern, or null if no match.\n */\nfunction matchCategoryColor(\n category: readonly string[],\n patterns: CategoryPattern[],\n): Color {\n for (const pattern of patterns) {\n if (categoryMatches(category, pattern.prefix)) {\n return pattern.color;\n }\n }\n return null;\n}\n\n/**\n * Checks if a category matches a prefix pattern.\n * A category matches if it starts with all segments of the prefix.\n */\nfunction categoryMatches(\n category: readonly string[],\n prefix: readonly string[],\n): boolean {\n if (prefix.length > category.length) {\n return false;\n }\n\n for (let i = 0; i < prefix.length; i++) {\n if (category[i] !== prefix[i]) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Default icons for each log level\n */\nconst defaultIcons: Record<LogLevel, string> = {\n trace: \"🔍\",\n debug: \"🐛\",\n info: \"✨\",\n warning: \"⚡\",\n error: \"❌\",\n fatal: \"💀\",\n};\n\n/**\n * Normalize icon spacing to ensure consistent column alignment.\n *\n * All icons will be padded with spaces to match the width of the widest icon,\n * ensuring consistent prefix alignment across all log levels.\n *\n * @param iconMap The icon mapping to normalize\n * @returns A new icon map with consistent spacing\n */\nfunction normalizeIconSpacing(\n iconMap: Record<LogLevel, string>,\n): Record<LogLevel, string> {\n const entries = Object.entries(iconMap) as Array<[LogLevel, string]>;\n const maxWidth = Math.max(\n ...entries.map(([, icon]) => getDisplayWidth(icon)),\n );\n\n return Object.fromEntries(\n entries.map(([level, icon]) => [\n level,\n icon + \" \".repeat(maxWidth - getDisplayWidth(icon)),\n ]),\n ) as Record<LogLevel, string>;\n}\n\n/**\n * Configuration options for the pretty formatter.\n *\n * This interface extends the base text formatter options while providing\n * extensive customization options for visual styling, layout control, and\n * development-focused features. It offers granular control over colors,\n * styles, and formatting similar to the ANSI color formatter.\n *\n * @since 1.0.0\n */\nexport interface PrettyFormatterOptions\n extends Omit<TextFormatterOptions, \"category\" | \"value\" | \"format\"> {\n /**\n * Color for timestamp display when timestamps are enabled.\n *\n * Supports true color RGB values, hex colors, or ANSI color names.\n * Set to `null` to disable timestamp coloring.\n *\n * @example\n * ```typescript\n * timestampColor: \"#888888\" // Hex color\n * timestampColor: \"rgb(128,128,128)\" // RGB color\n * timestampColor: \"cyan\" // ANSI color name\n * timestampColor: null // No color\n * ```\n *\n * @default `\"rgb(100,116,139)\"` (slate gray)\n */\n readonly timestampColor?: Color;\n\n /**\n * Visual style applied to timestamp text.\n *\n * Controls text appearance like boldness, dimming, etc.\n * Supports single styles, multiple styles combined, or no styling.\n * Combines with `timestampColor` for full styling control.\n *\n * @example\n * ```typescript\n * timestampStyle: \"dim\" // Single style: dimmed text\n * timestampStyle: \"bold\" // Single style: bold text\n * timestampStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * timestampStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * timestampStyle: null // No styling\n * ```\n *\n * @default `\"dim\"`\n */\n readonly timestampStyle?: Style;\n\n /**\n * Custom colors for each log level.\n *\n * Allows fine-grained control over level appearance. Each level can have\n * its own color scheme. Unspecified levels use built-in defaults.\n * Set individual levels to `null` to disable coloring for that level.\n *\n * @example\n * ```typescript\n * levelColors: {\n * info: \"#00ff00\", // Bright green for info\n * error: \"#ff0000\", // Bright red for errors\n * warning: \"orange\", // ANSI orange for warnings\n * debug: null, // No color for debug\n * }\n * ```\n *\n * @default Built-in color scheme (purple trace, blue debug, green info, amber warning, red error, dark red fatal)\n */\n readonly levelColors?: Partial<Record<LogLevel, Color>>;\n\n /**\n * Visual style applied to log level text.\n *\n * Controls the appearance of the level indicator (e.g., \"info\", \"error\").\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to level-specific colors.\n *\n * @example\n * ```typescript\n * levelStyle: \"bold\" // Single style: bold level text\n * levelStyle: \"underline\" // Single style: underlined level text\n * levelStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * levelStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * levelStyle: null // No additional styling\n * ```\n *\n * @default `\"underline\"`\n */\n readonly levelStyle?: Style;\n\n /**\n * Icon configuration for each log level.\n *\n * Controls the emoji/symbol displayed before each log entry.\n * Provides visual quick-identification of log severity.\n *\n * - `true`: Use built-in emoji set (🔍 trace, 🐛 debug, ✨ info, ⚠️ warning, ❌ error, 💀 fatal)\n * - `false`: Disable all icons for clean text-only output\n * - Object: Custom icon mapping, falls back to defaults for unspecified levels\n *\n * @example\n * ```typescript\n * icons: true // Use default emoji set\n * icons: false // No icons\n * icons: {\n * info: \"ℹ️\", // Custom info icon\n * error: \"🔥\", // Custom error icon\n * warning: \"⚡\", // Custom warning icon\n * }\n * ```\n *\n * @default `true` (use default emoji icons)\n */\n readonly icons?: boolean | Partial<Record<LogLevel, string>>;\n\n /**\n * Character(s) used to separate category hierarchy levels.\n *\n * Categories are hierarchical (e.g., [\"app\", \"auth\", \"jwt\"]) and this\n * separator joins them for display (e.g., \"app.auth.jwt\").\n *\n * @example\n * ```typescript\n * categorySeparator: \"·\" // app·auth·jwt\n * categorySeparator: \".\" // app.auth.jwt\n * categorySeparator: \":\" // app:auth:jwt\n * categorySeparator: \" > \" // app > auth > jwt\n * categorySeparator: \"::\" // app::auth::jwt\n * ```\n *\n * @default `\"·\"` (interpunct)\n */\n readonly categorySeparator?: string;\n\n /**\n * Default color for category display.\n *\n * Used as fallback when no specific color is found in `categoryColorMap`.\n * Controls the visual appearance of the category hierarchy display.\n *\n * @example\n * ```typescript\n * categoryColor: \"#666666\" // Gray categories\n * categoryColor: \"blue\" // Blue categories\n * categoryColor: \"rgb(100,150,200)\" // Light blue categories\n * categoryColor: null // No coloring\n * ```\n *\n * @default `\"rgb(100,116,139)\"` (slate gray)\n */\n readonly categoryColor?: Color;\n\n /**\n * Category-specific color mapping based on prefixes.\n *\n * Maps category prefixes (as arrays) to colors for visual grouping.\n * More specific (longer) prefixes take precedence over shorter ones.\n * If no prefix matches, falls back to the default `categoryColor`.\n *\n * @example\n * ```typescript\n * new Map([\n * [[\"app\", \"auth\"], \"#ff6b6b\"], // app.auth.* -> red\n * [[\"app\", \"db\"], \"#4ecdc4\"], // app.db.* -> teal\n * [[\"app\"], \"#45b7d1\"], // app.* (fallback) -> blue\n * [[\"lib\"], \"#96ceb4\"], // lib.* -> green\n * ])\n * ```\n */\n readonly categoryColorMap?: CategoryColorMap;\n\n /**\n * Visual style applied to category text.\n *\n * Controls the appearance of the category hierarchy display.\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to category colors from `categoryColor` or `categoryColorMap`.\n *\n * @example\n * ```typescript\n * categoryStyle: \"dim\" // Single style: dimmed category text\n * categoryStyle: \"italic\" // Single style: italic category text\n * categoryStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * categoryStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * categoryStyle: null // No additional styling\n * ```\n *\n * @default `[\"dim\", \"italic\"]` (dimmed for subtle appearance)\n */\n readonly categoryStyle?: Style;\n\n /**\n * Maximum display width for category names.\n *\n * Controls layout consistency by limiting category width.\n * Long categories are truncated according to `categoryTruncate` strategy.\n *\n * @default `20`\n */\n readonly categoryWidth?: number;\n\n /**\n * Strategy for truncating long category names.\n *\n * When categories exceed `categoryWidth`, this controls how truncation works.\n * Smart truncation preserves important context while maintaining layout.\n *\n * - `\"middle\"`: Keep first and last parts (e.g., \"app.server…auth.jwt\")\n * - `\"end\"`: Truncate at the end (e.g., \"app.server.middleware…\")\n * - `false`: No truncation (ignores `categoryWidth`)\n *\n * @example\n * ```typescript\n * categoryTruncate: \"middle\" // app.server…jwt (preserves context)\n * categoryTruncate: \"end\" // app.server.midd… (linear truncation)\n * categoryTruncate: false // app.server.middleware.auth.jwt (full)\n * ```\n *\n * @default `\"middle\"` (smart context-preserving truncation)\n */\n readonly categoryTruncate?: TruncationStrategy;\n\n /**\n * Color for log message text content.\n *\n * Controls the visual appearance of the actual log message content.\n * Does not affect structured values, which use syntax highlighting.\n *\n * @example\n * ```typescript\n * messageColor: \"#ffffff\" // White message text\n * messageColor: \"green\" // Green message text\n * messageColor: \"rgb(200,200,200)\" // Light gray message text\n * messageColor: null // No coloring\n * ```\n *\n * @default `\"rgb(148,163,184)\"` (light slate gray)\n */\n readonly messageColor?: Color;\n\n /**\n * Visual style applied to log message text.\n *\n * Controls the appearance of the log message content.\n * Supports single styles, multiple styles combined, or no styling.\n * Applied in addition to `messageColor`.\n *\n * @example\n * ```typescript\n * messageStyle: \"dim\" // Single style: dimmed message text\n * messageStyle: \"italic\" // Single style: italic message text\n * messageStyle: [\"dim\", \"italic\"] // Multiple styles: dimmed + italic\n * messageStyle: [\"bold\", \"underline\"] // Multiple styles: bold + underlined\n * messageStyle: null // No additional styling\n * ```\n *\n * @default `\"dim\"` (dimmed for subtle readability)\n */\n readonly messageStyle?: Style;\n\n /**\n * Global color control for the entire formatter.\n *\n * Master switch to enable/disable all color output.\n * When disabled, produces clean monochrome output suitable for\n * non-color terminals or when colors are not desired.\n *\n * @example\n * ```typescript\n * colors: true // Full color output (default)\n * colors: false // Monochrome output only\n * ```\n *\n * @default `true` (colors enabled)\n */\n readonly colors?: boolean;\n\n /**\n * Column alignment for consistent visual layout.\n *\n * When enabled, ensures all log components (icons, levels, categories)\n * align consistently across multiple log entries, creating a clean\n * tabular appearance.\n *\n * @example\n * ```typescript\n * align: true // Aligned columns (default)\n * align: false // Compact, non-aligned output\n * ```\n *\n * @default `true` (alignment enabled)\n */\n readonly align?: boolean;\n\n /**\n * Configuration for structured value inspection and rendering.\n *\n * Controls how objects, arrays, and other complex values are displayed\n * within log messages. Uses Node.js `util.inspect()` style options.\n *\n * @example\n * ```typescript\n * inspectOptions: {\n * depth: 3, // Show 3 levels of nesting\n * colors: false, // Disable value syntax highlighting\n * compact: true, // Use compact object display\n * }\n * ```\n *\n * @default `{}` (use built-in defaults: depth=unlimited, colors=auto, compact=true)\n */\n readonly inspectOptions?: {\n /**\n * Maximum depth to traverse when inspecting nested objects.\n * @default Infinity (no depth limit)\n */\n readonly depth?: number;\n\n /**\n * Whether to use syntax highlighting colors for inspected values.\n * @default Inherited from global `colors` setting\n */\n readonly colors?: boolean;\n\n /**\n * Whether to use compact formatting for objects and arrays.\n * @default `true` (compact formatting)\n */\n readonly compact?: boolean;\n };\n\n /**\n * Enable word wrapping for long messages.\n *\n * When enabled, long messages will be wrapped at the specified width,\n * with continuation lines aligned to the message column position.\n *\n * - `true`: Auto-detect terminal width when attached to a terminal,\n * fallback to 80 columns when not in a terminal or detection fails\n * - `number`: Use the specified width in columns\n * - `false`: Disable word wrapping\n *\n * @example\n * ```typescript\n * // Auto-detect terminal width (recommended)\n * wordWrap: true\n *\n * // Custom wrap width\n * wordWrap: 120\n *\n * // Disable word wrapping (default)\n * wordWrap: false\n * ```\n *\n * @default `true` (auto-detect terminal width)\n * @since 1.0.0\n */\n readonly wordWrap?: boolean | number;\n}\n\n/**\n * Creates a beautiful console formatter optimized for local development.\n *\n * This formatter provides a Signale-inspired visual design with colorful icons,\n * smart category truncation, dimmed styling, and perfect column alignment.\n * It's specifically designed for development environments that support true colors\n * and Unicode characters.\n *\n * The formatter features:\n * - Emoji icons for each log level (🔍 trace, 🐛 debug, ✨ info, etc.)\n * - True color support with rich color schemes\n * - Intelligent category truncation for long hierarchical categories\n * - Optional timestamp display with multiple formats\n * - Configurable alignment and styling options\n * - Enhanced value rendering with syntax highlighting\n *\n * @param options Configuration options for customizing the formatter behavior.\n * @returns A text formatter function that can be used with LogTape sinks.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getConsoleSink } from \"@logtape/logtape/sink\";\n * import { getPrettyFormatter } from \"@logtape/pretty\";\n *\n * await configure({\n * sinks: {\n * console: getConsoleSink({\n * formatter: getPrettyFormatter({\n * timestamp: \"time\",\n * categoryWidth: 25,\n * icons: {\n * info: \"📘\",\n * error: \"🔥\"\n * }\n * })\n * })\n * }\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport function getPrettyFormatter(\n options: PrettyFormatterOptions = {},\n): TextFormatter {\n // Extract options with defaults\n const {\n timestamp = \"none\",\n timestampColor = \"rgb(100,116,139)\",\n timestampStyle = \"dim\",\n level: levelFormat = \"full\",\n levelColors = {},\n levelStyle = \"underline\",\n icons = true,\n categorySeparator = \"·\",\n categoryColor = \"rgb(100,116,139)\",\n categoryColorMap = new Map(),\n categoryStyle = [\"dim\", \"italic\"],\n categoryWidth = 20,\n categoryTruncate = \"middle\",\n messageColor = \"rgb(148,163,184)\",\n messageStyle = \"dim\",\n colors: useColors = true,\n align = true,\n inspectOptions = {},\n wordWrap = true,\n } = options;\n\n // Resolve icons\n const baseIconMap: Record<LogLevel, string> = icons === false\n ? { trace: \"\", debug: \"\", info: \"\", warning: \"\", error: \"\", fatal: \"\" }\n : icons === true\n ? defaultIcons\n : { ...defaultIcons, ...(icons as Partial<Record<LogLevel, string>>) };\n\n // Normalize icon spacing for consistent alignment\n const iconMap = normalizeIconSpacing(baseIconMap);\n\n // Resolve level colors with defaults\n const resolvedLevelColors: Record<LogLevel, Color> = {\n trace: defaultColors.trace,\n debug: defaultColors.debug,\n info: defaultColors.info,\n warning: defaultColors.warning,\n error: defaultColors.error,\n fatal: defaultColors.fatal,\n ...levelColors,\n };\n\n // Level formatter function with optimized mappings\n const levelMappings: Record<string, Record<LogLevel, string>> = {\n \"ABBR\": {\n trace: \"TRC\",\n debug: \"DBG\",\n info: \"INF\",\n warning: \"WRN\",\n error: \"ERR\",\n fatal: \"FTL\",\n },\n \"L\": {\n trace: \"T\",\n debug: \"D\",\n info: \"I\",\n warning: \"W\",\n error: \"E\",\n fatal: \"F\",\n },\n \"abbr\": {\n trace: \"trc\",\n debug: \"dbg\",\n info: \"inf\",\n warning: \"wrn\",\n error: \"err\",\n fatal: \"ftl\",\n },\n \"l\": {\n trace: \"t\",\n debug: \"d\",\n info: \"i\",\n warning: \"w\",\n error: \"e\",\n fatal: \"f\",\n },\n };\n\n const formatLevel = (level: LogLevel): string => {\n if (typeof levelFormat === \"function\") {\n return levelFormat(level);\n }\n\n if (levelFormat === \"FULL\") return level.toUpperCase();\n if (levelFormat === \"full\") return level;\n\n return levelMappings[levelFormat]?.[level] ?? level;\n };\n\n // Timestamp formatters lookup table\n const timestampFormatters: Record<string, (ts: number) => string> = {\n \"date-time-timezone\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \" +00:00\");\n },\n \"date-time-tz\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \" +00\");\n },\n \"date-time\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(\"T\", \" \").replace(\"Z\", \"\");\n },\n \"time-timezone\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \" +00:00\");\n },\n \"time-tz\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \" +00\");\n },\n \"time\": (ts) => {\n const iso = new Date(ts).toISOString();\n return iso.replace(/.*T/, \"\").replace(\"Z\", \"\");\n },\n \"date\": (ts) => new Date(ts).toISOString().replace(/T.*/, \"\"),\n \"rfc3339\": (ts) => new Date(ts).toISOString(),\n };\n\n // Resolve timestamp formatter\n let timestampFn: ((ts: number) => string | null) | null = null;\n if (timestamp === \"none\" || timestamp === \"disabled\") {\n timestampFn = null;\n } else if (typeof timestamp === \"function\") {\n timestampFn = timestamp;\n } else {\n timestampFn = timestampFormatters[timestamp as string] ?? null;\n }\n\n // Configure word wrap settings\n const wordWrapEnabled = wordWrap !== false;\n let wordWrapWidth: number;\n\n if (typeof wordWrap === \"number\") {\n wordWrapWidth = wordWrap;\n } else if (wordWrap === true) {\n // Auto-detect terminal width\n wordWrapWidth = getOptimalWordWrapWidth(80);\n } else {\n wordWrapWidth = 80; // Default fallback\n }\n\n // Prepare category color patterns for matching\n const categoryPatterns = prepareCategoryPatterns(categoryColorMap);\n\n // Calculate level width based on format\n const allLevels: LogLevel[] = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warning\",\n \"error\",\n \"fatal\",\n ];\n const levelWidth = Math.max(...allLevels.map((l) => formatLevel(l).length));\n\n return (record: LogRecord): string => {\n // Calculate the prefix parts first to determine message column position\n const icon = iconMap[record.level] || \"\";\n const level = formatLevel(record.level);\n const categoryStr = truncateCategory(\n record.category,\n categoryWidth,\n categorySeparator,\n categoryTruncate,\n );\n\n // Format message with values - handle color reset/reapply for interpolated values\n let message = \"\";\n const messageColorCode = useColors ? colorToAnsi(messageColor) : \"\";\n const messageStyleCode = useColors ? styleToAnsi(messageStyle) : \"\";\n const messagePrefix = useColors\n ? `${messageStyleCode}${messageColorCode}`\n : \"\";\n\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n message += record.message[i];\n } else {\n const value = record.message[i];\n const inspected = inspect(value, {\n colors: useColors,\n ...inspectOptions,\n });\n\n // Handle multiline interpolated values properly\n if (inspected.includes(\"\\n\")) {\n const lines = inspected.split(\"\\n\");\n\n const formattedLines = lines.map((line, index) => {\n if (index === 0) {\n // First line: reset formatting, add the line, then reapply\n if (useColors && (messageColorCode || messageStyleCode)) {\n return `${RESET}${line}${messagePrefix}`;\n } else {\n return line;\n }\n } else {\n // Continuation lines: just apply formatting, let wrapText handle indentation\n if (useColors && (messageColorCode || messageStyleCode)) {\n return `${line}${messagePrefix}`;\n } else {\n return line;\n }\n }\n });\n message += formattedLines.join(\"\\n\");\n } else {\n // Single line - handle normally\n if (useColors && (messageColorCode || messageStyleCode)) {\n message += `${RESET}${inspected}${messagePrefix}`;\n } else {\n message += inspected;\n }\n }\n }\n }\n\n // Parts are already calculated above\n\n // Determine category color (with prefix matching)\n const finalCategoryColor = useColors\n ? (matchCategoryColor(record.category, categoryPatterns) || categoryColor)\n : null;\n\n // Apply colors and styling\n const formattedIcon = icon;\n let formattedLevel = level;\n let formattedCategory = categoryStr;\n let formattedMessage = message;\n let formattedTimestamp = \"\";\n\n if (useColors) {\n // Apply level color and style\n const levelColorCode = colorToAnsi(resolvedLevelColors[record.level]);\n const levelStyleCode = styleToAnsi(levelStyle);\n formattedLevel = `${levelStyleCode}${levelColorCode}${level}${RESET}`;\n\n // Apply category color and style (with prefix matching)\n const categoryColorCode = colorToAnsi(finalCategoryColor);\n const categoryStyleCode = styleToAnsi(categoryStyle);\n formattedCategory =\n `${categoryStyleCode}${categoryColorCode}${categoryStr}${RESET}`;\n\n // Apply message color and style (already handled in message building above)\n formattedMessage = `${messagePrefix}${message}${RESET}`;\n }\n\n // Format timestamp if needed\n if (timestampFn) {\n const ts = timestampFn(record.timestamp);\n if (ts !== null) {\n if (useColors) {\n const timestampColorCode = colorToAnsi(timestampColor);\n const timestampStyleCode = styleToAnsi(timestampStyle);\n formattedTimestamp =\n `${timestampStyleCode}${timestampColorCode}${ts}${RESET} `;\n } else {\n formattedTimestamp = `${ts} `;\n }\n }\n }\n\n // Build the final output with alignment\n if (align) {\n // Calculate padding accounting for ANSI escape sequences\n const levelColorLength = useColors\n ? (colorToAnsi(resolvedLevelColors[record.level]).length +\n styleToAnsi(levelStyle).length + RESET.length)\n : 0;\n const categoryColorLength = useColors\n ? (colorToAnsi(finalCategoryColor).length +\n styleToAnsi(categoryStyle).length + RESET.length)\n : 0;\n\n const paddedLevel = formattedLevel.padEnd(levelWidth + levelColorLength);\n const paddedCategory = formattedCategory.padEnd(\n categoryWidth + categoryColorLength,\n );\n\n let result =\n `${formattedTimestamp}${formattedIcon} ${paddedLevel} ${paddedCategory} ${formattedMessage}`;\n\n // Apply word wrapping if enabled, or if there are multiline interpolated values\n if (wordWrapEnabled || message.includes(\"\\n\")) {\n result = wrapText(\n result,\n wordWrapEnabled ? wordWrapWidth : Infinity,\n message,\n );\n }\n\n return result + \"\\n\";\n } else {\n let result =\n `${formattedTimestamp}${formattedIcon} ${formattedLevel} ${formattedCategory} ${formattedMessage}`;\n\n // Apply word wrapping if enabled, or if there are multiline interpolated values\n if (wordWrapEnabled || message.includes(\"\\n\")) {\n result = wrapText(\n result,\n wordWrapEnabled ? wordWrapWidth : Infinity,\n message,\n );\n }\n\n return result + \"\\n\";\n }\n };\n}\n\n/**\n * A pre-configured beautiful console formatter for local development.\n *\n * This is a ready-to-use instance of the pretty formatter with sensible defaults\n * for most development scenarios. It provides immediate visual enhancement to\n * your logs without requiring any configuration.\n *\n * Features enabled by default:\n * - Emoji icons for all log levels\n * - True color support with rich color schemes\n * - Dimmed text styling for better readability\n * - Smart category truncation (20 characters max)\n * - Perfect column alignment\n * - No timestamp display (cleaner for development)\n *\n * For custom configuration, use {@link getPrettyFormatter} instead.\n *\n * @example\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getConsoleSink } from \"@logtape/logtape/sink\";\n * import { prettyFormatter } from \"@logtape/pretty\";\n *\n * await configure({\n * sinks: {\n * console: getConsoleSink({\n * formatter: prettyFormatter\n * })\n * }\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport const prettyFormatter: TextFormatter = getPrettyFormatter();\n"],"mappings":";;;;;;;;;;AAeA,MAAM,QAAQ;AACd,MAAM,MAAM;AAGZ,MAAM,gBAAgB;CACpB,OAAO;CACP,OAAO;CACP,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,UAAU;CACV,SAAS;CACT,WAAW;AACZ;;;;AAKD,MAAM,SAAS;CACb,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACR,WAAW;CACX,eAAe;AAChB;;;;AAKD,MAAM,aAAa;CACjB,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;AACR;AA4CD,MAAM,cAAc;AACpB,MAAM,cAAc;;;;AAKpB,SAAS,YAAYA,OAAsB;AACzC,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,SAAS,WACX,QAAO,WAAW;CAIpB,MAAM,WAAW,MAAM,MAAM,YA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MAAM;GAC3D,MACC,uBAAsB,EAAE,GAAG;EAGhC;AAGD,MAAI,OAAO;GAET,MAAM,mBAAmB,YACpB,YAAY,oBAAoB,OAAO,OAAO,CAAC,SAChD,YAAY,WAAW,CAAC,SAAS,MAAM,SACvC;GACJ,MAAM,sBAAsB,YACvB,YAAY,mBAAmB,CAAC,SACjC,YAAY,cAAc,CAAC,SAAS,MAAM,SAC1C;GAEJ,MAAM,cAAc,eAAe,OAAO,aAAa,iBAAiB;GACxE,MAAM,iBAAiB,kBAAkB,OACvC,gBAAgB,oBACjB;GAED,IAAI,UACD,EAAE,mBAAmB,EAAE,cAAc,GAAG,YAAY,GAAG,eAAe,GAAG,iBAAiB;AAG7F,OAAI,mBAAmB,QAAQ,SAAS,KAAK,CAC3C,UAAS,SACP,QACA,kBAAkB,gBAAgB,UAClC,QACD;AAGH,UAAO,SAAS;EACjB,OAAM;GACL,IAAI,UACD,EAAE,mBAAmB,EAAE,cAAc,GAAG,eAAe,GAAG,kBAAkB,GAAG,iBAAiB;AAGnG,OAAI,mBAAmB,QAAQ,SAAS,KAAK,CAC3C,UAAS,SACP,QACA,kBAAkB,gBAAgB,UAClC,QACD;AAGH,UAAO,SAAS;EACjB;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCD,MAAaC,kBAAiC,oBAAoB"}
|
package/dist/terminal.cjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const node_process = require_rolldown_runtime.__toESM(require("node:process"));
|
|
3
1
|
|
|
4
2
|
//#region terminal.ts
|
|
5
3
|
/**
|
|
@@ -19,7 +17,7 @@ function isTerminal() {
|
|
|
19
17
|
if (typeof Deno !== "undefined") {
|
|
20
18
|
if (Deno.stdout.isTerminal) return Deno.stdout.isTerminal();
|
|
21
19
|
}
|
|
22
|
-
if (typeof
|
|
20
|
+
if (typeof process !== "undefined" && process.stdout) return Boolean(process.stdout.isTTY);
|
|
23
21
|
if (typeof window !== "undefined") return false;
|
|
24
22
|
return false;
|
|
25
23
|
} catch {
|
|
@@ -39,8 +37,8 @@ function getTerminalWidth() {
|
|
|
39
37
|
return size?.columns || null;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
if (typeof
|
|
43
|
-
const envColumns = typeof Deno !== "undefined" ? Deno.env.get("COLUMNS") :
|
|
40
|
+
if (typeof process !== "undefined" && process.stdout) return process.stdout.columns || null;
|
|
41
|
+
const envColumns = typeof Deno !== "undefined" ? Deno.env.get("COLUMNS") : process?.env?.COLUMNS;
|
|
44
42
|
if (envColumns) {
|
|
45
43
|
const parsed = parseInt(envColumns, 10);
|
|
46
44
|
return isNaN(parsed) ? null : parsed;
|
package/dist/terminal.js
CHANGED
package/dist/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","names":["defaultWidth: number"],"sources":["../terminal.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"terminal.js","names":["defaultWidth: number"],"sources":["../terminal.ts"],"sourcesContent":["// deno-lint-ignore-file no-process-global\n/// <reference types=\"@types/node\" />\n/**\n * @fileoverview\n * Terminal detection and width calculation utilities\n *\n * Provides cross-runtime compatible functions to detect if the process\n * is attached to a terminal and get the terminal width.\n */\n\n/**\n * Detect if the current process is attached to a terminal (TTY).\n *\n * @returns True if stdout is connected to a terminal\n */\nexport function isTerminal(): boolean {\n try {\n // Deno runtime\n if (typeof Deno !== \"undefined\") {\n // Use modern Deno API\n if (Deno.stdout.isTerminal) {\n return Deno.stdout.isTerminal();\n }\n }\n\n // Node.js/Bun runtime\n if (typeof process !== \"undefined\" && process.stdout) {\n return Boolean(process.stdout.isTTY);\n }\n\n // Browser environment - never a terminal\n if (typeof window !== \"undefined\") {\n return false;\n }\n\n // Unknown environment - assume not a terminal\n return false;\n } catch {\n // If any detection method fails, assume not a terminal\n return false;\n }\n}\n\n/**\n * Get the current terminal width in columns.\n *\n * @returns Terminal width in columns, or null if not available\n */\nexport function getTerminalWidth(): number | null {\n try {\n // Deno runtime\n if (typeof Deno !== \"undefined\") {\n // Try to get console size\n if (Deno.consoleSize) {\n const size = Deno.consoleSize();\n return size?.columns || null;\n }\n }\n\n // Node.js/Bun runtime\n if (typeof process !== \"undefined\" && process.stdout) {\n return process.stdout.columns || null;\n }\n\n // Fallback to environment variable\n const envColumns = typeof Deno !== \"undefined\"\n ? Deno.env.get(\"COLUMNS\")\n : process?.env?.COLUMNS;\n\n if (envColumns) {\n const parsed = parseInt(envColumns, 10);\n return isNaN(parsed) ? null : parsed;\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get the optimal word wrap width based on terminal detection.\n *\n * @param defaultWidth Default width to use when not in a terminal\n * @returns The optimal width\n */\nexport function getOptimalWordWrapWidth(defaultWidth: number = 80): number {\n if (!isTerminal()) {\n return defaultWidth;\n }\n\n const terminalWidth = getTerminalWidth();\n return terminalWidth || defaultWidth;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,aAAsB;AACpC,KAAI;AAEF,aAAW,SAAS,aAElB;OAAI,KAAK,OAAO,WACd,QAAO,KAAK,OAAO,YAAY;EAChC;AAIH,aAAW,YAAY,eAAe,QAAQ,OAC5C,QAAO,QAAQ,QAAQ,OAAO,MAAM;AAItC,aAAW,WAAW,YACpB,QAAO;AAIT,SAAO;CACR,QAAO;AAEN,SAAO;CACR;AACF;;;;;;AAOD,SAAgB,mBAAkC;AAChD,KAAI;AAEF,aAAW,SAAS,aAElB;OAAI,KAAK,aAAa;IACpB,MAAM,OAAO,KAAK,aAAa;AAC/B,WAAO,MAAM,WAAW;GACzB;;AAIH,aAAW,YAAY,eAAe,QAAQ,OAC5C,QAAO,QAAQ,OAAO,WAAW;EAInC,MAAM,oBAAoB,SAAS,cAC/B,KAAK,IAAI,IAAI,UAAU,GACvB,SAAS,KAAK;AAElB,MAAI,YAAY;GACd,MAAM,SAAS,SAAS,YAAY,GAAG;AACvC,UAAO,MAAM,OAAO,GAAG,OAAO;EAC/B;AAED,SAAO;CACR,QAAO;AACN,SAAO;CACR;AACF;;;;;;;AAQD,SAAgB,wBAAwBA,eAAuB,IAAY;AACzE,MAAK,YAAY,CACf,QAAO;CAGT,MAAM,gBAAgB,kBAAkB;AACxC,QAAO,iBAAiB;AACzB"}
|
package/dist/util.cjs
ADDED
package/dist/util.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.cts","names":[],"sources":["../util.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","names":[],"sources":["../util.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
//#region util.deno.ts
|
|
3
|
+
function inspect(obj, options) {
|
|
4
|
+
if ("Deno" in globalThis) return Deno.inspect(obj, {
|
|
5
|
+
colors: options?.colors,
|
|
6
|
+
depth: options?.depth ?? void 0,
|
|
7
|
+
compact: options?.compact ?? true
|
|
8
|
+
});
|
|
9
|
+
else {
|
|
10
|
+
const indent = options?.compact === true ? void 0 : 2;
|
|
11
|
+
return JSON.stringify(obj, null, indent);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.inspect = inspect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.deno.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.deno.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.d.cts","names":[],"sources":["../util.deno.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.deno.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.d.ts","names":[],"sources":["../util.deno.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region util.deno.ts
|
|
2
|
+
function inspect(obj, options) {
|
|
3
|
+
if ("Deno" in globalThis) return Deno.inspect(obj, {
|
|
4
|
+
colors: options?.colors,
|
|
5
|
+
depth: options?.depth ?? void 0,
|
|
6
|
+
compact: options?.compact ?? true
|
|
7
|
+
});
|
|
8
|
+
else {
|
|
9
|
+
const indent = options?.compact === true ? void 0 : 2;
|
|
10
|
+
return JSON.stringify(obj, null, indent);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { inspect };
|
|
16
|
+
//# sourceMappingURL=util.deno.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../util.deno.ts"],"sourcesContent":["export interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n if (\"Deno\" in globalThis) {\n return Deno.inspect(obj, {\n colors: options?.colors,\n depth: options?.depth ?? undefined,\n compact: options?.compact ?? true,\n });\n } else {\n const indent = options?.compact === true ? undefined : 2;\n return JSON.stringify(obj, null, indent);\n }\n}\n"],"mappings":";AAOA,SAAgB,QAAQA,KAAcC,SAAkC;AACtE,KAAI,UAAU,WACZ,QAAO,KAAK,QAAQ,KAAK;EACvB,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB,SAAS,SAAS,WAAW;CAC9B,EAAC;MACG;EACL,MAAM,SAAS,SAAS,YAAY,gBAAmB;AACvD,SAAO,KAAK,UAAU,KAAK,MAAM,OAAO;CACzC;AACF"}
|
package/dist/util.js
ADDED
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../util.ts"],"sourcesContent":["export interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n const indent = options?.compact === true ? undefined : 2;\n return JSON.stringify(obj, null, indent);\n}\n"],"mappings":";AAOA,SAAgB,QAAQA,KAAcC,SAAkC;CACtE,MAAM,SAAS,SAAS,YAAY,gBAAmB;AACvD,QAAO,KAAK,UAAU,KAAK,MAAM,OAAO;AACzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const node_util = require_rolldown_runtime.__toESM(require("node:util"));
|
|
3
|
+
|
|
4
|
+
//#region util.node.ts
|
|
5
|
+
function inspect(obj, options) {
|
|
6
|
+
return node_util.default.inspect(obj, options);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.inspect = inspect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.node.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.node.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.d.cts","names":[],"sources":["../util.node.ts"],"sourcesContent":[],"mappings":";UAEiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region util.node.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.d.ts","names":[],"sources":["../util.node.ts"],"sourcesContent":[],"mappings":";UAEiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../util.node.ts"],"sourcesContent":["import util from \"node:util\";\n\nexport interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n return util.inspect(obj, options);\n}\n"],"mappings":";;;AASA,SAAgB,QAAQA,KAAcC,SAAkC;AACtE,QAAO,KAAK,QAAQ,KAAK,QAAQ;AAClC"}
|
package/formatter.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
TextFormatter,
|
|
5
5
|
TextFormatterOptions,
|
|
6
6
|
} from "@logtape/logtape";
|
|
7
|
-
import { inspect
|
|
7
|
+
import { inspect } from "#util";
|
|
8
8
|
import { getOptimalWordWrapWidth } from "./terminal.ts";
|
|
9
9
|
import { truncateCategory, type TruncationStrategy } from "./truncate.ts";
|
|
10
10
|
import { getDisplayWidth } from "./wcwidth.ts";
|
|
@@ -235,29 +235,6 @@ function normalizeIconSpacing(
|
|
|
235
235
|
) as Record<LogLevel, string>;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
/**
|
|
239
|
-
* Platform-specific inspect function. Uses Node.js `util.inspect()` which
|
|
240
|
-
* is available in both Deno and Node.js environments. For browser environments,
|
|
241
|
-
* it falls back to {@link JSON.stringify}.
|
|
242
|
-
*
|
|
243
|
-
* @param value The value to inspect.
|
|
244
|
-
* @param options The options for inspecting the value.
|
|
245
|
-
* @returns The string representation of the value.
|
|
246
|
-
*/
|
|
247
|
-
const inspect: (value: unknown, options?: { colors?: boolean }) => string =
|
|
248
|
-
// @ts-ignore: Browser detection
|
|
249
|
-
typeof document !== "undefined" ||
|
|
250
|
-
// @ts-ignore: React Native detection
|
|
251
|
-
typeof navigator !== "undefined" && navigator.product === "ReactNative"
|
|
252
|
-
? (v) => JSON.stringify(v)
|
|
253
|
-
: (v, opts) =>
|
|
254
|
-
nodeInspect(v, {
|
|
255
|
-
maxArrayLength: 10,
|
|
256
|
-
maxStringLength: 80,
|
|
257
|
-
compact: true,
|
|
258
|
-
...opts,
|
|
259
|
-
});
|
|
260
|
-
|
|
261
238
|
/**
|
|
262
239
|
* Configuration options for the pretty formatter.
|
|
263
240
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/pretty",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Beautiful text formatter for LogTape—perfect for local development",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logging",
|
|
@@ -49,9 +49,33 @@
|
|
|
49
49
|
},
|
|
50
50
|
"./package.json": "./package.json"
|
|
51
51
|
},
|
|
52
|
+
"imports": {
|
|
53
|
+
"#util": {
|
|
54
|
+
"types": {
|
|
55
|
+
"import": "./dist/util.d.ts",
|
|
56
|
+
"require": "./dist/util.d.cts"
|
|
57
|
+
},
|
|
58
|
+
"browser": {
|
|
59
|
+
"import": "./dist/util.js",
|
|
60
|
+
"require": "./dist/util.cjs"
|
|
61
|
+
},
|
|
62
|
+
"node": {
|
|
63
|
+
"import": "./dist/util.node.js",
|
|
64
|
+
"require": "./dist/util.node.cjs"
|
|
65
|
+
},
|
|
66
|
+
"bun": {
|
|
67
|
+
"import": "./dist/util.node.js",
|
|
68
|
+
"require": "./dist/util.node.cjs"
|
|
69
|
+
},
|
|
70
|
+
"deno": "./dist/util.deno.js",
|
|
71
|
+
"import": "./dist/util.js",
|
|
72
|
+
"require": "./dist/util.cjs",
|
|
73
|
+
"default": "./dist/util.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
52
76
|
"sideEffects": false,
|
|
53
77
|
"peerDependencies": {
|
|
54
|
-
"@logtape/logtape": "1.0.
|
|
78
|
+
"@logtape/logtape": "1.0.1"
|
|
55
79
|
},
|
|
56
80
|
"devDependencies": {
|
|
57
81
|
"@alinea/suite": "^0.6.3",
|
package/terminal.ts
CHANGED
package/tsdown.config.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { defineConfig } from "tsdown";
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
entry: "mod.ts",
|
|
4
|
+
entry: ["mod.ts", "util.ts", "util.deno.ts", "util.node.ts"],
|
|
5
5
|
dts: {
|
|
6
6
|
sourcemap: true,
|
|
7
7
|
},
|
|
8
8
|
format: ["esm", "cjs"],
|
|
9
|
-
platform: "
|
|
9
|
+
platform: "neutral",
|
|
10
10
|
unbundle: true,
|
|
11
|
+
inputOptions: {
|
|
12
|
+
onLog(level, log, defaultHandler) {
|
|
13
|
+
if (
|
|
14
|
+
level === "warn" && log.code === "UNRESOLVED_IMPORT" &&
|
|
15
|
+
["node:util", "#util"].includes(
|
|
16
|
+
log.exporter ?? "",
|
|
17
|
+
)
|
|
18
|
+
) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
defaultHandler(level, log);
|
|
22
|
+
},
|
|
23
|
+
},
|
|
11
24
|
});
|
package/util.deno.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface InspectOptions {
|
|
2
|
+
colors?: boolean;
|
|
3
|
+
depth?: number | null;
|
|
4
|
+
compact?: boolean;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function inspect(obj: unknown, options?: InspectOptions): string {
|
|
9
|
+
if ("Deno" in globalThis) {
|
|
10
|
+
return Deno.inspect(obj, {
|
|
11
|
+
colors: options?.colors,
|
|
12
|
+
depth: options?.depth ?? undefined,
|
|
13
|
+
compact: options?.compact ?? true,
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
const indent = options?.compact === true ? undefined : 2;
|
|
17
|
+
return JSON.stringify(obj, null, indent);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/util.node.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import util from "node:util";
|
|
2
|
+
|
|
3
|
+
export interface InspectOptions {
|
|
4
|
+
colors?: boolean;
|
|
5
|
+
depth?: number | null;
|
|
6
|
+
compact?: boolean;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function inspect(obj: unknown, options?: InspectOptions): string {
|
|
11
|
+
return util.inspect(obj, options);
|
|
12
|
+
}
|
package/util.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface InspectOptions {
|
|
2
|
+
colors?: boolean;
|
|
3
|
+
depth?: number | null;
|
|
4
|
+
compact?: boolean;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function inspect(obj: unknown, options?: InspectOptions): string {
|
|
9
|
+
const indent = options?.compact === true ? undefined : 2;
|
|
10
|
+
return JSON.stringify(obj, null, indent);
|
|
11
|
+
}
|