nightingale-browser-console 11.6.0 → 11.7.4

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,41 @@
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
+ ## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
7
+
8
+ **Note:** Version bump only for package nightingale-browser-console
9
+
10
+
11
+
12
+
13
+
14
+ ## [11.7.2](https://github.com/christophehurpeau/nightingale/compare/v11.7.1...v11.7.2) (2021-11-27)
15
+
16
+ **Note:** Version bump only for package nightingale-browser-console
17
+
18
+
19
+
20
+
21
+
22
+ ## [11.7.1](https://github.com/christophehurpeau/nightingale/compare/v11.7.0...v11.7.1) (2021-06-29)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * update pob-babel to bring back webpack 4 support ([4887431](https://github.com/christophehurpeau/nightingale/commit/4887431b3b272496511f879af022638723b9056e))
28
+
29
+
30
+
31
+
32
+
33
+ # [11.7.0](https://github.com/christophehurpeau/nightingale/compare/v11.6.0...v11.7.0) (2021-03-29)
34
+
35
+ **Note:** Version bump only for package nightingale-browser-console
36
+
37
+
38
+
39
+
40
+
6
41
  # [11.6.0](https://github.com/christophehurpeau/nightingale/compare/v11.5.4...v11.6.0) (2021-03-21)
7
42
 
8
43
 
package/README.md CHANGED
@@ -68,3 +68,14 @@ localStorage.debug = '*,-app:*'; // debug everything except app and all its chil
68
68
  ?DEBUG=*,-app // debug everything except app
69
69
  ?DEBUG=*,-app:* // debug everything except app and all its children
70
70
  ```
71
+
72
+ ## Use source maps to display error stack trace
73
+
74
+ In production:
75
+
76
+ 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).
77
+
78
+ In development:
79
+
80
+ - 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.
81
+ - 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
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
- export { BrowserConsoleHandler };
62
+ export { BrowserConsoleHandler, BrowserConsoleHandler as default };
55
63
  //# sourceMappingURL=index-browser-dev.es.js.map
@@ -1 +1 @@
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"],"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-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","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,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI,qBAAP;AACD,GAPsC;;;AAUvC,MAAMI,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,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAACC,QAAD,EAAkBC,GAAlB;AAAA,SACrBC,oBAAoB,CAAChB,cAAc,EAAf,CAApB,CAAuCc,QAAvC,EAAiDC,GAAjD,CADqB;AAAA,CAAvB;;AAKA,IAAME,eAAe,GAAG,SAAlBA,eAAkB,GAAa;AACnC,MAAI;AACF,QAAMC,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,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA8C;AAAA,MAA7CA,KAA6C;AAA7CA,IAAAA,KAA6C,GAA9BH,eAAe,EAAe;AAAA;;AAClE,MAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAD,CAA7D;AACA,SAAO,UAAqBG,MAArB,EAA8C;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAD,CAAxB,EAAkCA,MAAlC,CAAb;AACD,GAFD;AAGD,CALD;;IAWaE,qBAAb,GAOE,+BAAYX,QAAZ,EAA6BY,OAA7B,EAAyE;AAAA,MAA5CA,OAA4C;AAA5CA,IAAAA,OAA4C,GAAJ,EAAI;AAAA;;AAAA,OANzEZ,QAMyE,GANvD,CAMuD;;AACvE,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,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
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
- export { BrowserConsoleHandler };
62
+ export { BrowserConsoleHandler, BrowserConsoleHandler as default };
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\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","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,OAArB,CAAxB,IAA0D,EAD5D;;AAGA,MAAI,CAACP,WAAL,EAAkB;AAChB,WAAOI,qBAAP;AACD,GAPsC;;;AAUvC,MAAMI,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,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAACC,QAAD,EAAkBC,GAAlB;AAAA,SACrBC,oBAAoB,CAAChB,cAAc,EAAf,CAApB,CAAuCc,QAAvC,EAAiDC,GAAjD,CADqB;AAAA,CAAvB;;AAKA,IAAME,eAAe,GAAG,SAAlBA,eAAkB,GAAa;AACnC,MAAI;AACF,QAAMC,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,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA8C;AAAA,MAA7CA,KAA6C;AAA7CA,IAAAA,KAA6C,GAA9BH,eAAe,EAAe;AAAA;;AAClE,MAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAD,CAA7D;AACA,SAAO,UAAqBG,MAArB,EAA8C;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAD,CAAxB,EAAkCA,MAAlC,CAAb;AACD,GAFD;AAGD,CALD;;IAWaE,qBAAb,GAOE,+BAAYX,QAAZ,EAA6BY,OAA7B,EAAyE;AAAA,MAA5CA,OAA4C;AAA5CA,IAAAA,OAA4C,GAAJ,EAAI;AAAA;;AAAA,OANzEZ,QAMyE,GANvD,CAMuD;;AACvE,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) {
@@ -48,6 +50,5 @@ class BrowserConsoleHandler {
48
50
 
49
51
  }
50
52
 
51
- export default BrowserConsoleHandler;
52
- export { BrowserConsoleHandler };
53
+ export { BrowserConsoleHandler, BrowserConsoleHandler as default };
53
54
  //# sourceMappingURL=index-browsermodern-dev.es.js.map
@@ -1 +1 @@
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,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-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;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,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,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) {
@@ -48,6 +50,5 @@ class BrowserConsoleHandler {
48
50
 
49
51
  }
50
52
 
51
- export default BrowserConsoleHandler;
52
- export { BrowserConsoleHandler };
53
+ export { BrowserConsoleHandler, BrowserConsoleHandler as default };
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\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,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,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale-browser-console",
3
- "version": "11.6.0",
3
+ "version": "11.7.4",
4
4
  "description": "Browser console handler for nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
@@ -14,23 +14,19 @@
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": {
@@ -56,7 +52,7 @@
56
52
  "build:definitions": "tsc -p tsconfig.build.json",
57
53
  "clean": "rm -Rf docs dist test/node6 coverage",
58
54
  "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",
55
+ "lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-browser-console",
60
56
  "watch": "pob-watch"
61
57
  },
62
58
  "prettier": {
@@ -85,28 +81,18 @@
85
81
  ]
86
82
  },
87
83
  "dependencies": {
88
- "nightingale-browser-console-formatter": "^11.6.0",
89
- "nightingale-console-output": "^11.6.0",
90
- "nightingale-debug": "^11.6.0",
91
- "nightingale-types": "^11.6.0"
84
+ "nightingale-browser-console-formatter": "^11.7.4",
85
+ "nightingale-console-output": "^11.7.4",
86
+ "nightingale-debug": "^11.7.4",
87
+ "nightingale-types": "^11.7.4"
92
88
  },
93
89
  "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.18.0",
100
- "@typescript-eslint/parser": "4.18.0",
90
+ "@babel/core": "7.16.0",
91
+ "@babel/preset-env": "7.16.4",
101
92
  "babel-preset-modern-browsers": "15.0.2",
102
- "eslint": "7.22.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.42.1",
109
- "typescript": "4.2.3"
93
+ "pob-babel": "28.5.0",
94
+ "rollup": "2.60.1",
95
+ "typescript": "4.5.2"
110
96
  },
111
- "gitHead": "56849d6762e917f29c20f932569973046a24f602"
97
+ "gitHead": "70f6b4ba634ff778fc94bef7e2455e8b6a7db06a"
112
98
  }
@@ -0,0 +1,3 @@
1
+ import createRollupConfig from 'pob-babel/createRollupConfig.js';
2
+
3
+ export default createRollupConfig({});
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,