nightingale-browser-console 13.0.0 → 14.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
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
+ ## [14.0.1](https://github.com/christophehurpeau/nightingale/compare/v14.0.0...v14.0.1) (2023-06-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add missing type in exports for latest typescript ([8897fd6](https://github.com/christophehurpeau/nightingale/commit/8897fd6fcbd25975482fd1549277b73ed725e53c))
12
+
13
+
14
+
15
+ ## [14.0.0](https://github.com/christophehurpeau/nightingale/compare/v13.0.0...v14.0.0) (2023-06-30)
16
+
17
+
18
+ ### ⚠ BREAKING CHANGES
19
+
20
+ * **deps:** require node 18
21
+ * requires node 18
22
+
23
+ ### Features
24
+
25
+ * requires node 18 ([4452b11](https://github.com/christophehurpeau/nightingale/commit/4452b116188e58c293be85e462e04922f7ad51f0))
26
+
27
+
28
+ ### Miscellaneous Chores
29
+
30
+ * **deps:** update dependency @pob/root to v8 ([#760](https://github.com/christophehurpeau/nightingale/issues/760)) ([22dc3cc](https://github.com/christophehurpeau/nightingale/commit/22dc3cceabdfd465d04ee36fec8fdac31febab69))
31
+
32
+
33
+
6
34
  # [13.0.0](https://github.com/christophehurpeau/nightingale/compare/v12.1.4...v13.0.0) (2022-11-19)
7
35
 
8
36
 
@@ -1,5 +1,5 @@
1
1
  import type { Level, Handle, IsHandling, Handler } from 'nightingale-types';
2
- type Theme = 'light' | 'dark';
2
+ type Theme = 'dark' | 'light';
3
3
  export interface BrowserConsoleHandlerOptions {
4
4
  theme?: Theme;
5
5
  }
@@ -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,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAmB9B,MAAM,WAAW,4BAA4B;IAC3C,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"}
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,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAmB9B,MAAM,WAAW,4BAA4B;IAC3C,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"}
@@ -22,8 +22,9 @@ var findDebugLevel = function findDebugLevel(minLevel, key) {
22
22
  return createFindDebugLevel(getDebugString())(minLevel, key);
23
23
  };
24
24
  var getDefaultTheme = function getDefaultTheme() {
25
+ var configInLocalStorage;
25
26
  try {
26
- var configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
27
+ configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
27
28
  if (configInLocalStorage && configInLocalStorage === 'dark') {
28
29
  return configInLocalStorage;
29
30
  }
@@ -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, 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\nexport interface 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,cAAc,GAAW;AAAA,EAAA,IAAA,kBAAA,CAAA;AACvC,EAAA,IAAMC,WAAW,GAAGC,CAAAA,kBAAAA,GAAAA,QAAQ,CAACC,QAAQ,KAAA,IAAA,GAAA,KAAA,CAAA,GAAjB,mBAAmBC,MAAM,CAAA;AAC7C,EAAA,IAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAY,IAAIA,YAAY,CAACC,OAAO,CAAC,OAAO,CAAC,IAAK,EAAE,CAAA;EAE9D,IAAI,CAACP,WAAW,EAAE;AAChB,IAAA,OAAOI,qBAAqB,CAAA;AAC9B,GAAA;;AAEA;AACA,EAAA,IAAMI,oBAAoB,GAAGC,SAAS,CACpCT,WAAW,CAACU,OAAO;AACjB;EACA,IAAIC,MAAM,CAAC,uCAAuC,EAAE,GAAG,CAAC,EACxD,IAAI,CACL,CACF,CAAA;AAED,EAAA,OACE,CAACP,qBAAqB,GAAMA,qBAAqB,GAAM,GAAA,GAAA,EAAE,IACzDI,oBAAoB,CAAA;AAExB;;ACTA;AACA,IAAMI,cAAc,GAAG,SAAjBA,cAAc,CAAIC,QAAe,EAAEC,GAAW,EAAA;EAAA,OAClDC,oBAAoB,CAAChB,cAAc,EAAE,CAAC,CAACc,QAAQ,EAAEC,GAAG,CAAC,CAAA;AAAA,CAAA,CAAA;AAIvD,IAAME,eAAe,GAAG,SAAlBA,eAAe,GAAgB;EACnC,IAAI;AACF,IAAA,IAAMC,oBAAoB,GAAGX,YAAY,CAACC,OAAO,CAAC,mBAAmB,CAAC,CAAA;AACtE,IAAA,IAAIU,oBAAoB,IAAIA,oBAAoB,KAAK,MAAM,EAAE;AAC3D,MAAA,OAAOA,oBAAoB,CAAA;AAC7B,KAAA;GACD,CAAC,gBAAM,EAAC;AACT,EAAA,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,IAAMC,aAAa,GAAG,SAAhBA,aAAa,CAAIC,KAAY,EAAiC;AAAA,EAAA,IAA7CA,KAAY,KAAA,KAAA,CAAA,EAAA;IAAZA,KAAY,GAAGH,eAAe,EAAE,CAAA;AAAA,GAAA;AACrD,EAAA,IAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAK,CAAC,CAAA;EACpE,OAAO,UAAqBG,MAAoB,EAAK;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAM,CAAC,EAAEA,MAAM,CAAC,CAAA;GACvD,CAAA;AACH,CAAC,CAAA;AAMD,IAAaE,qBAAqB,GAOhC,SAAA,qBAAA,CAAYX,QAAe,EAAEY,OAAqC,EAAO;AAAA,EAAA,IAA5CA,OAAqC,KAAA,KAAA,CAAA,EAAA;IAArCA,OAAqC,GAAG,EAAE,CAAA;AAAA,GAAA;EAAA,IANvEZ,CAAAA,QAAQ,GAAU,CAAC,CAAA;AAOjB,EAAA,IAAI,CAACa,UAAU,GAAG,UAACC,KAAY,EAAEb,GAAW,EAAA;AAAA,IAAA,OAC1Ca,KAAK,IAAIf,cAAc,CAACC,QAAQ,EAAEC,GAAG,CAAC,CAAA;AAAA,GAAA,CAAA;EAExC,IAAI,CAACc,MAAM,GAAGV,aAAa,CAACO,OAAO,CAACN,KAAK,CAAC,CAAA;AAC5C;;;;"}
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 = 'dark' | 'light';\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\nexport interface 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","_document$location","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","_unused","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record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C,CAAA;AAED,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,KAAY,EAAiC;AAAA,EAAA,IAA7CA,KAAY,KAAA,KAAA,CAAA,EAAA;IAAZA,KAAY,GAAGJ,eAAe,EAAE,CAAA;AAAA,GAAA;AACrD,EAAA,IAAMK,uBAAuB,GAAGC,6BAA6B,CAACF,KAAK,CAAC,CAAA;EACpE,OAAO,UAAqBG,MAAoB,EAAK;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAM,CAAC,EAAEA,MAAM,CAAC,CAAA;GACvD,CAAA;AACH,CAAC,CAAA;AAMD,IAAaE,qBAAqB,GAOhC,SAAAA,sBAAYZ,QAAe,EAAEa,OAAqC,EAAO;AAAA,EAAA,IAA5CA,OAAqC,KAAA,KAAA,CAAA,EAAA;IAArCA,OAAqC,GAAG,EAAE,CAAA;AAAA,GAAA;EAAA,IANvEb,CAAAA,QAAQ,GAAU,CAAC,CAAA;AAOjB,EAAA,IAAI,CAACc,UAAU,GAAG,UAACC,KAAY,EAAEd,GAAW,EAAA;AAAA,IAAA,OAC1Cc,KAAK,IAAIhB,cAAc,CAACC,QAAQ,EAAEC,GAAG,CAAC,CAAA;AAAA,GAAA,CAAA;EAExC,IAAI,CAACe,MAAM,GAAGV,aAAa,CAACO,OAAO,CAACN,KAAK,CAAC,CAAA;AAC5C;;;;"}
@@ -3,8 +3,7 @@ import consoleOutput from 'nightingale-console-output';
3
3
  import { createFindDebugLevel } from 'nightingale-debug';
4
4
 
5
5
  function getDebugString() {
6
- var _document$location;
7
- const querystring = (_document$location = document.location) === null || _document$location === void 0 ? void 0 : _document$location.search;
6
+ const querystring = document.location?.search;
8
7
  const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
9
8
  if (!querystring) {
10
9
  return debugFromLocalStorage;
@@ -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, 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\nexport interface 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,cAAc,GAAW;AAAA,EAAA,IAAA,kBAAA,CAAA;AACvC,EAAA,MAAMC,WAAW,GAAGC,CAAAA,kBAAAA,GAAAA,QAAQ,CAACC,QAAQ,MAAA,IAAA,IAAA,kBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAjB,mBAAmBC,MAAM,CAAA;AAC7C,EAAA,MAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAY,IAAIA,YAAY,CAACC,OAAO,CAAC,OAAO,CAAC,IAAK,EAAE,CAAA;EAE9D,IAAI,CAACP,WAAW,EAAE;AAChB,IAAA,OAAOI,qBAAqB,CAAA;AAC9B,GAAA;;AAEA;AACA,EAAA,MAAMI,oBAAoB,GAAGC,SAAS,CACpCT,WAAW,CAACU,OAAO;AACjB;EACA,IAAIC,MAAM,CAAC,uCAAuC,EAAE,GAAG,CAAC,EACxD,IAAI,CACL,CACF,CAAA;EAED,OACE,CAACP,qBAAqB,GAAI,CAAA,EAAEA,qBAAsB,CAAE,CAAA,CAAA,GAAG,EAAE,IACzDI,oBAAoB,CAAA;AAExB;;ACTA;AACA,MAAMI,cAAc,GAAG,CAACC,QAAe,EAAEC,GAAW,KAClDC,oBAAoB,CAAChB,cAAc,EAAE,CAAC,CAACc,QAAQ,EAAEC,GAAG,CAAC,CAAA;AAIvD,MAAME,eAAe,GAAG,MAAa;EACnC,IAAI;AACF,IAAA,MAAMC,oBAAoB,GAAGX,YAAY,CAACC,OAAO,CAAC,mBAAmB,CAAC,CAAA;AACtE,IAAA,IAAIU,oBAAoB,IAAIA,oBAAoB,KAAK,MAAM,EAAE;AAC3D,MAAA,OAAOA,oBAAoB,CAAA;AAC7B,KAAA;GACD,CAAC,MAAM,EAAC;AACT,EAAA,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAMC,aAAa,GAAG,CAACC,KAAY,GAAGH,eAAe,EAAE,KAAa;AAClE,EAAA,MAAMI,uBAAuB,GAAGC,6BAA6B,CAACF,KAAK,CAAC,CAAA;AACpE,EAAA,OAA4BG,MAAoB,IAAK;AACnDC,IAAAA,aAAa,CAACH,uBAAuB,CAACE,MAAM,CAAC,EAAEA,MAAM,CAAC,CAAA;GACvD,CAAA;AACH,CAAC,CAAA;AAMM,MAAME,qBAAqB,CAAoB;AACpDX,EAAAA,QAAQ,GAAU,CAAC,CAAA;AAMnBY,EAAAA,WAAW,CAACZ,QAAe,EAAEa,OAAqC,GAAG,EAAE,EAAE;AACvE,IAAA,IAAI,CAACC,UAAU,GAAG,CAACC,KAAY,EAAEd,GAAW,KAC1Cc,KAAK,IAAIhB,cAAc,CAACC,QAAQ,EAAEC,GAAG,CAAC,CAAA;IAExC,IAAI,CAACe,MAAM,GAAGX,aAAa,CAACQ,OAAO,CAACP,KAAK,CAAC,CAAA;AAC5C,GAAA;AACF;;;;"}
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 = 'dark' | 'light';\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\nexport interface 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,cAAcA,GAAW;AACvC,EAAA,MAAMC,WAAW,GAAGC,QAAQ,CAACC,QAAQ,EAAEC,MAAM,CAAA;AAC7C,EAAA,MAAMC,qBAAqB,GACxBC,MAAM,CAACC,YAAY,IAAIA,YAAY,CAACC,O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ACvE,IAAA,IAAI,CAACC,UAAU,GAAG,CAACC,KAAY,EAAEd,GAAW,KAC1Cc,KAAK,IAAIhB,cAAc,CAACC,QAAQ,EAAEC,GAAG,CAAC,CAAA;IAExC,IAAI,CAACe,MAAM,GAAGX,aAAa,CAACQ,OAAO,CAACP,KAAK,CAAC,CAAA;AAC5C,GAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightingale-browser-console",
3
- "version": "13.0.0",
3
+ "version": "14.0.1",
4
4
  "description": "Browser console handler for nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
@@ -16,21 +16,24 @@
16
16
  "homepage": "https://github.com/christophehurpeau/nightingale",
17
17
  "type": "module",
18
18
  "engines": {
19
- "node": ">=16.0.0"
19
+ "node": ">=18.12.0"
20
+ },
21
+ "browserslist": {
22
+ "production": [
23
+ "defaults",
24
+ "> 0.2%",
25
+ "not ie < 12",
26
+ "not safari < 10",
27
+ "not ios_saf < 10"
28
+ ]
20
29
  },
21
- "browserslist": [
22
- "defaults",
23
- "> 0.2%",
24
- "not ie < 12",
25
- "not safari < 10",
26
- "not ios_saf < 10"
27
- ],
28
30
  "types": "./dist/definitions/index.d.ts",
29
31
  "module": "./dist/index-browser.es.js",
30
32
  "browser": "./dist/index-browser.es.js",
31
33
  "exports": {
32
34
  "./package.json": "./package.json",
33
35
  ".": {
36
+ "type": "./dist/definitions/index.d.ts",
34
37
  "browser": {
35
38
  "browser:modern": {
36
39
  "import": "./dist/index-browsermodern.es.js"
@@ -42,7 +45,7 @@
42
45
  "sideEffects": false,
43
46
  "scripts": {
44
47
  "build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
45
- "build:definitions": "tsc -p",
48
+ "build:definitions": "tsc -p tsconfig.json",
46
49
  "clean": "yarn clean:build",
47
50
  "clean:build": "pob-babel-clean-out dist",
48
51
  "lint": "yarn run lint:eslint",
@@ -65,17 +68,16 @@
65
68
  ]
66
69
  },
67
70
  "dependencies": {
68
- "nightingale-browser-console-formatter": "13.0.0",
69
- "nightingale-console-output": "13.0.0",
70
- "nightingale-debug": "13.0.0",
71
- "nightingale-types": "13.0.0"
71
+ "nightingale-browser-console-formatter": "14.0.1",
72
+ "nightingale-console-output": "14.0.1",
73
+ "nightingale-debug": "14.0.1",
74
+ "nightingale-types": "14.0.1"
72
75
  },
73
76
  "devDependencies": {
74
- "@babel/core": "7.20.2",
75
- "@babel/preset-env": "7.20.2",
76
- "babel-preset-modern-browsers": "15.0.2",
77
- "pob-babel": "35.3.0",
78
- "typescript": "4.9.3"
77
+ "@babel/core": "7.22.5",
78
+ "@babel/preset-env": "7.22.5",
79
+ "pob-babel": "36.1.0",
80
+ "typescript": "5.1.6"
79
81
  },
80
- "gitHead": "52cf7e3c8762a07891da9dde497ec03298c15654"
82
+ "gitHead": "e012fc159ceae0db482198c3f0308e0fc6470ae1"
81
83
  }
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@ import { getDebugString } from './debug';
15
15
  const findDebugLevel = (minLevel: Level, key: string): Level =>
16
16
  createFindDebugLevel(getDebugString())(minLevel, key);
17
17
 
18
- type Theme = 'light' | 'dark';
18
+ type Theme = 'dark' | 'light';
19
19
 
20
20
  const getDefaultTheme = (): Theme => {
21
21
  try {