nightingale-browser-console 11.7.0 → 12.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/.eslintrc.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "root": true,
3
- "extends": ["@pob/eslint-config/root", "@pob/eslint-config-node"],
3
+ "extends": ["@pob/eslint-config/root-commonjs"],
4
4
  "env": {
5
5
  "browser": true
6
6
  },
package/CHANGELOG.md CHANGED
@@ -3,6 +3,60 @@
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
+ # [12.0.0](https://github.com/christophehurpeau/nightingale/compare/v11.9.0...v12.0.0) (2021-12-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * typings ([2715620](https://github.com/christophehurpeau/nightingale/commit/271562032469125cf1ccb493db37117e60a0e54f))
12
+
13
+
14
+ ### Build System
15
+
16
+ * node 14 and remove dev builds ([432ecd1](https://github.com/christophehurpeau/nightingale/commit/432ecd1faafd0419f57dea00fce560e4cccc207f))
17
+
18
+
19
+ ### Features
20
+
21
+ * drop default exports ([8878e49](https://github.com/christophehurpeau/nightingale/commit/8878e492b94852fcb892fd6d12c02c15c31b38b9))
22
+
23
+
24
+ ### BREAKING CHANGES
25
+
26
+ * use named imports instead of default exports
27
+ * requires node 14
28
+
29
+
30
+
31
+
32
+
33
+ ## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
34
+
35
+ **Note:** Version bump only for package nightingale-browser-console
36
+
37
+
38
+
39
+
40
+
41
+ ## [11.7.2](https://github.com/christophehurpeau/nightingale/compare/v11.7.1...v11.7.2) (2021-11-27)
42
+
43
+ **Note:** Version bump only for package nightingale-browser-console
44
+
45
+
46
+
47
+
48
+
49
+ ## [11.7.1](https://github.com/christophehurpeau/nightingale/compare/v11.7.0...v11.7.1) (2021-06-29)
50
+
51
+
52
+ ### Bug Fixes
53
+
54
+ * update pob-babel to bring back webpack 4 support ([4887431](https://github.com/christophehurpeau/nightingale/commit/4887431b3b272496511f879af022638723b9056e))
55
+
56
+
57
+
58
+
59
+
6
60
  # [11.7.0](https://github.com/christophehurpeau/nightingale/compare/v11.6.0...v11.7.0) (2021-03-29)
7
61
 
8
62
  **Note:** Version bump only for package nightingale-browser-console
package/README.md CHANGED
@@ -20,7 +20,7 @@ npm install --save nightingale-browser-console
20
20
 
21
21
  ```js
22
22
  import { configure, levels } from 'nightingale';
23
- import ConsoleHandler from 'nightingale-browser-console';
23
+ import { ConsoleHandler } from 'nightingale-browser-console';
24
24
 
25
25
  configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
26
26
  ```
@@ -29,37 +29,35 @@ configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
29
29
 
30
30
  If you have a dark console theme, you can set this config in your localStorage :
31
31
 
32
- ```
32
+ ```js
33
33
  localStorage.NIGHTINGALE_THEME = 'dark';
34
34
  ```
35
35
 
36
36
  You can also force this option:
37
37
 
38
- ```
39
- import ConsoleHandler from 'nightingale-browser-console';
40
-
38
+ ```js
39
+ import { ConsoleHandler } from 'nightingale-browser-console';
41
40
 
42
41
  configure([{ handlers: [new ConsoleHandler(Level.INFO, { theme: 'dark' })] }]);
43
-
44
42
  ```
45
43
 
46
44
  ## Debug
47
45
 
48
46
  ### with localStorage
49
47
 
50
- ```
48
+ ```js
51
49
  localStorage.debug = '*'; // debug everything
52
50
  localStorage.debug = 'app'; // debug for logger with key 'app'
53
51
  localStorage.debug = 'app,nightingale'; // debug for logger with key 'app' and 'nightingale'
54
- localStorage.debug = '/^app/'; //debug for logger with key starting with 'app'
55
- localStorage.debug = '/^(app|nightingale$)/'; // debug for logger with key starting with 'app' and key 'nightingale'
52
+ localStorage.debug = '/^app/'; //debug for logger with key starting with 'app'
53
+ localStorage.debug = '/^(app|nightingale$)/'; // debug for logger with key starting with 'app' and key 'nightingale'
56
54
  localStorage.debug = '*,-app'; // debug everything except app
57
55
  localStorage.debug = '*,-app:*'; // debug everything except app and all its children
58
56
  ```
59
57
 
60
58
  ### with query, in the url
61
59
 
62
- ```
60
+ ```js
63
61
  ?DEBUG='*'; // debug everything
64
62
  ?DEBUG=app // debug for logger with key 'app'
65
63
  ?DEBUG=app,nightingale // debug for logger with key 'app' and 'nightingale'
@@ -68,3 +66,14 @@ localStorage.debug = '*,-app:*'; // debug everything except app and all its chil
68
66
  ?DEBUG=*,-app // debug everything except app
69
67
  ?DEBUG=*,-app:* // debug everything except app and all its children
70
68
  ```
69
+
70
+ ## Use source maps to display error stack trace
71
+
72
+ In production:
73
+
74
+ Send your log to an external tool like [sentry](https://sentry.io/). Sentry allows you to send the source maps after building (if you use webpack, you can use `hidden-source-map` to generate `.map` files, send them to sentry, and remove them so they are not accessible).
75
+
76
+ In development:
77
+
78
+ - Configure your build tool to generate sourcemaps. For webpack: use proper [`devtool` configuration](https://webpack.js.org/configuration/devtool/). For best stack trace, use `source-map` but it's the slowest option.
79
+ - Make sure your project uses [source-map-support](https://www.npmjs.com/package/source-map-support) or similar tool. If not, you can install and simply import `source-map-support/register`.
@@ -1,28 +1,30 @@
1
1
  import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';
2
2
  import consoleOutput from 'nightingale-console-output';
3
- import createFindDebugLevel from 'nightingale-debug';
3
+ import { createFindDebugLevel } from 'nightingale-debug';
4
4
 
5
5
  function getDebugString() {
6
6
  var _document$location;
7
7
 
8
- const querystring = (_document$location = document.location) == null ? void 0 : _document$location.search;
9
- const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
8
+ var querystring = (_document$location = document.location) == null ? void 0 : _document$location.search;
9
+ var debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
10
10
 
11
11
  if (!querystring) {
12
12
  return debugFromLocalStorage;
13
13
  } // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
14
14
 
15
15
 
16
- const debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex
16
+ var debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
17
17
  new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
18
18
  return (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') + debugFromQueryString;
19
19
  }
20
20
 
21
- const findDebugLevel = (minLevel, key) => createFindDebugLevel(getDebugString())(minLevel, key);
21
+ var findDebugLevel = function findDebugLevel(minLevel, key) {
22
+ return createFindDebugLevel(getDebugString())(minLevel, key);
23
+ };
22
24
 
23
- const getDefaultTheme = () => {
25
+ var getDefaultTheme = function getDefaultTheme() {
24
26
  try {
25
- const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
27
+ var configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
26
28
 
27
29
  if (configInLocalStorage && configInLocalStorage === 'dark') {
28
30
  return configInLocalStorage;
@@ -32,24 +34,30 @@ const getDefaultTheme = () => {
32
34
  return 'light';
33
35
  };
34
36
 
35
- const createHandler = (theme = getDefaultTheme()) => {
36
- const browserConsoleFormatter = createBrowserConsoleFormatter(theme);
37
- return record => {
37
+ var createHandler = function createHandler(theme) {
38
+ if (theme === void 0) {
39
+ theme = getDefaultTheme();
40
+ }
41
+
42
+ var browserConsoleFormatter = createBrowserConsoleFormatter(theme);
43
+ return function (record) {
38
44
  consoleOutput(browserConsoleFormatter(record), record);
39
45
  };
40
46
  };
41
47
 
42
- class BrowserConsoleHandler {
43
- constructor(minLevel, options = {}) {
44
- this.minLevel = 0;
48
+ var BrowserConsoleHandler = function BrowserConsoleHandler(minLevel, options) {
49
+ if (options === void 0) {
50
+ options = {};
51
+ }
45
52
 
46
- this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
53
+ this.minLevel = 0;
47
54
 
48
- this.handle = createHandler(options.theme);
49
- }
55
+ this.isHandling = function (level, key) {
56
+ return level >= findDebugLevel(minLevel, key);
57
+ };
50
58
 
51
- }
59
+ this.handle = createHandler(options.theme);
60
+ };
52
61
 
53
- export default BrowserConsoleHandler;
54
62
  export { BrowserConsoleHandler };
55
63
  //# sourceMappingURL=index-browser.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport createFindDebugLevel from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n\n/** @deprecated use named export instead */\nexport default BrowserConsoleHandler;\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","constructor","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AAAA;;AACvC,QAAMC,WAAW,yBAAGC,QAAQ,CAACC,QAAZ,qBAAG,mBAAmBC,MAAvC;AACA,QAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAP,IAAuBA,YAAY,CAACC,OAAb,CAAqB,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI,qBAAP;AACD,GAPsC;;;AAUvC,QAAMI,oBAAoB,GAAGC,SAAS,CACpCT,WAAW,CAACU,OAAZ;AAEE,MAAIC,MAAJ,CAAW,uCAAX,EAAoD,GAApD,CAFF,EAGE,IAHF,CADoC,CAAtC;AAQA,SACE,CAACP,qBAAqB,GAAI,GAAEA,qBAAsB,GAA5B,GAAiC,EAAvD,IACAI,oBAFF;AAID;;ACRD,MAAMI,cAAc,GAAG,CAACC,QAAD,EAAkBC,GAAlB,KACrBC,oBAAoB,CAAChB,cAAc,EAAf,CAApB,CAAuCc,QAAvC,EAAiDC,GAAjD,CADF;;AAKA,MAAME,eAAe,GAAG,MAAa;AACnC,MAAI;AACF,UAAMC,oBAAoB,GAAGX,YAAY,CAACC,OAAb,CAAqB,mBAArB,CAA7B;;AACA,QAAIU,oBAAoB,IAAIA,oBAAoB,KAAK,MAArD,EAA6D;AAC3D,aAAOA,oBAAP;AACD;AACF,GALD,CAKE,gBAAM;;AACR,SAAO,OAAP;AACD,CARD;;AAUA,MAAMC,aAAa,GAAG,CAACC,KAAY,GAAGH,eAAe,EAA/B,KAA8C;AAClE,QAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAD,CAA7D;AACA,SAA4BG,MAArB,IAA8C;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAD,CAAxB,EAAkCA,MAAlC,CAAb;AACD,GAFD;AAGD,CALD;;AAWO,MAAME,qBAAN,CAA+C;AAOpDC,EAAAA,WAAW,CAACZ,QAAD,EAAkBa,OAAqC,GAAG,EAA1D,EAA8D;AAAA,SANzEb,QAMyE,GANvD,CAMuD;;AACvE,SAAKc,UAAL,GAAkB,CAACC,KAAD,EAAed,GAAf,KAChBc,KAAK,IAAIhB,cAAc,CAACC,QAAD,EAAWC,GAAX,CADzB;;AAGA,SAAKe,MAAL,GAAcX,aAAa,CAACQ,OAAO,CAACP,KAAT,CAA3B;AACD;;AAZmD;;;;;"}
1
+ {"version":3,"file":"index-browser.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AAAA;;AACvC,MAAMC,WAAW,yBAAGC,QAAQ,CAACC,QAAZ,qBAAG,mBAAmBC,MAAvC;AACA,MAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAP,IAAuBA,YAAY,CAACC,OAAb,CAAqB,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ACvE,OAAKa,UAAL,GAAkB,UAACC,KAAD,EAAeb,GAAf;AAAA,WAChBa,KAAK,IAAIf,cAAc,CAACC,QAAD,EAAWC,GAAX,CADP;AAAA,GAAlB;;AAGA,OAAKc,MAAL,GAAcV,aAAa,CAACO,OAAO,CAACN,KAAT,CAA3B;AACD;;;;"}
@@ -1,9 +1,11 @@
1
1
  import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';
2
2
  import consoleOutput from 'nightingale-console-output';
3
- import createFindDebugLevel from 'nightingale-debug';
3
+ import { createFindDebugLevel } from 'nightingale-debug';
4
4
 
5
5
  function getDebugString() {
6
- const querystring = document.location?.search;
6
+ var _document$location;
7
+
8
+ const querystring = (_document$location = document.location) === null || _document$location === void 0 ? void 0 : _document$location.search;
7
9
  const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
8
10
 
9
11
  if (!querystring) {
@@ -11,7 +13,7 @@ function getDebugString() {
11
13
  } // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
12
14
 
13
15
 
14
- const debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex
16
+ const debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
15
17
  new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
16
18
  return (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') + debugFromQueryString;
17
19
  }
@@ -38,9 +40,9 @@ const createHandler = (theme = getDefaultTheme()) => {
38
40
  };
39
41
 
40
42
  class BrowserConsoleHandler {
41
- constructor(minLevel, options = {}) {
42
- this.minLevel = 0;
43
+ minLevel = 0;
43
44
 
45
+ constructor(minLevel, options = {}) {
44
46
  this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
45
47
 
46
48
  this.handle = createHandler(options.theme);
@@ -48,6 +50,5 @@ class BrowserConsoleHandler {
48
50
 
49
51
  }
50
52
 
51
- export default BrowserConsoleHandler;
52
53
  export { BrowserConsoleHandler };
53
54
  //# sourceMappingURL=index-browsermodern.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-browsermodern.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport createFindDebugLevel from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n\n/** @deprecated use named export instead */\nexport default BrowserConsoleHandler;\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","constructor","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AACvC,QAAMC,WAAW,GAAGC,QAAQ,CAACC,QAAT,EAAmBC,MAAvC;AACA,QAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAP,IAAuBA,YAAY,CAACC,OAAb,CAAqB,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI,qBAAP;AACD,GAPsC;;;AAUvC,QAAMI,oBAAoB,GAAGC,SAAS,CACpCT,WAAW,CAACU,OAAZ;AAEE,MAAIC,MAAJ,CAAW,uCAAX,EAAoD,GAApD,CAFF,EAGE,IAHF,CADoC,CAAtC;AAQA,SACE,CAACP,qBAAqB,GAAI,GAAEA,qBAAsB,GAA5B,GAAiC,EAAvD,IACAI,oBAFF;AAID;;ACRD,MAAMI,cAAc,GAAG,CAACC,QAAD,EAAkBC,GAAlB,KACrBC,oBAAoB,CAAChB,cAAc,EAAf,CAApB,CAAuCc,QAAvC,EAAiDC,GAAjD,CADF;;AAKA,MAAME,eAAe,GAAG,MAAa;AACnC,MAAI;AACF,UAAMC,oBAAoB,GAAGX,YAAY,CAACC,OAAb,CAAqB,mBAArB,CAA7B;;AACA,QAAIU,oBAAoB,IAAIA,oBAAoB,KAAK,MAArD,EAA6D;AAC3D,aAAOA,oBAAP;AACD;AACF,GALD,CAKE,MAAM;;AACR,SAAO,OAAP;AACD,CARD;;AAUA,MAAMC,aAAa,GAAG,CAACC,KAAY,GAAGH,eAAe,EAA/B,KAA8C;AAClE,QAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAD,CAA7D;AACA,SAA4BG,MAArB,IAA8C;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAD,CAAxB,EAAkCA,MAAlC,CAAb;AACD,GAFD;AAGD,CALD;;AAWO,MAAME,qBAAN,CAA+C;AAOpDC,EAAAA,WAAW,CAACZ,QAAD,EAAkBa,OAAqC,GAAG,EAA1D,EAA8D;AAAA,SANzEb,QAMyE,GANvD,CAMuD;;AACvE,SAAKc,UAAL,GAAkB,CAACC,KAAD,EAAed,GAAf,KAChBc,KAAK,IAAIhB,cAAc,CAACC,QAAD,EAAWC,GAAX,CADzB;;AAGA,SAAKe,MAAL,GAAcX,aAAa,CAACQ,OAAO,CAACP,KAAT,CAA3B;AACD;;AAZmD;;;;;"}
1
+ {"version":3,"file":"index-browsermodern.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","constructor","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AAAA;;AACvC,QAAMC,WAAW,yBAAGC,QAAQ,CAACC,QAAZ,uDAAG,mBAAmBC,MAAvC;AACA,QAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAP,IAAuBA,YAAY,CAACC,OAAb,CAAqB,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI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,5 @@ export declare class BrowserConsoleHandler implements Handler {
9
9
  isHandling: IsHandling;
10
10
  constructor(minLevel: Level, options?: BrowserConsoleHandlerOptions);
11
11
  }
12
- /** @deprecated use named export instead */
13
- export default BrowserConsoleHandler;
12
+ export {};
14
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,KAAK,EACL,MAAM,EACN,UAAU,EAGV,OAAO,EACR,MAAM,mBAAmB,CAAC;AAO3B,aAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAmB9B,UAAU,4BAA4B;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,qBAAa,qBAAsB,YAAW,OAAO;IACnD,QAAQ,EAAE,KAAK,CAAK;IAEpB,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAE,4BAAiC;CAMxE;AAED,2CAA2C;AAC3C,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,KAAK,EACL,MAAM,EACN,UAAU,EAGV,OAAO,EACR,MAAM,mBAAmB,CAAC;AAO3B,aAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAmB9B,UAAU,4BAA4B;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,qBAAa,qBAAsB,YAAW,OAAO;IACnD,QAAQ,EAAE,KAAK,CAAK;IAEpB,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,UAAU,CAAC;gBAEX,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAE,4BAAiC;CAMxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale-browser-console",
3
- "version": "11.7.0",
3
+ "version": "12.0.0",
4
4
  "description": "Browser console handler for nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
@@ -14,49 +14,36 @@
14
14
  "directory": "packages/nightingale-browser-console"
15
15
  },
16
16
  "homepage": "https://github.com/christophehurpeau/nightingale",
17
+ "type": "commonjs",
17
18
  "browserslist": [
19
+ "defaults",
18
20
  "> 0.2%",
19
- "Firefox ESR",
20
- "last 2 Chrome versions",
21
- "last 2 iOS versions",
22
- "last 2 Edge versions",
23
- "last 2 Safari versions",
24
21
  "not ie < 12",
25
- "not ios_saf < 10",
26
- "not dead",
27
- "not op_mini all"
22
+ "not safari < 10",
23
+ "not ios_saf < 10"
28
24
  ],
29
- "main": "./dist/index-browser.es.js",
30
25
  "types": "./dist/index.d.ts",
31
26
  "module": "./dist/index-browser.es.js",
32
27
  "browser": "./dist/index-browser.es.js",
33
28
  "exports": {
29
+ "./package.json": "./package.json",
34
30
  ".": {
35
31
  "browser": {
36
32
  "browser:modern": {
37
- "development": {
38
- "import": "./dist/index-browsermodern-dev.es.js"
39
- },
40
33
  "import": "./dist/index-browsermodern.es.js"
41
34
  },
42
- "development": {
43
- "import": "./dist/index-browser-dev.es.js"
44
- },
45
35
  "import": "./dist/index-browser.es.js"
46
36
  }
47
37
  }
48
38
  },
49
- "module:browser": "./dist/index-browser.es.js",
50
- "module:browser-dev": "./dist/index-browser-dev.es.js",
51
39
  "module:modern-browsers": "./dist/index-browsermodern.es.js",
52
- "module:modern-browsers-dev": "./dist/index-browsermodern-dev.es.js",
53
40
  "sideEffects": false,
54
41
  "scripts": {
55
42
  "build": "pob-build && yarn run build:definitions",
56
43
  "build:definitions": "tsc -p tsconfig.build.json",
57
- "clean": "rm -Rf docs dist test/node6 coverage",
44
+ "clean": "rm -Rf dist",
58
45
  "lint": "yarn run lint:eslint",
59
- "lint:eslint": "yarn --cwd ../.. run eslint --ext .js,.mjs,.ts --report-unused-disable-directives --quiet packages/nightingale-browser-console",
46
+ "lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-browser-console",
60
47
  "watch": "pob-watch"
61
48
  },
62
49
  "prettier": {
@@ -85,28 +72,17 @@
85
72
  ]
86
73
  },
87
74
  "dependencies": {
88
- "nightingale-browser-console-formatter": "^11.7.0",
89
- "nightingale-console-output": "^11.7.0",
90
- "nightingale-debug": "^11.7.0",
91
- "nightingale-types": "^11.7.0"
75
+ "nightingale-browser-console-formatter": "^12.0.0",
76
+ "nightingale-console-output": "^12.0.0",
77
+ "nightingale-debug": "^12.0.0",
78
+ "nightingale-types": "^12.0.0"
92
79
  },
93
80
  "devDependencies": {
94
- "@babel/core": "7.13.10",
95
- "@babel/preset-env": "7.13.10",
96
- "@pob/eslint-config": "43.0.0",
97
- "@pob/eslint-config-node": "43.1.0",
98
- "@pob/eslint-config-typescript": "43.0.0",
99
- "@typescript-eslint/eslint-plugin": "4.19.0",
100
- "@typescript-eslint/parser": "4.19.0",
81
+ "@babel/core": "7.16.0",
82
+ "@babel/preset-env": "7.16.4",
101
83
  "babel-preset-modern-browsers": "15.0.2",
102
- "eslint": "7.23.0",
103
- "eslint-import-resolver-node": "0.3.4",
104
- "eslint-plugin-import": "2.22.1",
105
- "eslint-plugin-node": "11.1.0",
106
- "eslint-plugin-unicorn": "25.0.1",
107
- "pob-babel": "26.8.0",
108
- "rollup": "2.43.1",
109
- "typescript": "4.2.3"
84
+ "pob-babel": "29.3.0",
85
+ "typescript": "4.5.3"
110
86
  },
111
- "gitHead": "cc85b26dbfce264e968f288517a1af98d6f5156d"
87
+ "gitHead": "682f57fa30eaca9732681d16008abb2680b24174"
112
88
  }
@@ -0,0 +1,3 @@
1
+ import createRollupConfig from 'pob-babel/createRollupConfig.js';
2
+
3
+ export default createRollupConfig({});
@@ -6,5 +6,22 @@
6
6
  },
7
7
  "plugins": ["@typescript-eslint"],
8
8
  "extends": ["@pob/eslint-config-typescript"],
9
- "ignorePatterns": ["*.d.ts"]
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
+ ]
10
27
  }
package/src/debug.ts CHANGED
@@ -10,7 +10,7 @@ export function getDebugString(): string {
10
10
  // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
11
11
  const debugFromQueryString = decodeURI(
12
12
  querystring.replace(
13
- // eslint-disable-next-line unicorn/no-unsafe-regex
13
+ // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
14
14
  new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'),
15
15
  '$1',
16
16
  ),
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';
2
2
  import consoleOutput from 'nightingale-console-output';
3
- import createFindDebugLevel from 'nightingale-debug';
3
+ import { createFindDebugLevel } from 'nightingale-debug';
4
4
  import type {
5
5
  Level,
6
6
  Handle,
@@ -52,6 +52,3 @@ export class BrowserConsoleHandler implements Handler {
52
52
  this.handle = createHandler(options.theme);
53
53
  }
54
54
  }
55
-
56
- /** @deprecated use named export instead */
57
- export default BrowserConsoleHandler;
@@ -0,0 +1 @@
1
+ /// <reference types="pob-babel" />
@@ -1,55 +0,0 @@
1
- import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';
2
- import consoleOutput from 'nightingale-console-output';
3
- import createFindDebugLevel from 'nightingale-debug';
4
-
5
- function getDebugString() {
6
- var _document$location;
7
-
8
- const querystring = (_document$location = document.location) == null ? void 0 : _document$location.search;
9
- const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
10
-
11
- if (!querystring) {
12
- return debugFromLocalStorage;
13
- } // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
14
-
15
-
16
- const debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex
17
- new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
18
- return (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') + debugFromQueryString;
19
- }
20
-
21
- const findDebugLevel = (minLevel, key) => createFindDebugLevel(getDebugString())(minLevel, key);
22
-
23
- const getDefaultTheme = () => {
24
- try {
25
- const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
26
-
27
- if (configInLocalStorage && configInLocalStorage === 'dark') {
28
- return configInLocalStorage;
29
- }
30
- } catch (_unused) {}
31
-
32
- return 'light';
33
- };
34
-
35
- const createHandler = (theme = getDefaultTheme()) => {
36
- const browserConsoleFormatter = createBrowserConsoleFormatter(theme);
37
- return record => {
38
- consoleOutput(browserConsoleFormatter(record), record);
39
- };
40
- };
41
-
42
- class BrowserConsoleHandler {
43
- constructor(minLevel, options = {}) {
44
- this.minLevel = 0;
45
-
46
- this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
47
-
48
- this.handle = createHandler(options.theme);
49
- }
50
-
51
- }
52
-
53
- export default BrowserConsoleHandler;
54
- export { BrowserConsoleHandler };
55
- //# sourceMappingURL=index-browser-dev.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-browser-dev.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport createFindDebugLevel from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n\n/** @deprecated use named export instead */\nexport default BrowserConsoleHandler;\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","constructor","options","isHandling","level","handle"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EAA8D;AAAA,SANzEb,QAMyE,GANvD,CAMuD;;AACvE,SAAKc,UAAL,GAAkB,CAACC,KAAD,EAAed,GAAf,KAChBc,KAAK,IAAIhB,cAAc,CAACC,QAAD,EAAWC,GAAX,CADzB;;AAGA,SAAKe,MAAL,GAAcX,aAAa,CAACQ,OAAO,CAACP,KAAT,CAA3B;AACD;;AAZmD;;;;;"}
@@ -1,53 +0,0 @@
1
- import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';
2
- import consoleOutput from 'nightingale-console-output';
3
- import createFindDebugLevel from 'nightingale-debug';
4
-
5
- function getDebugString() {
6
- const querystring = document.location?.search;
7
- const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
8
-
9
- if (!querystring) {
10
- return debugFromLocalStorage;
11
- } // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
12
-
13
-
14
- const debugFromQueryString = decodeURI(querystring.replace( // eslint-disable-next-line unicorn/no-unsafe-regex
15
- new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
16
- return (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') + debugFromQueryString;
17
- }
18
-
19
- const findDebugLevel = (minLevel, key) => createFindDebugLevel(getDebugString())(minLevel, key);
20
-
21
- const getDefaultTheme = () => {
22
- try {
23
- const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
24
-
25
- if (configInLocalStorage && configInLocalStorage === 'dark') {
26
- return configInLocalStorage;
27
- }
28
- } catch {}
29
-
30
- return 'light';
31
- };
32
-
33
- const createHandler = (theme = getDefaultTheme()) => {
34
- const browserConsoleFormatter = createBrowserConsoleFormatter(theme);
35
- return record => {
36
- consoleOutput(browserConsoleFormatter(record), record);
37
- };
38
- };
39
-
40
- class BrowserConsoleHandler {
41
- constructor(minLevel, options = {}) {
42
- this.minLevel = 0;
43
-
44
- this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
45
-
46
- this.handle = createHandler(options.theme);
47
- }
48
-
49
- }
50
-
51
- export default BrowserConsoleHandler;
52
- export { BrowserConsoleHandler };
53
- //# sourceMappingURL=index-browsermodern-dev.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-browsermodern-dev.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport createFindDebugLevel from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n\n/** @deprecated use named export instead */\nexport default BrowserConsoleHandler;\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","constructor","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AACvC,QAAMC,WAAW,GAAGC,QAAQ,CAACC,QAAT,EAAmBC,MAAvC;AACA,QAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAP,IAAuBA,YAAY,CAACC,OAAb,CAAqB,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI,qBAAP;AACD,GAPsC;;;AAUvC,QAAMI,oBAAoB,GAAGC,SAAS,CACpCT,WAAW,CAACU,OAAZ;AAEE,MAAIC,MAAJ,CAAW,uCAAX,EAAoD,GAApD,CAFF,EAGE,IAHF,CADoC,CAAtC;AAQA,SACE,CAACP,qBAAqB,GAAI,GAAEA,qBAAsB,GAA5B,GAAiC,EAAvD,IACAI,oBAFF;AAID;;ACRD,MAAMI,cAAc,GAAG,CAACC,QAAD,EAAkBC,GAAlB,KACrBC,oBAAoB,CAAChB,cAAc,EAAf,CAApB,CAAuCc,QAAvC,EAAiDC,GAAjD,CADF;;AAKA,MAAME,eAAe,GAAG,MAAa;AACnC,MAAI;AACF,UAAMC,oBAAoB,GAAGX,YAAY,CAACC,OAAb,CAAqB,mBAArB,CAA7B;;AACA,QAAIU,oBAAo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