@jacob-z/chalk 0.1.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/README.md CHANGED
@@ -1,12 +1,13 @@
1
- # custom-chalk
1
+ # @jacob-z/chalk
2
2
 
3
- Browser console coloring utilities — a modular, type-safe rewrite of `@alita/chalk`.
3
+ Browser console coloring utilities — a modular, type-safe rewrite of `@alita/chalk`, themed with [Catppuccin Mocha](https://catppuccin.com/palette/).
4
4
 
5
5
  ## Features
6
6
 
7
7
  - `%c` CSS tuple formatters for browser DevTools console output
8
- - 8 foreground colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
8
+ - 9 foreground colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`
9
9
  - 8 background colors: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
10
+ - Light foreground colors automatically get a subtle dark background for readability in dark-mode consoles
10
11
  - `bold()` text formatting
11
12
  - `add()` for merging multiple formatted tuples
12
13
  - Debug-gated logger methods: `log`, `wait`, `error`, `warn`, `ready`, `info`, `event`, `debug`
@@ -18,7 +19,7 @@ Browser console coloring utilities — a modular, type-safe rewrite of `@alita/c
18
19
  ## Install
19
20
 
20
21
  ```bash
21
- pnpm add custom-chalk
22
+ pnpm add @jacob-z/chalk
22
23
  ```
23
24
 
24
25
  ## Basic Usage
@@ -26,19 +27,22 @@ pnpm add custom-chalk
26
27
  Color formatters return `console.log`-ready tuples:
27
28
 
28
29
  ```ts
29
- import chalk from 'custom-chalk'
30
+ import chalk from '@jacob-z/chalk'
30
31
 
31
32
  chalk.red('text')
32
- // → ['%ctext', 'color:#FF0000']
33
+ // → ['%ctext', 'color:#f38ba8']
34
+
35
+ chalk.yellow('text')
36
+ // → ['%ctext', 'color:#f9e2af;background:rgba(0,0,0,0.15);padding:0 2px;border-radius:2px']
33
37
 
34
38
  chalk.bgRed('text')
35
- // → ['%ctext', 'padding: 2px 4px; border-radius: 3px; color: #fff; font-weight: bold; background:#FF0000;']
39
+ // → ['%ctext', 'padding: 2px 4px; border-radius: 3px; color: #1e1e2e; font-weight: bold; background:#f38ba8;']
36
40
 
37
41
  chalk.bold('text')
38
42
  // → ['%ctext', 'font-weight: bold;']
39
43
 
40
44
  chalk.add(chalk.red('a'), chalk.blue('b'))
41
- // → [' %ca %cb', 'color:#FF0000', 'color:#0000FF']
45
+ // → [' %ca %cb', 'color:#f38ba8', 'color:#89b4fa']
42
46
  ```
43
47
 
44
48
  Use with `console.log` spread:
@@ -62,7 +66,7 @@ chalk.error('failed') // prints [Error] in red
62
66
  For tests or controlled environments, use the factory:
63
67
 
64
68
  ```ts
65
- import { createChalk } from 'custom-chalk'
69
+ import { createChalk } from '@jacob-z/chalk'
66
70
 
67
71
  const chalk = createChalk({ console, isDebug: () => true })
68
72
  chalk.info('loaded')
@@ -86,7 +90,7 @@ If a console method is unavailable, the logger falls back to `console.log`.
86
90
  ## Custom Colors
87
91
 
88
92
  ```ts
89
- import { createChalk } from 'custom-chalk'
93
+ import { createChalk } from '@jacob-z/chalk'
90
94
 
91
95
  const chalk = createChalk({
92
96
  colors: { brand: '#123456' },
@@ -137,6 +141,7 @@ Design principles vs the original `@alita/chalk`:
137
141
  - **No module-level side effects** — factory pattern, pure functions
138
142
  - **No `any` / `@ts-ignore`** — strict TypeScript throughout
139
143
  - **Modular & extensible** — custom colors, custom log levels, injected console
144
+ - **Dark-mode friendly** — light foreground colors get a subtle background for readability
140
145
 
141
146
  ## License
142
147
 
package/dist/index.cjs CHANGED
@@ -1,16 +1,27 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  //#region src/colors.ts
4
+ /**
5
+ * Catppuccin Mocha palette — https://catppuccin.com/palette/
6
+ */
4
7
  const DEFAULT_COLORS = {
5
- black: "#000000",
6
- red: "#FF0000",
7
- green: "#008000",
8
- yellow: "#FFFF00",
9
- blue: "#0000FF",
10
- magenta: "#FF00FF",
11
- cyan: "#00FFFF",
12
- white: "#FFFFFF",
13
- gray: "#808080"
8
+ black: "#1e1e2e",
9
+ red: "#f38ba8",
10
+ green: "#a6e3a1",
11
+ yellow: "#f9e2af",
12
+ blue: "#89b4fa",
13
+ magenta: "#cba6f7",
14
+ cyan: "#94e2d5",
15
+ white: "#cdd6f4",
16
+ gray: "#6c7086"
17
+ };
18
+ /**
19
+ * Colors that are dark enough to not need a background on dark consoles.
20
+ * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.
21
+ */
22
+ const DARK_FG_COLORS = {
23
+ black: true,
24
+ gray: true
14
25
  };
15
26
  function createColorMap(customColors = {}) {
16
27
  return {
@@ -23,11 +34,27 @@ function resolveColor(colors, name) {
23
34
  if (color$2 === void 0) throw new Error(`Unknown chalk color: ${name}`);
24
35
  return color$2;
25
36
  }
37
+ /** Returns true when the color is bright enough to need a background in dark consoles. */
38
+ function needsBackground(colors, name) {
39
+ if (DARK_FG_COLORS[name]) return false;
40
+ const hex = colors[name];
41
+ if (!hex) return true;
42
+ return getRelativeLuminance(hex) > .18;
43
+ }
44
+ function getRelativeLuminance(hex) {
45
+ const h = hex.replace("#", "");
46
+ const r = Number.parseInt(h.slice(0, 2), 16) / 255;
47
+ const g = Number.parseInt(h.slice(2, 4), 16) / 255;
48
+ const b = Number.parseInt(h.slice(4, 6), 16) / 255;
49
+ return .2126 * r + .7152 * g + .0722 * b;
50
+ }
26
51
  function getForegroundStyle(colors, name) {
27
- return `color:${resolveColor(colors, name)}`;
52
+ const parts = [`color:${resolveColor(colors, name)}`];
53
+ if (needsBackground(colors, name)) parts.push("background:rgba(0,0,0,0.15)", "padding:0 2px", "border-radius:2px");
54
+ return parts.join(";");
28
55
  }
29
56
  function getBackgroundStyle(colors, name) {
30
- return `padding: 2px 4px; border-radius: 3px; color: ${name === "white" ? "#000" : "#fff"}; font-weight: bold; background:${resolveColor(colors, name)};`;
57
+ return `padding: 2px 4px; border-radius: 3px; color: #1e1e2e; font-weight: bold; background:${resolveColor(colors, name)};`;
31
58
  }
32
59
 
33
60
  //#endregion
@@ -36,7 +63,7 @@ function createBannerMethods(consoleLike, isDebug) {
36
63
  return {
37
64
  hello(title, version) {
38
65
  if (!isDebug()) return;
39
- consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
66
+ consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;");
40
67
  },
41
68
  image(url) {
42
69
  if (!url) return;
@@ -120,18 +147,31 @@ const DEFAULT_LOG_LEVELS = [
120
147
  function getConsoleMethod(consoleLike, method) {
121
148
  return consoleLike[method] ?? consoleLike.log;
122
149
  }
123
- function createLogMethod(consoleLike, colors, isDebug, level) {
150
+ function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
124
151
  return (message, ...args) => {
125
- if (!isDebug()) return;
126
- const method = getConsoleMethod(consoleLike, level.method);
127
- const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`;
128
- const messageStyle = getForegroundStyle(colors, level.color);
129
- method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
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
+ }
130
170
  };
131
171
  }
132
172
  function createLoggerMethods(options) {
133
173
  const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
134
- 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)]));
135
175
  }
136
176
 
137
177
  //#endregion
@@ -153,13 +193,16 @@ function createChalk(options = {}) {
153
193
  const colors = createColorMap(options.colors);
154
194
  const isDebug = resolveDebugPredicate(options.isDebug);
155
195
  const banner = createBannerMethods(consoleLike, isDebug);
196
+ const hooks = [];
197
+ const getHooks = () => hooks;
156
198
  const loggers = createLoggerMethods({
157
199
  console: consoleLike,
158
200
  colors,
159
201
  isDebug,
160
- logLevels: options.logLevels
202
+ logLevels: options.logLevels,
203
+ getHooks
161
204
  });
162
- return {
205
+ const instance = {
163
206
  add,
164
207
  bold,
165
208
  ...banner,
@@ -188,8 +231,13 @@ function createChalk(options = {}) {
188
231
  ready: loggers.ready,
189
232
  info: loggers.info,
190
233
  event: loggers.event,
191
- debug: loggers.debug
234
+ debug: loggers.debug,
235
+ use(hook) {
236
+ hooks.push(hook);
237
+ return instance;
238
+ }
192
239
  };
240
+ return instance;
193
241
  }
194
242
 
195
243
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["DEFAULT_COLORS: ColorMap","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\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#000000',\n red: '#FF0000',\n green: '#008000',\n yellow: '#FFFF00',\n blue: '#0000FF',\n magenta: '#FF00FF',\n cyan: '#00FFFF',\n white: '#FFFFFF',\n gray: '#808080',\n}\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\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n return `color:${resolveColor(colors, name)}`\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const textColor = name === 'white' ? '#000' : '#fff'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${resolveColor(colors, name)};`\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: #fff; background: #606060; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; 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":";;;AAEA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;AAID,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;;AAGT,SAAgB,mBAAmB,QAA0C,MAAsB;AACjG,QAAO,SAAS,aAAa,QAAQ,KAAK;;AAG5C,SAAgB,mBAAmB,QAA0C,MAAsB;AAEjG,QAAO,gDADW,SAAS,UAAU,SAAS,OACmB,kCAAkC,aAAa,QAAQ,KAAK,CAAC;;;;;AC7BhI,SAAgB,oBAAoB,aAA0B,SAAwC;AACpG,QA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D,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,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,aAA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a,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
@@ -68,6 +77,9 @@ declare function bold(text: string): FormattedText;
68
77
  declare function add(...items: readonly FormattedText[]): FormattedText;
69
78
  //#endregion
70
79
  //#region src/colors.d.ts
80
+ /**
81
+ * Catppuccin Mocha palette — https://catppuccin.com/palette/
82
+ */
71
83
  declare const DEFAULT_COLORS: ColorMap;
72
84
  type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>;
73
85
  declare function createColorMap(customColors?: CustomColorMap): ResolvedColorMap;
@@ -80,5 +92,5 @@ declare const chalk: ChalkInstance;
80
92
  declare function color(name: string, text: string): FormattedText;
81
93
  declare function bgColor(name: string, text: string): FormattedText;
82
94
  //#endregion
83
- 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 };
84
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
@@ -68,6 +77,9 @@ declare function bold(text: string): FormattedText;
68
77
  declare function add(...items: readonly FormattedText[]): FormattedText;
69
78
  //#endregion
70
79
  //#region src/colors.d.ts
80
+ /**
81
+ * Catppuccin Mocha palette — https://catppuccin.com/palette/
82
+ */
71
83
  declare const DEFAULT_COLORS: ColorMap;
72
84
  type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>;
73
85
  declare function createColorMap(customColors?: CustomColorMap): ResolvedColorMap;
@@ -80,5 +92,5 @@ declare const chalk: ChalkInstance;
80
92
  declare function color(name: string, text: string): FormattedText;
81
93
  declare function bgColor(name: string, text: string): FormattedText;
82
94
  //#endregion
83
- 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 };
84
96
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,14 +1,25 @@
1
1
  //#region src/colors.ts
2
+ /**
3
+ * Catppuccin Mocha palette — https://catppuccin.com/palette/
4
+ */
2
5
  const DEFAULT_COLORS = {
3
- black: "#000000",
4
- red: "#FF0000",
5
- green: "#008000",
6
- yellow: "#FFFF00",
7
- blue: "#0000FF",
8
- magenta: "#FF00FF",
9
- cyan: "#00FFFF",
10
- white: "#FFFFFF",
11
- gray: "#808080"
6
+ black: "#1e1e2e",
7
+ red: "#f38ba8",
8
+ green: "#a6e3a1",
9
+ yellow: "#f9e2af",
10
+ blue: "#89b4fa",
11
+ magenta: "#cba6f7",
12
+ cyan: "#94e2d5",
13
+ white: "#cdd6f4",
14
+ gray: "#6c7086"
15
+ };
16
+ /**
17
+ * Colors that are dark enough to not need a background on dark consoles.
18
+ * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.
19
+ */
20
+ const DARK_FG_COLORS = {
21
+ black: true,
22
+ gray: true
12
23
  };
13
24
  function createColorMap(customColors = {}) {
14
25
  return {
@@ -21,11 +32,27 @@ function resolveColor(colors, name) {
21
32
  if (color$2 === void 0) throw new Error(`Unknown chalk color: ${name}`);
22
33
  return color$2;
23
34
  }
35
+ /** Returns true when the color is bright enough to need a background in dark consoles. */
36
+ function needsBackground(colors, name) {
37
+ if (DARK_FG_COLORS[name]) return false;
38
+ const hex = colors[name];
39
+ if (!hex) return true;
40
+ return getRelativeLuminance(hex) > .18;
41
+ }
42
+ function getRelativeLuminance(hex) {
43
+ const h = hex.replace("#", "");
44
+ const r = Number.parseInt(h.slice(0, 2), 16) / 255;
45
+ const g = Number.parseInt(h.slice(2, 4), 16) / 255;
46
+ const b = Number.parseInt(h.slice(4, 6), 16) / 255;
47
+ return .2126 * r + .7152 * g + .0722 * b;
48
+ }
24
49
  function getForegroundStyle(colors, name) {
25
- return `color:${resolveColor(colors, name)}`;
50
+ const parts = [`color:${resolveColor(colors, name)}`];
51
+ if (needsBackground(colors, name)) parts.push("background:rgba(0,0,0,0.15)", "padding:0 2px", "border-radius:2px");
52
+ return parts.join(";");
26
53
  }
27
54
  function getBackgroundStyle(colors, name) {
28
- return `padding: 2px 4px; border-radius: 3px; color: ${name === "white" ? "#000" : "#fff"}; font-weight: bold; background:${resolveColor(colors, name)};`;
55
+ return `padding: 2px 4px; border-radius: 3px; color: #1e1e2e; font-weight: bold; background:${resolveColor(colors, name)};`;
29
56
  }
30
57
 
31
58
  //#endregion
@@ -34,7 +61,7 @@ function createBannerMethods(consoleLike, isDebug) {
34
61
  return {
35
62
  hello(title, version) {
36
63
  if (!isDebug()) return;
37
- consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
64
+ consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;");
38
65
  },
39
66
  image(url) {
40
67
  if (!url) return;
@@ -118,18 +145,31 @@ const DEFAULT_LOG_LEVELS = [
118
145
  function getConsoleMethod(consoleLike, method) {
119
146
  return consoleLike[method] ?? consoleLike.log;
120
147
  }
121
- function createLogMethod(consoleLike, colors, isDebug, level) {
148
+ function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
122
149
  return (message, ...args) => {
123
- if (!isDebug()) return;
124
- const method = getConsoleMethod(consoleLike, level.method);
125
- const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`;
126
- const messageStyle = getForegroundStyle(colors, level.color);
127
- method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
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
+ }
128
168
  };
129
169
  }
130
170
  function createLoggerMethods(options) {
131
171
  const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
132
- 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)]));
133
173
  }
134
174
 
135
175
  //#endregion
@@ -151,13 +191,16 @@ function createChalk(options = {}) {
151
191
  const colors = createColorMap(options.colors);
152
192
  const isDebug = resolveDebugPredicate(options.isDebug);
153
193
  const banner = createBannerMethods(consoleLike, isDebug);
194
+ const hooks = [];
195
+ const getHooks = () => hooks;
154
196
  const loggers = createLoggerMethods({
155
197
  console: consoleLike,
156
198
  colors,
157
199
  isDebug,
158
- logLevels: options.logLevels
200
+ logLevels: options.logLevels,
201
+ getHooks
159
202
  });
160
- return {
203
+ const instance = {
161
204
  add,
162
205
  bold,
163
206
  ...banner,
@@ -186,8 +229,13 @@ function createChalk(options = {}) {
186
229
  ready: loggers.ready,
187
230
  info: loggers.info,
188
231
  event: loggers.event,
189
- debug: loggers.debug
232
+ debug: loggers.debug,
233
+ use(hook) {
234
+ hooks.push(hook);
235
+ return instance;
236
+ }
190
237
  };
238
+ return instance;
191
239
  }
192
240
 
193
241
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["DEFAULT_COLORS: ColorMap","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\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#000000',\n red: '#FF0000',\n green: '#008000',\n yellow: '#FFFF00',\n blue: '#0000FF',\n magenta: '#FF00FF',\n cyan: '#00FFFF',\n white: '#FFFFFF',\n gray: '#808080',\n}\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\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n return `color:${resolveColor(colors, name)}`\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const textColor = name === 'white' ? '#000' : '#fff'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${resolveColor(colors, name)};`\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: #fff; background: #606060; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; 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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,QAAQ,KAAK;EAC7C,YAAW,SAAQA,UAAQ,QAAQ,WAAW,KAAK;EACnD,SAAQ,SAAQA,UAAQ,QAAQ,QAAQ,KAAK;EAC7C,UAAS,SAAQA,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,MAA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KAAK;EAC7C,YAAW,SAAQA,UAAQ,QAAQ,WAAW,KAAK;EACnD,SAAQ,SAAQA,UAAQ,QAAQ,QAAQ,KAAK;EAC7C,UAAS,SAAQA,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;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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jacob-z/chalk",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "1.1.0",
5
5
  "description": "Browser console coloring utilities compatible with alita/chalk behavior.",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,