@jacob-z/chalk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +31 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +31 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -147,18 +147,31 @@ const DEFAULT_LOG_LEVELS = [
|
|
|
147
147
|
function getConsoleMethod(consoleLike, method) {
|
|
148
148
|
return consoleLike[method] ?? consoleLike.log;
|
|
149
149
|
}
|
|
150
|
-
function createLogMethod(consoleLike, colors, isDebug, level) {
|
|
150
|
+
function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
|
|
151
151
|
return (message, ...args) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
const debugValue = isDebug();
|
|
153
|
+
if (debugValue) {
|
|
154
|
+
const method = getConsoleMethod(consoleLike, level.method);
|
|
155
|
+
const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`;
|
|
156
|
+
const messageStyle = getForegroundStyle(colors, level.color);
|
|
157
|
+
method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
|
|
158
|
+
}
|
|
159
|
+
const hooks = getHooks();
|
|
160
|
+
if (hooks.length > 0) {
|
|
161
|
+
const ctx = {
|
|
162
|
+
level: level.name,
|
|
163
|
+
label: level.label,
|
|
164
|
+
message,
|
|
165
|
+
args,
|
|
166
|
+
isDebug: debugValue
|
|
167
|
+
};
|
|
168
|
+
for (const hook of hooks) hook(ctx);
|
|
169
|
+
}
|
|
157
170
|
};
|
|
158
171
|
}
|
|
159
172
|
function createLoggerMethods(options) {
|
|
160
173
|
const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
|
|
161
|
-
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.colors, options.isDebug, level)]));
|
|
174
|
+
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks)]));
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
//#endregion
|
|
@@ -180,13 +193,16 @@ function createChalk(options = {}) {
|
|
|
180
193
|
const colors = createColorMap(options.colors);
|
|
181
194
|
const isDebug = resolveDebugPredicate(options.isDebug);
|
|
182
195
|
const banner = createBannerMethods(consoleLike, isDebug);
|
|
196
|
+
const hooks = [];
|
|
197
|
+
const getHooks = () => hooks;
|
|
183
198
|
const loggers = createLoggerMethods({
|
|
184
199
|
console: consoleLike,
|
|
185
200
|
colors,
|
|
186
201
|
isDebug,
|
|
187
|
-
logLevels: options.logLevels
|
|
202
|
+
logLevels: options.logLevels,
|
|
203
|
+
getHooks
|
|
188
204
|
});
|
|
189
|
-
|
|
205
|
+
const instance = {
|
|
190
206
|
add,
|
|
191
207
|
bold,
|
|
192
208
|
...banner,
|
|
@@ -215,8 +231,13 @@ function createChalk(options = {}) {
|
|
|
215
231
|
ready: loggers.ready,
|
|
216
232
|
info: loggers.info,
|
|
217
233
|
event: loggers.event,
|
|
218
|
-
debug: loggers.debug
|
|
234
|
+
debug: loggers.debug,
|
|
235
|
+
use(hook) {
|
|
236
|
+
hooks.push(hook);
|
|
237
|
+
return instance;
|
|
238
|
+
}
|
|
219
239
|
};
|
|
240
|
+
return instance;
|
|
220
241
|
}
|
|
221
242
|
|
|
222
243
|
//#endregion
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","noopConsole: ConsoleLike","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n if (!isDebug())\n return\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n })\n\n return {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n }\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;;;AAKA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;;;;;AAMD,MAAaC,iBAAuC;CAAE,OAAO;CAAM,MAAM;CAAM;AAI/E,SAAgB,eAAe,eAA+B,EAAE,EAAsC;AACpG,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAgB,aAAa,QAA0C,MAAsB;CAC3F,MAAMC,UAAQ,OAAO;AACrB,KAAIA,YAAU,OACZ,OAAM,IAAI,MAAM,wBAAwB,OAAO;AACjD,QAAOA;;;AAIT,SAAS,gBAAgB,QAA0C,MAAuB;AACxF,KAAI,eAAe,MACjB,QAAO;CACT,MAAM,MAAM,OAAO;AACnB,KAAI,CAAC,IACH,QAAO;AACT,QAAO,qBAAqB,IAAI,GAAG;;AAGrC,SAAS,qBAAqB,KAAqB;CACjD,MAAM,IAAI,IAAI,QAAQ,KAAK,GAAG;CAC9B,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/C,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/C,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;AAC/C,QAAO,QAAS,IAAI,QAAS,IAAI,QAAS;;AAG5C,SAAgB,mBAAmB,QAA0C,MAAsB;CAEjG,MAAM,QAAQ,CAAC,SADH,aAAa,QAAQ,KAAK,GACR;A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,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,QAAQ;EAChB;;;;;ACjEH,MAAM,gBAAgB,gBAAgB;AAEtC,MAAa,QAAQ,aAAa;AAkBlC,SAAgB,MAAM,MAAc,MAAc;AAChD,QAAOC,QAAa,eAAe,MAAM,KAAK;;AAGhD,SAAgB,QAAQ,MAAc,MAAc;AAClD,QAAOC,UAAe,eAAe,MAAM,KAAK;;AAGlD,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;;;AAKA,MAAaA,iBAA2B;CACtC,O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,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,QAAQ;EACf,IAAI,MAA8B;AAChC,SAAM,KAAK,KAAK;AAChB,UAAO;;EAEV;AAED,QAAO;;;;;AC1ET,MAAM,gBAAgB,gBAAgB;AAEtC,MAAa,QAAQ,aAAa;AAoBlC,SAAgB,MAAM,MAAc,MAAc;AAChD,QAAOC,QAAa,eAAe,MAAM,KAAK;;AAGhD,SAAgB,QAAQ,MAAc,MAAc;AAClD,QAAOC,UAAe,eAAe,MAAM,KAAK;;AAGlD,kBAAe"}
|
package/dist/index.d.cts
CHANGED
|
@@ -27,6 +27,14 @@ interface CreateChalkOptions {
|
|
|
27
27
|
}
|
|
28
28
|
type TextFormatter = (text: string) => FormattedText;
|
|
29
29
|
type LogMethod = (message: string, ...args: unknown[]) => void;
|
|
30
|
+
interface LogHookContext {
|
|
31
|
+
level: string;
|
|
32
|
+
label: string;
|
|
33
|
+
message: string;
|
|
34
|
+
args: unknown[];
|
|
35
|
+
isDebug: boolean;
|
|
36
|
+
}
|
|
37
|
+
type LogHook = (ctx: LogHookContext) => void;
|
|
30
38
|
interface ChalkInstance {
|
|
31
39
|
add: (...items: readonly FormattedText[]) => FormattedText;
|
|
32
40
|
bold: TextFormatter;
|
|
@@ -58,6 +66,7 @@ interface ChalkInstance {
|
|
|
58
66
|
bgWhite: TextFormatter;
|
|
59
67
|
color: (name: string, text: string) => FormattedText;
|
|
60
68
|
bgColor: (name: string, text: string) => FormattedText;
|
|
69
|
+
use: (hook: LogHook) => ChalkInstance;
|
|
61
70
|
}
|
|
62
71
|
//#endregion
|
|
63
72
|
//#region src/create.d.ts
|
|
@@ -83,5 +92,5 @@ declare const chalk: ChalkInstance;
|
|
|
83
92
|
declare function color(name: string, text: string): FormattedText;
|
|
84
93
|
declare function bgColor(name: string, text: string): FormattedText;
|
|
85
94
|
//#endregion
|
|
86
|
-
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, type CustomColorMap, DEFAULT_COLORS, type FormattedText, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bgColor, bold, chalk, chalk as default, color, createChalk, createColorMap, getBackgroundStyle, getForegroundStyle, resolveColor };
|
|
95
|
+
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, type CustomColorMap, DEFAULT_COLORS, type FormattedText, type LogHook, type LogHookContext, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bgColor, bold, chalk, chalk as default, color, createChalk, createColorMap, getBackgroundStyle, getForegroundStyle, resolveColor };
|
|
87
96
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -27,6 +27,14 @@ interface CreateChalkOptions {
|
|
|
27
27
|
}
|
|
28
28
|
type TextFormatter = (text: string) => FormattedText;
|
|
29
29
|
type LogMethod = (message: string, ...args: unknown[]) => void;
|
|
30
|
+
interface LogHookContext {
|
|
31
|
+
level: string;
|
|
32
|
+
label: string;
|
|
33
|
+
message: string;
|
|
34
|
+
args: unknown[];
|
|
35
|
+
isDebug: boolean;
|
|
36
|
+
}
|
|
37
|
+
type LogHook = (ctx: LogHookContext) => void;
|
|
30
38
|
interface ChalkInstance {
|
|
31
39
|
add: (...items: readonly FormattedText[]) => FormattedText;
|
|
32
40
|
bold: TextFormatter;
|
|
@@ -58,6 +66,7 @@ interface ChalkInstance {
|
|
|
58
66
|
bgWhite: TextFormatter;
|
|
59
67
|
color: (name: string, text: string) => FormattedText;
|
|
60
68
|
bgColor: (name: string, text: string) => FormattedText;
|
|
69
|
+
use: (hook: LogHook) => ChalkInstance;
|
|
61
70
|
}
|
|
62
71
|
//#endregion
|
|
63
72
|
//#region src/create.d.ts
|
|
@@ -83,5 +92,5 @@ declare const chalk: ChalkInstance;
|
|
|
83
92
|
declare function color(name: string, text: string): FormattedText;
|
|
84
93
|
declare function bgColor(name: string, text: string): FormattedText;
|
|
85
94
|
//#endregion
|
|
86
|
-
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, type CustomColorMap, DEFAULT_COLORS, type FormattedText, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bgColor, bold, chalk, chalk as default, color, createChalk, createColorMap, getBackgroundStyle, getForegroundStyle, resolveColor };
|
|
95
|
+
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, type CustomColorMap, DEFAULT_COLORS, type FormattedText, type LogHook, type LogHookContext, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bgColor, bold, chalk, chalk as default, color, createChalk, createColorMap, getBackgroundStyle, getForegroundStyle, resolveColor };
|
|
87
96
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -145,18 +145,31 @@ const DEFAULT_LOG_LEVELS = [
|
|
|
145
145
|
function getConsoleMethod(consoleLike, method) {
|
|
146
146
|
return consoleLike[method] ?? consoleLike.log;
|
|
147
147
|
}
|
|
148
|
-
function createLogMethod(consoleLike, colors, isDebug, level) {
|
|
148
|
+
function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
|
|
149
149
|
return (message, ...args) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
const debugValue = isDebug();
|
|
151
|
+
if (debugValue) {
|
|
152
|
+
const method = getConsoleMethod(consoleLike, level.method);
|
|
153
|
+
const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`;
|
|
154
|
+
const messageStyle = getForegroundStyle(colors, level.color);
|
|
155
|
+
method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
|
|
156
|
+
}
|
|
157
|
+
const hooks = getHooks();
|
|
158
|
+
if (hooks.length > 0) {
|
|
159
|
+
const ctx = {
|
|
160
|
+
level: level.name,
|
|
161
|
+
label: level.label,
|
|
162
|
+
message,
|
|
163
|
+
args,
|
|
164
|
+
isDebug: debugValue
|
|
165
|
+
};
|
|
166
|
+
for (const hook of hooks) hook(ctx);
|
|
167
|
+
}
|
|
155
168
|
};
|
|
156
169
|
}
|
|
157
170
|
function createLoggerMethods(options) {
|
|
158
171
|
const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
|
|
159
|
-
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.colors, options.isDebug, level)]));
|
|
172
|
+
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks)]));
|
|
160
173
|
}
|
|
161
174
|
|
|
162
175
|
//#endregion
|
|
@@ -178,13 +191,16 @@ function createChalk(options = {}) {
|
|
|
178
191
|
const colors = createColorMap(options.colors);
|
|
179
192
|
const isDebug = resolveDebugPredicate(options.isDebug);
|
|
180
193
|
const banner = createBannerMethods(consoleLike, isDebug);
|
|
194
|
+
const hooks = [];
|
|
195
|
+
const getHooks = () => hooks;
|
|
181
196
|
const loggers = createLoggerMethods({
|
|
182
197
|
console: consoleLike,
|
|
183
198
|
colors,
|
|
184
199
|
isDebug,
|
|
185
|
-
logLevels: options.logLevels
|
|
200
|
+
logLevels: options.logLevels,
|
|
201
|
+
getHooks
|
|
186
202
|
});
|
|
187
|
-
|
|
203
|
+
const instance = {
|
|
188
204
|
add,
|
|
189
205
|
bold,
|
|
190
206
|
...banner,
|
|
@@ -213,8 +229,13 @@ function createChalk(options = {}) {
|
|
|
213
229
|
ready: loggers.ready,
|
|
214
230
|
info: loggers.info,
|
|
215
231
|
event: loggers.event,
|
|
216
|
-
debug: loggers.debug
|
|
232
|
+
debug: loggers.debug,
|
|
233
|
+
use(hook) {
|
|
234
|
+
hooks.push(hook);
|
|
235
|
+
return instance;
|
|
236
|
+
}
|
|
217
237
|
};
|
|
238
|
+
return instance;
|
|
218
239
|
}
|
|
219
240
|
|
|
220
241
|
//#endregion
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","noopConsole: ConsoleLike","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n if (!isDebug())\n return\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n })\n\n return {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n }\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;AAKA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;;;;;AAMD,MAAaC,iBAAuC;CAAE,OAAO;CAAM,MAAM;CAAM;AAI/E,SAAgB,eAAe,eAA+B,EAAE,EAAsC;AACpG,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAgB,aAAa,QAA0C,MAAsB;CAC3F,MAAMC,UAAQ,OAAO;AACrB,KAAIA,YAAU,OACZ,OAAM,IAAI,MAAM,wBAAwB,OAAO;AACjD,QAAOA;;;AAIT,SAAS,gBAAgB,QAA0C,MAAuB;AACxF,KAAI,eAAe,MACjB,QAAO;CACT,MAAM,MAAM,OAAO;AACnB,KAAI,CAAC,IACH,QAAO;AACT,QAAO,qBAAqB,IAAI,GAAG;;AAGrC,SAAS,qBAAqB,KAAqB;CACjD,MAAM,IAAI,IAAI,QAAQ,KAAK,GAAG;CAC9B,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/C,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/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,UAAQ,QAAQ,SAAS,KAAK;EAC/C,QAAQ,MAAM,SAASD,QAAM,QAAQ,MAAM,KAAK;EAChD,UAAU,MAAM,SAASC,UAAQ,QAAQ,MAAM,KAAK;EACpD,KAAK,QAAQ;EACb,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,QAAQ;EAChB;;;;;ACjEH,MAAM,gBAAgB,gBAAgB;AAEtC,MAAa,QAAQ,aAAa;AAkBlC,SAAgB,MAAM,MAAc,MAAc;AAChD,QAAOC,QAAa,eAAe,MAAM,KAAK;;AAGhD,SAAgB,QAAQ,MAAc,MAAc;AAClD,QAAOC,UAAe,eAAe,MAAM,KAAK;;AAGlD,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;AAKA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;;;;;AAMD,MAAaC,iBAAuC;CAAE,OAAO;CAAM,MAAM;CAAM;AAI/E,SAAgB,eAAe,eAA+B,EAAE,EAAsC;AACpG,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAgB,aAAa,QAA0C,MAAsB;CAC3F,MAAMC,UAAQ,OAAO;AACrB,KAAIA,YAAU,OACZ,OAAM,IAAI,MAAM,wBAAwB,OAAO;AACjD,QAAOA;;;AAIT,SAAS,gBAAgB,QAA0C,MAAuB;AACxF,KAAI,eAAe,MACjB,QAAO;CACT,MAAM,MAAM,OAAO;AACnB,KAAI,CAAC,IACH,QAAO;AACT,QAAO,qBAAqB,IAAI,GAAG;;AAGrC,SAAS,qBAAqB,KAAqB;CACjD,MAAM,IAAI,IAAI,QAAQ,KAAK,GAAG;CAC9B,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/C,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;CAC/C,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG;AAC/C,QAAO,QAAS,IAAI,QAAS,IAAI,QAAS;;AAG5C,SAAgB,mBAAmB,QAA0C,MAAsB;CAEjG,MAAM,QAAQ,CAAC,SADH,aAAa,QAAQ,KAAK,GACR;AAC9B,KAAI,gBAAgB,QAAQ,KAAK,CAC/B,OAAM,KAAK,+BAA+B,iBAAiB,oBAAoB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