nightingale-browser-console 11.7.4 → 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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
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
+
6
33
  ## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
7
34
 
8
35
  **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'
@@ -13,7 +13,7 @@ function getDebugString() {
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
- var 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
  }
@@ -59,5 +59,5 @@ var BrowserConsoleHandler = function BrowserConsoleHandler(minLevel, options) {
59
59
  this.handle = createHandler(options.theme);
60
60
  };
61
61
 
62
- export { BrowserConsoleHandler, BrowserConsoleHandler as default };
62
+ export { BrowserConsoleHandler };
63
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","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
+ {"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;AAA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,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;;;;"}
@@ -13,7 +13,7 @@ function getDebugString() {
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
+ const 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
  }
@@ -40,9 +40,9 @@ const createHandler = (theme = getDefaultTheme()) => {
40
40
  };
41
41
 
42
42
  class BrowserConsoleHandler {
43
- constructor(minLevel, options = {}) {
44
- this.minLevel = 0;
43
+ minLevel = 0;
45
44
 
45
+ constructor(minLevel, options = {}) {
46
46
  this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
47
47
 
48
48
  this.handle = createHandler(options.theme);
@@ -50,5 +50,5 @@ class BrowserConsoleHandler {
50
50
 
51
51
  }
52
52
 
53
- export { BrowserConsoleHandler, BrowserConsoleHandler as default };
53
+ export { BrowserConsoleHandler };
54
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;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
+ {"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,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;AACpDX,EAAAA,QAAQ,GAAU,CAAV;;AAMRY,EAAAA,WAAW,CAACZ,QAAD,EAAkBa,OAAqC,GAAG,EAA1D,EAA8D;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/dist/index.d.ts CHANGED
@@ -9,6 +9,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.4",
3
+ "version": "12.0.0",
4
4
  "description": "Browser console handler for nightingale",
5
5
  "keywords": [
6
6
  "nightingale",
@@ -30,27 +30,18 @@
30
30
  ".": {
31
31
  "browser": {
32
32
  "browser:modern": {
33
- "development": {
34
- "import": "./dist/index-browsermodern-dev.es.js"
35
- },
36
33
  "import": "./dist/index-browsermodern.es.js"
37
34
  },
38
- "development": {
39
- "import": "./dist/index-browser-dev.es.js"
40
- },
41
35
  "import": "./dist/index-browser.es.js"
42
36
  }
43
37
  }
44
38
  },
45
- "module:browser": "./dist/index-browser.es.js",
46
- "module:browser-dev": "./dist/index-browser-dev.es.js",
47
39
  "module:modern-browsers": "./dist/index-browsermodern.es.js",
48
- "module:modern-browsers-dev": "./dist/index-browsermodern-dev.es.js",
49
40
  "sideEffects": false,
50
41
  "scripts": {
51
42
  "build": "pob-build && yarn run build:definitions",
52
43
  "build:definitions": "tsc -p tsconfig.build.json",
53
- "clean": "rm -Rf docs dist test/node6 coverage",
44
+ "clean": "rm -Rf dist",
54
45
  "lint": "yarn run lint:eslint",
55
46
  "lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-browser-console",
56
47
  "watch": "pob-watch"
@@ -81,18 +72,17 @@
81
72
  ]
82
73
  },
83
74
  "dependencies": {
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"
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"
88
79
  },
89
80
  "devDependencies": {
90
81
  "@babel/core": "7.16.0",
91
82
  "@babel/preset-env": "7.16.4",
92
83
  "babel-preset-modern-browsers": "15.0.2",
93
- "pob-babel": "28.5.0",
94
- "rollup": "2.60.1",
95
- "typescript": "4.5.2"
84
+ "pob-babel": "29.3.0",
85
+ "typescript": "4.5.3"
96
86
  },
97
- "gitHead": "70f6b4ba634ff778fc94bef7e2455e8b6a7db06a"
87
+ "gitHead": "682f57fa30eaca9732681d16008abb2680b24174"
98
88
  }
@@ -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
@@ -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,63 +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
- var querystring = (_document$location = document.location) == null ? void 0 : _document$location.search;
9
- var 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
- var 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
- var findDebugLevel = function findDebugLevel(minLevel, key) {
22
- return createFindDebugLevel(getDebugString())(minLevel, key);
23
- };
24
-
25
- var getDefaultTheme = function getDefaultTheme() {
26
- try {
27
- var configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
28
-
29
- if (configInLocalStorage && configInLocalStorage === 'dark') {
30
- return configInLocalStorage;
31
- }
32
- } catch (_unused) {}
33
-
34
- return 'light';
35
- };
36
-
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) {
44
- consoleOutput(browserConsoleFormatter(record), record);
45
- };
46
- };
47
-
48
- var BrowserConsoleHandler = function BrowserConsoleHandler(minLevel, options) {
49
- if (options === void 0) {
50
- options = {};
51
- }
52
-
53
- this.minLevel = 0;
54
-
55
- this.isHandling = function (level, key) {
56
- return level >= findDebugLevel(minLevel, key);
57
- };
58
-
59
- this.handle = createHandler(options.theme);
60
- };
61
-
62
- export { BrowserConsoleHandler, BrowserConsoleHandler as default };
63
- //# 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","options","isH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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,54 +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 || _document$location === void 0 ? 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 {}
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 { BrowserConsoleHandler, BrowserConsoleHandler as default };
54
- //# 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;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,G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