rslog 1.2.9 → 1.2.11

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.
@@ -0,0 +1,8 @@
1
+ export type ColorFn = (input: string | number | null | undefined) => string;
2
+ export declare const bold: ColorFn;
3
+ export declare const red: ColorFn;
4
+ export declare const green: ColorFn;
5
+ export declare const yellow: ColorFn;
6
+ export declare const magenta: ColorFn;
7
+ export declare const cyan: ColorFn;
8
+ export declare const gray: ColorFn;
@@ -0,0 +1,48 @@
1
+ export declare let LOG_LEVEL: {
2
+ readonly silent: -1;
3
+ readonly error: 0;
4
+ readonly warn: 1;
5
+ readonly info: 2;
6
+ readonly log: 2;
7
+ readonly verbose: 3;
8
+ };
9
+ export declare let LOG_TYPES: {
10
+ error: {
11
+ label: string;
12
+ level: "error";
13
+ color: import("./color.js").ColorFn;
14
+ };
15
+ warn: {
16
+ label: string;
17
+ level: "warn";
18
+ color: import("./color.js").ColorFn;
19
+ };
20
+ info: {
21
+ label: string;
22
+ level: "info";
23
+ color: import("./color.js").ColorFn;
24
+ };
25
+ start: {
26
+ label: string;
27
+ level: "info";
28
+ color: import("./color.js").ColorFn;
29
+ };
30
+ ready: {
31
+ label: string;
32
+ level: "info";
33
+ color: import("./color.js").ColorFn;
34
+ };
35
+ success: {
36
+ label: string;
37
+ level: "info";
38
+ color: import("./color.js").ColorFn;
39
+ };
40
+ log: {
41
+ level: "info";
42
+ };
43
+ debug: {
44
+ label: string;
45
+ level: "verbose";
46
+ color: import("./color.js").ColorFn;
47
+ };
48
+ };
@@ -0,0 +1,2 @@
1
+ import type { Options, Logger } from './types.js';
2
+ export declare let createLogger: (options?: Options) => Logger;
@@ -0,0 +1 @@
1
+ export declare let gradient: (message: string) => string;
package/dist/index.cjs CHANGED
@@ -99,6 +99,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
99
99
  if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
100
100
  if ('truecolor' === env.COLORTERM) return 3;
101
101
  if ('xterm-kitty' === env.TERM) return 3;
102
+ if ('xterm-ghostty' === env.TERM) return 3;
102
103
  if ('TERM_PROGRAM' in env) {
103
104
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
104
105
  switch(env.TERM_PROGRAM){
package/dist/index.d.ts CHANGED
@@ -1,72 +1,4 @@
1
- declare type ColorFn = (input: string | number | null | undefined) => string;
2
-
3
- export declare let createLogger: (options?: Options) => Logger;
4
-
5
- declare let LOG_TYPES: {
6
- error: {
7
- label: string;
8
- level: "error";
9
- color: ColorFn;
10
- };
11
- warn: {
12
- label: string;
13
- level: "warn";
14
- color: ColorFn;
15
- };
16
- info: {
17
- label: string;
18
- level: "info";
19
- color: ColorFn;
20
- };
21
- start: {
22
- label: string;
23
- level: "info";
24
- color: ColorFn;
25
- };
26
- ready: {
27
- label: string;
28
- level: "info";
29
- color: ColorFn;
30
- };
31
- success: {
32
- label: string;
33
- level: "info";
34
- color: ColorFn;
35
- };
36
- log: {
37
- level: "info";
38
- };
39
- debug: {
40
- label: string;
41
- level: "verbose";
42
- color: ColorFn;
43
- };
44
- };
45
-
46
- export declare type LogFunction = (message?: LogMessage, ...args: any[]) => void;
47
-
48
- export declare type Logger = Record<LogMethods, LogFunction> & {
49
- greet: (message: string) => void;
50
- level: LogLevel;
51
- override: (customLogger: Partial<Record<LogMethods, LogFunction>>) => void;
52
- };
53
-
54
- export declare let logger: Logger;
55
-
56
- export declare type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
57
-
58
- export declare type LogMessage = unknown;
59
-
60
- declare type LogMethods = keyof typeof LOG_TYPES;
61
-
62
- export declare interface LogType {
63
- label?: string;
64
- level: LogLevel;
65
- color?: ColorFn;
66
- }
67
-
68
- export declare interface Options {
69
- level?: LogLevel;
70
- }
71
-
72
- export { }
1
+ import { createLogger } from './createLogger.js';
2
+ export { createLogger };
3
+ export declare let logger: import("./types.js").Logger;
4
+ export type { Options, Logger, LogType, LogLevel, LogMessage, LogFunction, } from './types.js';
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import external_node_process_default from "node:process";
2
- import external_node_os_default from "node:os";
3
- import external_node_tty_default from "node:tty";
4
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : external_node_process_default.argv) {
1
+ import node_process from "node:process";
2
+ import node_os from "node:os";
3
+ import node_tty from "node:tty";
4
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
5
5
  const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
6
6
  const position = argv.indexOf(prefix + flag);
7
7
  const terminatorPosition = argv.indexOf('--');
8
8
  return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
9
9
  }
10
- const { env } = external_node_process_default;
10
+ const { env } = node_process;
11
11
  let flagForceColor;
12
12
  if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
13
13
  else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
@@ -47,8 +47,8 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
47
47
  if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
48
48
  const min = forceColor || 0;
49
49
  if ('dumb' === env.TERM) return min;
50
- if ('win32' === external_node_process_default.platform) {
51
- const osRelease = external_node_os_default.release().split('.');
50
+ if ('win32' === node_process.platform) {
51
+ const osRelease = node_os.release().split('.');
52
52
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
53
53
  return 1;
54
54
  }
@@ -70,6 +70,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
70
70
  if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
71
71
  if ('truecolor' === env.COLORTERM) return 3;
72
72
  if ('xterm-kitty' === env.TERM) return 3;
73
+ if ('xterm-ghostty' === env.TERM) return 3;
73
74
  if ('TERM_PROGRAM' in env) {
74
75
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
75
76
  switch(env.TERM_PROGRAM){
@@ -93,10 +94,10 @@ function createSupportsColor(stream, options = {}) {
93
94
  }
94
95
  const supportsColor = {
95
96
  stdout: createSupportsColor({
96
- isTTY: external_node_tty_default.isatty(1)
97
+ isTTY: node_tty.isatty(1)
97
98
  }),
98
99
  stderr: createSupportsColor({
99
- isTTY: external_node_tty_default.isatty(2)
100
+ isTTY: node_tty.isatty(2)
100
101
  })
101
102
  };
102
103
  const supports_color = supportsColor;
@@ -0,0 +1,19 @@
1
+ import type { ColorFn } from './color.js';
2
+ import type { LOG_TYPES } from './constants.js';
3
+ export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
4
+ export type LogMessage = unknown;
5
+ export interface LogType {
6
+ label?: string;
7
+ level: LogLevel;
8
+ color?: ColorFn;
9
+ }
10
+ export type LogFunction = (message?: LogMessage, ...args: any[]) => void;
11
+ export interface Options {
12
+ level?: LogLevel;
13
+ }
14
+ export type LogMethods = keyof typeof LOG_TYPES;
15
+ export type Logger = Record<LogMethods, LogFunction> & {
16
+ greet: (message: string) => void;
17
+ level: LogLevel;
18
+ override: (customLogger: Partial<Record<LogMethods, LogFunction>>) => void;
19
+ };
@@ -0,0 +1,2 @@
1
+ export declare const colorLevel: import("supports-color").ColorSupportLevel;
2
+ export declare let isErrorStackMessage: (message: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rslog",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rspack-contrib/rslog.git"
@@ -25,22 +25,20 @@
25
25
  "dev": "rslib build --watch",
26
26
  "prepare": "rslib build",
27
27
  "preview": "bun run ./preview.ts",
28
- "test": "vitest"
28
+ "test": "rstest"
29
29
  },
30
30
  "devDependencies": {
31
- "@microsoft/api-extractor": "^7.52.8",
32
- "@rslib/core": "^0.9.2",
31
+ "@rslib/core": "^0.11.1",
32
+ "@rstest/core": "^0.1.0",
33
33
  "@types/node": "^22.15.31",
34
34
  "prettier": "~3.5.3",
35
35
  "strip-ansi": "^7.1.0",
36
36
  "supports-color": "^10.0.0",
37
- "typescript": "~5.8.3",
38
- "vitest": "^2.1.8"
37
+ "typescript": "~5.8.3"
39
38
  },
40
39
  "packageManager": "pnpm@10.12.1",
41
40
  "publishConfig": {
42
41
  "access": "public",
43
- "provenance": true,
44
42
  "registry": "https://registry.npmjs.org/"
45
43
  }
46
44
  }