heading-case 1.1.5 → 1.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -5
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1788,8 +1788,13 @@ const LOG_TYPES = {
1788
1788
  },
1789
1789
  debug: createLogType('debug', 'verbose', color.magenta)
1790
1790
  };
1791
+ const ANSI_REGEXP = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, 'g');
1792
+ const stripAnsi = (text)=>text.replace(ANSI_REGEXP, '');
1791
1793
  const errorStackRegExp = /at [^\r\n]{0,200}(?::\d+:\d+[\s)]*|\(<anonymous>\)|\(index\s\d+\))$/;
1792
- const isErrorStackMessage = (message)=>errorStackRegExp.test(message);
1794
+ const isErrorStackMessage = (message)=>{
1795
+ const stripped = stripAnsi(message);
1796
+ return errorStackRegExp.test(stripped);
1797
+ };
1793
1798
  const normalizeErrorMessage = (err)=>{
1794
1799
  if (err.stack) {
1795
1800
  const [rawName, ...rest] = err.stack.split('\n');
@@ -1799,7 +1804,7 @@ const normalizeErrorMessage = (err)=>{
1799
1804
  return err.message;
1800
1805
  };
1801
1806
  const createLogger = (options = {})=>{
1802
- const { level = 'info', prefix, console: console1 = globalThis.console } = options;
1807
+ const { level = 'info', prefix, console: console1 = globalThis.console, alignMultiline } = options;
1803
1808
  let maxLevel = level;
1804
1809
  const log = (type, message, ...args)=>{
1805
1810
  const logType = LOG_TYPES[type];
@@ -1807,8 +1812,10 @@ const createLogger = (options = {})=>{
1807
1812
  if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
1808
1813
  if (null == message) return console1.log();
1809
1814
  const label = 'label' in logType ? logType.label : '';
1815
+ const header = label ? prefix ? `${label} ${prefix}` : label : prefix;
1810
1816
  let text = '';
1811
- if (message instanceof Error) {
1817
+ const isErrorObject = message instanceof Error;
1818
+ if (isErrorObject) {
1812
1819
  text += normalizeErrorMessage(message);
1813
1820
  const { cause } = message;
1814
1821
  if (cause) {
@@ -1819,9 +1826,13 @@ const createLogger = (options = {})=>{
1819
1826
  const lines = message.split('\n');
1820
1827
  text = lines.map((line)=>isErrorStackMessage(line) ? color.gray(line) : line).join('\n');
1821
1828
  } else text = `${message}`;
1822
- if (prefix) text = `${prefix} ${text}`;
1829
+ if (alignMultiline && header && !isErrorObject && text.includes('\n')) {
1830
+ const indent = ' '.repeat(stripAnsi(header).length + 1);
1831
+ const skipStack = 'error' === level;
1832
+ text = text.split('\n').map((line, i)=>0 === i || '' === line || skipStack && isErrorStackMessage(line) ? line : indent + line).join('\n');
1833
+ }
1823
1834
  const method = 'error' === level || 'warn' === level ? level : 'log';
1824
- console1[method](label ? `${label} ${text}` : text, ...args);
1835
+ console1[method](header ? `${header} ${text}` : text, ...args);
1825
1836
  };
1826
1837
  const logger = {
1827
1838
  greet: (message)=>log('log', boldMint(message))
@@ -2615,8 +2626,10 @@ const dict = [
2615
2626
  'API Report File',
2616
2627
  'App Router',
2617
2628
  'Babel',
2629
+ 'Baseline',
2618
2630
  'Create React App',
2619
2631
  'Cloudflare Pages',
2632
+ 'Cloudflare Workers',
2620
2633
  'CSS Modules',
2621
2634
  'Coding Agent',
2622
2635
  'Coding Agents',
@@ -2639,6 +2652,7 @@ const dict = [
2639
2652
  'Open Graph',
2640
2653
  'Page Router',
2641
2654
  'Parcel',
2655
+ 'Playwright',
2642
2656
  'Preact',
2643
2657
  'Preact Refresh',
2644
2658
  'Relay',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heading-case",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rstackjs/heading-case"
@@ -25,14 +25,14 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rslib/core": "^0.23.2",
28
- "@rslint/core": "^0.6.5",
29
- "@rstest/core": "^0.11.1",
28
+ "@rslint/core": "^0.8.0",
29
+ "@rstest/core": "^0.11.8",
30
30
  "@types/node": "^24.13.3",
31
31
  "case-police": "^2.2.1",
32
32
  "pathe": "^2.0.3",
33
33
  "picocolors": "^1.1.1",
34
- "prettier": "^3.9.5",
35
- "rslog": "^2.2.0",
34
+ "prettier": "^3.9.6",
35
+ "rslog": "^2.3.0",
36
36
  "simple-git-hooks": "^2.13.1",
37
37
  "tinyglobby": "^0.2.17",
38
38
  "typescript": "^7.0.2"