nightingale-browser-console-formatter 14.2.1 → 16.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [16.0.0](https://github.com/christophehurpeau/nightingale/compare/v15.0.0...v16.0.0) (2025-03-30)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * drop node 18
11
+
12
+ ### Features
13
+
14
+ * drop node 18 ([1b11a55](https://github.com/christophehurpeau/nightingale/commit/1b11a55dd24c9435be50519a748316079f554414))
15
+
16
+ ### Bug Fixes
17
+
18
+ * fix lib exports ([5b562b2](https://github.com/christophehurpeau/nightingale/commit/5b562b245aac1aa86b728a9433f3c9d28c62fe04))
19
+
20
+ Version bump for dependency: nightingale
21
+
22
+
23
+ ## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
24
+
25
+
26
+ ### ⚠ BREAKING CHANGES
27
+
28
+ * update babel and drop browser modern version
29
+
30
+ ### Features
31
+
32
+ * update babel and drop browser modern version ([5c76abc](https://github.com/christophehurpeau/nightingale/commit/5c76abc8bfb595a617fc4c8b795dae7e674ea664))
33
+
34
+ Version bump for dependency: nightingale-formatter
35
+ Version bump for dependency: nightingale-types
36
+ Version bump for dependency: nightingale-levels
37
+
38
+
6
39
  ## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
7
40
 
8
41
  Note: no notable changes
package/README.md CHANGED
@@ -1,27 +1,30 @@
1
- <h3 align="center">
1
+ <h1 align="center">
2
2
  nightingale-browser-console-formatter
3
- </h3>
3
+ </h1>
4
4
 
5
5
  <p align="center">
6
- Nightingale Browser console formatter
6
+ Deprecated: use NightingaleBrowserConsoleFormatter from nightingale
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/v/nightingale-browser-console-formatter.svg?style=flat-square"></a>
11
- <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/dw/nightingale-browser-console-formatter.svg?style=flat-square"></a>
12
- <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/node/v/nightingale-browser-console-formatter.svg?style=flat-square"></a>
13
- <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/types/nightingale-browser-console-formatter.svg?style=flat-square"></a>
10
+ <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/v/nightingale-browser-console-formatter.svg?style=flat-square" alt="npm version"></a>
11
+ <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/dw/nightingale-browser-console-formatter.svg?style=flat-square" alt="npm downloads"></a>
12
+ <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/node/v/nightingale-browser-console-formatter.svg?style=flat-square" alt="node version"></a>
13
+ <a href="https://npmjs.org/package/nightingale-browser-console-formatter"><img src="https://img.shields.io/npm/types/nightingale-browser-console-formatter.svg?style=flat-square" alt="types"></a>
14
14
  <a href="https://codecov.io/gh/christophehurpeau/nightingale"><img src="https://img.shields.io/codecov/c/github/christophehurpeau/nightingale/master.svg?style=flat-square"></a>
15
15
  </p>
16
16
 
17
17
  ## Install
18
18
 
19
19
  ```sh
20
- npm install --save nightingale-browser-console-formatter
20
+ npm install --save nightingale
21
21
  ```
22
22
 
23
23
  ## Usage
24
24
 
25
25
  ```js
26
- import browserConsoleFormatter from 'nightingale-browser-console-formatter';
26
+ import { NightingaleBrowserConsoleFormatter } from "nightingale";
27
+
28
+ const formatter = new NightingaleBrowserConsoleFormatter("light");
29
+ formatter.format(record);
27
30
  ```
package/lib/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { BrowserConsoleFormatter } from "nightingale";
2
+
3
+ /**
4
+ *
5
+ * param is dark or light
6
+ * @param {"light" | "dark"} [theme="light"]
7
+ * @returns {import("nightingale").StringArrayNightingaleFormatter["format"]}
8
+ */
9
+ export default function createBrowserConsoleFormatter(theme = "light") {
10
+ const formatter = new BrowserConsoleFormatter(theme);
11
+ return (record) => formatter.format(record);
12
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nightingale-browser-console-formatter",
3
- "version": "14.2.1",
4
- "description": "Nightingale Browser console formatter",
3
+ "version": "16.0.0",
4
+ "description": "Deprecated: use NightingaleBrowserConsoleFormatter from nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
7
7
  "nightingale-formatter"
@@ -16,79 +16,28 @@
16
16
  "homepage": "https://github.com/christophehurpeau/nightingale",
17
17
  "type": "module",
18
18
  "engines": {
19
- "node": ">=18.12.0"
19
+ "node": ">=20.9.0"
20
20
  },
21
- "browserslist": {
22
- "production": [
23
- "defaults",
24
- "> 0.2%",
25
- "not ie < 12",
26
- "not safari < 10",
27
- "not ios_saf < 10"
28
- ]
29
- },
30
- "main": "./dist/index-node18.mjs",
31
- "types": "./dist/definitions/index.d.ts",
32
- "module": "./dist/index-browser.es.js",
33
- "browser": "./dist/index-browser.es.js",
21
+ "sideEffects": false,
22
+ "main": "./lib/index.js",
23
+ "types": "./lib/index.d.ts",
34
24
  "exports": {
35
25
  "./package.json": "./package.json",
36
- ".": {
37
- "types": "./dist/definitions/index.d.ts",
38
- "node": {
39
- "import": "./dist/index-node18.mjs"
40
- },
41
- "browser": {
42
- "browser:modern": {
43
- "import": "./dist/index-browsermodern.es.js"
44
- },
45
- "import": "./dist/index-browser.es.js"
46
- }
47
- }
26
+ ".": "./lib/index.js"
48
27
  },
49
- "sideEffects": false,
50
28
  "files": [
51
- "src",
52
- "dist"
29
+ "lib"
53
30
  ],
54
31
  "scripts": {
55
- "build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
56
- "build:definitions": "tsc -p tsconfig.json",
57
32
  "clean": "yarn clean:build",
58
- "clean:build": "pob-babel-clean-out dist",
59
33
  "lint": "yarn run lint:eslint",
60
- "lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-browser-console-formatter",
34
+ "lint:eslint": "yarn ../.. run eslint --quiet packages/nightingale-browser-console-formatter",
61
35
  "test": "yarn ../../ run test -- packages/nightingale-browser-console-formatter",
62
36
  "watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
63
37
  },
38
+ "pob": {},
64
39
  "prettier": "@pob/root/prettier-config",
65
- "pob": {
66
- "babelEnvs": [
67
- {
68
- "target": "node",
69
- "version": "18"
70
- },
71
- {
72
- "target": "browser",
73
- "version": "modern"
74
- },
75
- {
76
- "target": "browser"
77
- }
78
- ],
79
- "entries": [
80
- "index"
81
- ]
82
- },
83
40
  "dependencies": {
84
- "nightingale-formatter": "14.2.1",
85
- "nightingale-types": "14.2.1"
86
- },
87
- "devDependencies": {
88
- "@babel/core": "7.23.2",
89
- "@babel/preset-env": "7.23.2",
90
- "nightingale-levels": "14.2.1",
91
- "pob-babel": "36.6.1",
92
- "typescript": "5.2.2"
41
+ "nightingale": "16.0.0"
93
42
  }
94
43
  }
@@ -1,5 +0,0 @@
1
- import type { StyleToHtmlStyle } from 'nightingale-formatter';
2
- import type { LogRecord, Metadata, Styles } from 'nightingale-types';
3
- export declare const style: (styleToHtmlStyle: StyleToHtmlStyle, args: string[]) => (styles: Styles, string: string) => string;
4
- export declare function createBrowserConsoleFormatter(theme?: 'dark' | 'light'): <T extends Metadata>(record: LogRecord<T>) => string[];
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM9D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAErE,eAAO,MAAM,KAAK,qBACG,gBAAgB,QAAQ,MAAM,EAAE,cAC1C,MAAM,UAAU,MAAM,KAAG,MAWjC,CAAC;AAEJ,wBAAgB,6BAA6B,CAC3C,KAAK,GAAE,MAAM,GAAG,OAAiB,GAChC,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAQxD"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/index.test.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- import { formatRecordToString, styleToHtmlStyleThemeDark, styleToHtmlStyleThemeLight } from 'nightingale-formatter';
2
-
3
- var style = function style(styleToHtmlStyle, args) {
4
- return function (styles, string) {
5
- if (!styles || styles.length === 0 || !string) {
6
- return string;
7
- }
8
- var htmlStyles = styles.map(function (styleName) {
9
- return styleToHtmlStyle[styleName];
10
- });
11
- args.push(htmlStyles.map(function (s) {
12
- return s.open;
13
- }).join('; '), htmlStyles.map(function (s) {
14
- return s.close;
15
- }).join('; '));
16
- return "%c" + string + "%c";
17
- };
18
- };
19
- function createBrowserConsoleFormatter(theme) {
20
- if (theme === void 0) {
21
- theme = 'light';
22
- }
23
- var styleToHtmlStyle = theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;
24
- return function format(record) {
25
- var args = [];
26
- var string = formatRecordToString(record, style(styleToHtmlStyle, args));
27
- return [string].concat(args);
28
- };
29
- }
30
-
31
- export { createBrowserConsoleFormatter, style };
32
- //# sourceMappingURL=index-browser.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["import type { StyleToHtmlStyle } from 'nightingale-formatter';\nimport {\n formatRecordToString,\n styleToHtmlStyleThemeLight,\n styleToHtmlStyleThemeDark,\n} from 'nightingale-formatter';\nimport type { LogRecord, Metadata, Styles } from 'nightingale-types';\n\nexport const style =\n (styleToHtmlStyle: StyleToHtmlStyle, args: string[]) =>\n (styles: Styles, string: string): string => {\n if (!styles || styles.length === 0 || !string) {\n return string;\n }\n\n const htmlStyles = styles.map((styleName) => styleToHtmlStyle[styleName]);\n args.push(\n htmlStyles.map((s) => s.open).join('; '),\n htmlStyles.map((s) => s.close).join('; '),\n );\n return `%c${string}%c`;\n };\n\nexport function createBrowserConsoleFormatter(\n theme: 'dark' | 'light' = 'light',\n): <T extends Metadata>(record: LogRecord<T>) => string[] {\n const styleToHtmlStyle: StyleToHtmlStyle =\n theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;\n return function format<T extends Metadata>(record: LogRecord<T>): string[] {\n const args: string[] = [];\n const string = formatRecordToString(record, style(styleToHtmlStyle, args));\n return [string, ...args];\n };\n}\n"],"names":["style","styleToHtmlStyle","args","styles","string","length","htmlStyles","map","styleName","push","s","open","join","close","createBrowserConsoleFormatter","theme","styleToHtmlStyleThemeDark","styleToHtmlStyleThemeLight","format","record","formatRecordToString","concat"],"mappings":";;AAQO,IAAMA,KAAK,GAChB,SADWA,KAAKA,CACfC,gBAAkC,EAAEC,IAAc,EAAA;AAAA,EAAA,OACnD,UAACC,MAAc,EAAEC,MAAc,EAAa;IAC1C,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,MAAM,KAAK,CAAC,IAAI,CAACD,MAAM,EAAE;AAC7C,MAAA,OAAOA,MAAM,CAAA;AACf,KAAA;AAEA,IAAA,IAAME,UAAU,GAAGH,MAAM,CAACI,GAAG,CAAC,UAACC,SAAS,EAAA;MAAA,OAAKP,gBAAgB,CAACO,SAAS,CAAC,CAAA;KAAC,CAAA,CAAA;IACzEN,IAAI,CAACO,IAAI,CACPH,UAAU,CAACC,GAAG,CAAC,UAACG,CAAC,EAAA;MAAA,OAAKA,CAAC,CAACC,IAAI,CAAA;KAAC,CAAA,CAACC,IAAI,CAAC,IAAI,CAAC,EACxCN,UAAU,CAACC,GAAG,CAAC,UAACG,CAAC,EAAA;MAAA,OAAKA,CAAC,CAACG,KAAK,CAAA;AAAA,KAAA,CAAC,CAACD,IAAI,CAAC,IAAI,CAC1C,CAAC,CAAA;AACD,IAAA,OAAA,IAAA,GAAYR,MAAM,GAAA,IAAA,CAAA;GACnB,CAAA;AAAA,EAAA;AAEI,SAASU,6BAA6BA,CAC3CC,KAAuB,EACiC;AAAA,EAAA,IADxDA,KAAuB,KAAA,KAAA,CAAA,EAAA;AAAvBA,IAAAA,KAAuB,GAAG,OAAO,CAAA;AAAA,GAAA;EAEjC,IAAMd,gBAAkC,GACtCc,KAAK,KAAK,MAAM,GAAGC,yBAAyB,GAAGC,0BAA0B,CAAA;AAC3E,EAAA,OAAO,SAASC,MAAMA,CAAqBC,MAAoB,EAAY;IACzE,IAAMjB,IAAc,GAAG,EAAE,CAAA;AACzB,IAAA,IAAME,MAAM,GAAGgB,oBAAoB,CAACD,MAAM,EAAEnB,KAAK,CAACC,gBAAgB,EAAEC,IAAI,CAAC,CAAC,CAAA;AAC1E,IAAA,OAAA,CAAQE,MAAM,CAAA,CAAAiB,MAAA,CAAKnB,IAAI,CAAA,CAAA;GACxB,CAAA;AACH;;;;"}
@@ -1,21 +0,0 @@
1
- import { formatRecordToString, styleToHtmlStyleThemeDark, styleToHtmlStyleThemeLight } from 'nightingale-formatter';
2
-
3
- const style = (styleToHtmlStyle, args) => (styles, string) => {
4
- if (!styles || styles.length === 0 || !string) {
5
- return string;
6
- }
7
- const htmlStyles = styles.map(styleName => styleToHtmlStyle[styleName]);
8
- args.push(htmlStyles.map(s => s.open).join('; '), htmlStyles.map(s => s.close).join('; '));
9
- return `%c${string}%c`;
10
- };
11
- function createBrowserConsoleFormatter(theme = 'light') {
12
- const styleToHtmlStyle = theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;
13
- return function format(record) {
14
- const args = [];
15
- const string = formatRecordToString(record, style(styleToHtmlStyle, args));
16
- return [string, ...args];
17
- };
18
- }
19
-
20
- export { createBrowserConsoleFormatter, style };
21
- //# sourceMappingURL=index-browsermodern.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-browsermodern.es.js","sources":["../src/index.ts"],"sourcesContent":["import type { StyleToHtmlStyle } from 'nightingale-formatter';\nimport {\n formatRecordToString,\n styleToHtmlStyleThemeLight,\n styleToHtmlStyleThemeDark,\n} from 'nightingale-formatter';\nimport type { LogRecord, Metadata, Styles } from 'nightingale-types';\n\nexport const style =\n (styleToHtmlStyle: StyleToHtmlStyle, args: string[]) =>\n (styles: Styles, string: string): string => {\n if (!styles || styles.length === 0 || !string) {\n return string;\n }\n\n const htmlStyles = styles.map((styleName) => styleToHtmlStyle[styleName]);\n args.push(\n htmlStyles.map((s) => s.open).join('; '),\n htmlStyles.map((s) => s.close).join('; '),\n );\n return `%c${string}%c`;\n };\n\nexport function createBrowserConsoleFormatter(\n theme: 'dark' | 'light' = 'light',\n): <T extends Metadata>(record: LogRecord<T>) => string[] {\n const styleToHtmlStyle: StyleToHtmlStyle =\n theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;\n return function format<T extends Metadata>(record: LogRecord<T>): string[] {\n const args: string[] = [];\n const string = formatRecordToString(record, style(styleToHtmlStyle, args));\n return [string, ...args];\n };\n}\n"],"names":["style","styleToHtmlStyle","args","styles","string","length","htmlStyles","map","styleName","push","s","open","join","close","createBrowserConsoleFormatter","theme","styleToHtmlStyleThemeDark","styleToHtmlStyleThemeLight","format","record","formatRecordToString"],"mappings":";;AAQaA,MAAAA,KAAK,GAChBA,CAACC,gBAAkC,EAAEC,IAAc,KACnD,CAACC,MAAc,EAAEC,MAAc,KAAa;EAC1C,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,MAAM,KAAK,CAAC,IAAI,CAACD,MAAM,EAAE;AAC7C,IAAA,OAAOA,MAAM,CAAA;AACf,GAAA;AAEA,EAAA,MAAME,UAAU,GAAGH,MAAM,CAACI,GAAG,CAAEC,SAAS,IAAKP,gBAAgB,CAACO,SAAS,CAAC,CAAC,CAAA;AACzEN,EAAAA,IAAI,CAACO,IAAI,CACPH,UAAU,CAACC,GAAG,CAAEG,CAAC,IAAKA,CAAC,CAACC,IAAI,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,EACxCN,UAAU,CAACC,GAAG,CAAEG,CAAC,IAAKA,CAAC,CAACG,KAAK,CAAC,CAACD,IAAI,CAAC,IAAI,CAC1C,CAAC,CAAA;EACD,OAAQ,CAAA,EAAA,EAAIR,MAAO,CAAG,EAAA,CAAA,CAAA;AACxB,EAAC;AAEI,SAASU,6BAA6BA,CAC3CC,KAAuB,GAAG,OAAO,EACuB;EACxD,MAAMd,gBAAkC,GACtCc,KAAK,KAAK,MAAM,GAAGC,yBAAyB,GAAGC,0BAA0B,CAAA;AAC3E,EAAA,OAAO,SAASC,MAAMA,CAAqBC,MAAoB,EAAY;IACzE,MAAMjB,IAAc,GAAG,EAAE,CAAA;AACzB,IAAA,MAAME,MAAM,GAAGgB,oBAAoB,CAACD,MAAM,EAAEnB,KAAK,CAACC,gBAAgB,EAAEC,IAAI,CAAC,CAAC,CAAA;AAC1E,IAAA,OAAO,CAACE,MAAM,EAAE,GAAGF,IAAI,CAAC,CAAA;GACzB,CAAA;AACH;;;;"}
@@ -1,21 +0,0 @@
1
- import { formatRecordToString, styleToHtmlStyleThemeDark, styleToHtmlStyleThemeLight } from 'nightingale-formatter';
2
-
3
- const style = (styleToHtmlStyle, args) => (styles, string) => {
4
- if (!styles || styles.length === 0 || !string) {
5
- return string;
6
- }
7
- const htmlStyles = styles.map(styleName => styleToHtmlStyle[styleName]);
8
- args.push(htmlStyles.map(s => s.open).join('; '), htmlStyles.map(s => s.close).join('; '));
9
- return `%c${string}%c`;
10
- };
11
- function createBrowserConsoleFormatter(theme = 'light') {
12
- const styleToHtmlStyle = theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;
13
- return function format(record) {
14
- const args = [];
15
- const string = formatRecordToString(record, style(styleToHtmlStyle, args));
16
- return [string, ...args];
17
- };
18
- }
19
-
20
- export { createBrowserConsoleFormatter, style };
21
- //# sourceMappingURL=index-node18.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node18.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { StyleToHtmlStyle } from 'nightingale-formatter';\nimport {\n formatRecordToString,\n styleToHtmlStyleThemeLight,\n styleToHtmlStyleThemeDark,\n} from 'nightingale-formatter';\nimport type { LogRecord, Metadata, Styles } from 'nightingale-types';\n\nexport const style =\n (styleToHtmlStyle: StyleToHtmlStyle, args: string[]) =>\n (styles: Styles, string: string): string => {\n if (!styles || styles.length === 0 || !string) {\n return string;\n }\n\n const htmlStyles = styles.map((styleName) => styleToHtmlStyle[styleName]);\n args.push(\n htmlStyles.map((s) => s.open).join('; '),\n htmlStyles.map((s) => s.close).join('; '),\n );\n return `%c${string}%c`;\n };\n\nexport function createBrowserConsoleFormatter(\n theme: 'dark' | 'light' = 'light',\n): <T extends Metadata>(record: LogRecord<T>) => string[] {\n const styleToHtmlStyle: StyleToHtmlStyle =\n theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;\n return function format<T extends Metadata>(record: LogRecord<T>): string[] {\n const args: string[] = [];\n const string = formatRecordToString(record, style(styleToHtmlStyle, args));\n return [string, ...args];\n };\n}\n"],"names":["style","styleToHtmlStyle","args","styles","string","length","htmlStyles","map","styleName","push","s","open","join","close","createBrowserConsoleFormatter","theme","styleToHtmlStyleThemeDark","styleToHtmlStyleThemeLight","format","record","formatRecordToString"],"mappings":";;AAQaA,MAAAA,KAAK,GAChBA,CAACC,gBAAkC,EAAEC,IAAc,KACnD,CAACC,MAAc,EAAEC,MAAc,KAAa;EAC1C,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,MAAM,KAAK,CAAC,IAAI,CAACD,MAAM,EAAE;AAC7C,IAAA,OAAOA,MAAM,CAAA;AACf,GAAA;AAEA,EAAA,MAAME,UAAU,GAAGH,MAAM,CAACI,GAAG,CAAEC,SAAS,IAAKP,gBAAgB,CAACO,SAAS,CAAC,CAAC,CAAA;AACzEN,EAAAA,IAAI,CAACO,IAAI,CACPH,UAAU,CAACC,GAAG,CAAEG,CAAC,IAAKA,CAAC,CAACC,IAAI,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,EACxCN,UAAU,CAACC,GAAG,CAAEG,CAAC,IAAKA,CAAC,CAACG,KAAK,CAAC,CAACD,IAAI,CAAC,IAAI,CAC1C,CAAC,CAAA;EACD,OAAQ,CAAA,EAAA,EAAIR,MAAO,CAAG,EAAA,CAAA,CAAA;AACxB,EAAC;AAEI,SAASU,6BAA6BA,CAC3CC,KAAuB,GAAG,OAAO,EACuB;EACxD,MAAMd,gBAAkC,GACtCc,KAAK,KAAK,MAAM,GAAGC,yBAAyB,GAAGC,0BAA0B,CAAA;AAC3E,EAAA,OAAO,SAASC,MAAMA,CAAqBC,MAAoB,EAAY;IACzE,MAAMjB,IAAc,GAAG,EAAE,CAAA;AACzB,IAAA,MAAME,MAAM,GAAGgB,oBAAoB,CAACD,MAAM,EAAEnB,KAAK,CAACC,gBAAgB,EAAEC,IAAI,CAAC,CAAC,CAAA;AAC1E,IAAA,OAAO,CAACE,MAAM,EAAE,GAAGF,IAAI,CAAC,CAAA;GACzB,CAAA;AACH;;;;"}
@@ -1,27 +0,0 @@
1
- {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "parserOptions": {
5
- "project": "packages/nightingale-browser-console-formatter/tsconfig.json"
6
- },
7
- "plugins": ["@typescript-eslint"],
8
- "extends": ["@pob/eslint-config-typescript"],
9
- "ignorePatterns": ["*.d.ts"],
10
- "overrides": [
11
- {
12
- "files": ["**/*.test.ts", "__tests__/**/*.ts"],
13
- "extends": ["@pob/eslint-config-typescript/test"],
14
- "env": {
15
- "jest": true
16
- },
17
- "rules": {
18
- "import/no-extraneous-dependencies": [
19
- "error",
20
- {
21
- "devDependencies": true
22
- }
23
- ]
24
- }
25
- }
26
- ]
27
- }
package/src/index.test.ts DELETED
@@ -1,59 +0,0 @@
1
- import type { StyleToHtmlStyle } from 'nightingale-formatter';
2
- import { styleToHtmlStyleThemeLight } from 'nightingale-formatter';
3
- import { Level } from 'nightingale-levels';
4
- import { createBrowserConsoleFormatter, style } from '.';
5
-
6
- const styleToHtmlStyle: StyleToHtmlStyle = styleToHtmlStyleThemeLight;
7
- const formatWithLightTheme = createBrowserConsoleFormatter('light');
8
- const formatWithDarkTheme = createBrowserConsoleFormatter('dark');
9
-
10
- test('style: blue bold color', () => {
11
- const args: string[] = [];
12
- expect(style(styleToHtmlStyle, args)(['blue', 'bold'], 'test')).toBe(
13
- '%ctest%c',
14
- );
15
- expect(args).toEqual([
16
- 'color: #00a0ff; font-weight: bold',
17
- 'color: currentcolor; font-weight: normal',
18
- ]);
19
- });
20
-
21
- test('format simple message, with light theme', () => {
22
- const record = {
23
- key: 'record.key',
24
- level: Level.INFO,
25
- datetime: new Date(2000, 1, 1, 1, 0, 0),
26
- message: 'test',
27
- metadata: {},
28
- extra: {},
29
- };
30
-
31
- const [string, ...args] = formatWithLightTheme(record);
32
- expect(string).toBe('%crecord.key%c %c01:00:00%c → test');
33
- expect(args).toEqual([
34
- 'color: #808080',
35
- 'color: currentcolor',
36
- 'color: gray; font-weight: bold',
37
- 'color: currentcolor; font-weight: normal',
38
- ]);
39
- });
40
-
41
- test('format simple message, with dark theme', () => {
42
- const record = {
43
- key: 'record.key',
44
- level: Level.INFO,
45
- datetime: new Date(2000, 1, 1, 1, 0, 0),
46
- message: 'test',
47
- metadata: {},
48
- extra: {},
49
- };
50
-
51
- const [string, ...args] = formatWithDarkTheme(record);
52
- expect(string).toBe('%crecord.key%c %c01:00:00%c → test');
53
- expect(args).toEqual([
54
- 'color: #808080',
55
- 'color: currentcolor',
56
- 'color: lightgray; font-weight: bold',
57
- 'color: currentcolor; font-weight: normal',
58
- ]);
59
- });
package/src/index.ts DELETED
@@ -1,34 +0,0 @@
1
- import type { StyleToHtmlStyle } from 'nightingale-formatter';
2
- import {
3
- formatRecordToString,
4
- styleToHtmlStyleThemeLight,
5
- styleToHtmlStyleThemeDark,
6
- } from 'nightingale-formatter';
7
- import type { LogRecord, Metadata, Styles } from 'nightingale-types';
8
-
9
- export const style =
10
- (styleToHtmlStyle: StyleToHtmlStyle, args: string[]) =>
11
- (styles: Styles, string: string): string => {
12
- if (!styles || styles.length === 0 || !string) {
13
- return string;
14
- }
15
-
16
- const htmlStyles = styles.map((styleName) => styleToHtmlStyle[styleName]);
17
- args.push(
18
- htmlStyles.map((s) => s.open).join('; '),
19
- htmlStyles.map((s) => s.close).join('; '),
20
- );
21
- return `%c${string}%c`;
22
- };
23
-
24
- export function createBrowserConsoleFormatter(
25
- theme: 'dark' | 'light' = 'light',
26
- ): <T extends Metadata>(record: LogRecord<T>) => string[] {
27
- const styleToHtmlStyle: StyleToHtmlStyle =
28
- theme === 'dark' ? styleToHtmlStyleThemeDark : styleToHtmlStyleThemeLight;
29
- return function format<T extends Metadata>(record: LogRecord<T>): string[] {
30
- const args: string[] = [];
31
- const string = formatRecordToString(record, style(styleToHtmlStyle, args));
32
- return [string, ...args];
33
- };
34
- }