nightingale-browser-console 11.7.4 → 12.1.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/.eslintrc.json +1 -1
- package/CHANGELOG.md +54 -0
- package/README.md +8 -10
- package/dist/index-browser.es.js +3 -3
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +4 -4
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +12 -22
- package/src/.eslintrc.json +18 -1
- package/src/debug.ts +1 -1
- package/src/index.ts +0 -3
- package/dist/index-browser-dev.es.js +0 -63
- package/dist/index-browser-dev.es.js.map +0 -1
- package/dist/index-browsermodern-dev.es.js +0 -54
- package/dist/index-browsermodern-dev.es.js.map +0 -1
package/.eslintrc.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,60 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [12.1.1](https://github.com/christophehurpeau/nightingale/compare/v12.1.0...v12.1.1) (2022-01-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* properly configure package type ([2e0cbf5](https://github.com/christophehurpeau/nightingale/commit/2e0cbf555bd3b9fa3c3851025452937f64408aa8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [12.1.0](https://github.com/christophehurpeau/nightingale/compare/v12.0.1...v12.1.0) (2021-12-15)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package nightingale-browser-console
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [12.0.1](https://github.com/christophehurpeau/nightingale/compare/v12.0.0...v12.0.1) (2021-12-12)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package nightingale-browser-console
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [12.0.0](https://github.com/christophehurpeau/nightingale/compare/v11.9.0...v12.0.0) (2021-12-11)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* typings ([2715620](https://github.com/christophehurpeau/nightingale/commit/271562032469125cf1ccb493db37117e60a0e54f))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Build System
|
|
42
|
+
|
|
43
|
+
* node 14 and remove dev builds ([432ecd1](https://github.com/christophehurpeau/nightingale/commit/432ecd1faafd0419f57dea00fce560e4cccc207f))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* drop default exports ([8878e49](https://github.com/christophehurpeau/nightingale/commit/8878e492b94852fcb892fd6d12c02c15c31b38b9))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### BREAKING CHANGES
|
|
52
|
+
|
|
53
|
+
* use named imports instead of default exports
|
|
54
|
+
* requires node 14
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
6
60
|
## [11.7.4](https://github.com/christophehurpeau/nightingale/compare/v11.7.3...v11.7.4) (2021-11-27)
|
|
7
61
|
|
|
8
62
|
**Note:** Version bump only for package nightingale-browser-console
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm install --save nightingale-browser-console
|
|
|
20
20
|
|
|
21
21
|
```js
|
|
22
22
|
import { configure, levels } from 'nightingale';
|
|
23
|
-
import ConsoleHandler from 'nightingale-browser-console';
|
|
23
|
+
import { ConsoleHandler } from 'nightingale-browser-console';
|
|
24
24
|
|
|
25
25
|
configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
|
|
26
26
|
```
|
|
@@ -29,37 +29,35 @@ configure([{ handlers: [new ConsoleHandler(Level.INFO)] }]);
|
|
|
29
29
|
|
|
30
30
|
If you have a dark console theme, you can set this config in your localStorage :
|
|
31
31
|
|
|
32
|
-
```
|
|
32
|
+
```js
|
|
33
33
|
localStorage.NIGHTINGALE_THEME = 'dark';
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
You can also force this option:
|
|
37
37
|
|
|
38
|
-
```
|
|
39
|
-
import ConsoleHandler from 'nightingale-browser-console';
|
|
40
|
-
|
|
38
|
+
```js
|
|
39
|
+
import { ConsoleHandler } from 'nightingale-browser-console';
|
|
41
40
|
|
|
42
41
|
configure([{ handlers: [new ConsoleHandler(Level.INFO, { theme: 'dark' })] }]);
|
|
43
|
-
|
|
44
42
|
```
|
|
45
43
|
|
|
46
44
|
## Debug
|
|
47
45
|
|
|
48
46
|
### with localStorage
|
|
49
47
|
|
|
50
|
-
```
|
|
48
|
+
```js
|
|
51
49
|
localStorage.debug = '*'; // debug everything
|
|
52
50
|
localStorage.debug = 'app'; // debug for logger with key 'app'
|
|
53
51
|
localStorage.debug = 'app,nightingale'; // debug for logger with key 'app' and 'nightingale'
|
|
54
|
-
localStorage.debug = '/^app/';
|
|
55
|
-
localStorage.debug = '/^(app|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'
|
package/dist/index-browser.es.js
CHANGED
|
@@ -13,9 +13,9 @@ 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
|
-
return (debugFromLocalStorage ?
|
|
18
|
+
return (debugFromLocalStorage ? debugFromLocalStorage + "," : '') + debugFromQueryString;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
var findDebugLevel = function findDebugLevel(minLevel, key) {
|
|
@@ -59,5 +59,5 @@ var BrowserConsoleHandler = function BrowserConsoleHandler(minLevel, options) {
|
|
|
59
59
|
this.handle = createHandler(options.theme);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export { BrowserConsoleHandler
|
|
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
|
|
1
|
+
{"version":3,"file":"index-browser.es.js","sources":["../src/debug.ts","../src/index.ts"],"sourcesContent":["export function getDebugString(): string {\n const querystring = document.location?.search;\n const debugFromLocalStorage =\n (window.localStorage && localStorage.getItem('debug')) || '';\n\n if (!querystring) {\n return debugFromLocalStorage;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param\n const debugFromQueryString = decodeURI(\n querystring.replace(\n // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals\n new RegExp('^(?:.*[&\\\\?]DEBUG(?:\\\\=([^&]*))?)?.*$', 'i'),\n '$1',\n ),\n );\n\n return (\n (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') +\n debugFromQueryString\n );\n}\n","import { createBrowserConsoleFormatter } from 'nightingale-browser-console-formatter';\nimport consoleOutput from 'nightingale-console-output';\nimport { createFindDebugLevel } from 'nightingale-debug';\nimport type {\n Level,\n Handle,\n IsHandling,\n LogRecord,\n Metadata,\n Handler,\n} from 'nightingale-types';\nimport { getDebugString } from './debug';\n\n// debug string can change any time (localStorage), so we need a new object each time.\nconst findDebugLevel = (minLevel: Level, key: string): Level =>\n createFindDebugLevel(getDebugString())(minLevel, key);\n\ntype Theme = 'light' | 'dark';\n\nconst getDefaultTheme = (): Theme => {\n try {\n const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');\n if (configInLocalStorage && configInLocalStorage === 'dark') {\n return configInLocalStorage;\n }\n } catch {}\n return 'light';\n};\n\nconst createHandler = (theme: Theme = getDefaultTheme()): Handle => {\n const browserConsoleFormatter = createBrowserConsoleFormatter(theme);\n return <T extends Metadata>(record: LogRecord<T>) => {\n consoleOutput(browserConsoleFormatter(record), record);\n };\n};\n\ninterface BrowserConsoleHandlerOptions {\n theme?: Theme;\n}\n\nexport class BrowserConsoleHandler implements Handler {\n minLevel: Level = 0;\n\n handle: Handle;\n\n isHandling: IsHandling;\n\n constructor(minLevel: Level, options: BrowserConsoleHandlerOptions = {}) {\n this.isHandling = (level: Level, key: string) =>\n level >= findDebugLevel(minLevel, key);\n\n this.handle = createHandler(options.theme);\n }\n}\n"],"names":["getDebugString","querystring","document","location","search","debugFromLocalStorage","window","localStorage","getItem","debugFromQueryString","decodeURI","replace","RegExp","findDebugLevel","minLevel","key","createFindDebugLevel","getDefaultTheme","configInLocalStorage","createHandler","theme","browserConsoleFormatter","createBrowserConsoleFormatter","record","consoleOutput","BrowserConsoleHandler","options","isHandling","level","handle"],"mappings":";;;;AAAO,SAASA,cAAT,GAAkC;AAAA;;AACvC,MAAMC,WAAW,yBAAGC,QAAQ,CAACC,QAAZ,qBAAG,mBAAmBC,MAAvC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,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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
13
|
-
export default BrowserConsoleHandler;
|
|
12
|
+
export {};
|
|
14
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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
|
|
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": "
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "Browser console handler for nightingale",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nightingale",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"directory": "packages/nightingale-browser-console"
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
17
|
-
"type": "
|
|
17
|
+
"type": "module",
|
|
18
18
|
"browserslist": [
|
|
19
19
|
"defaults",
|
|
20
20
|
"> 0.2%",
|
|
@@ -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
|
|
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": "
|
|
85
|
-
"nightingale-console-output": "
|
|
86
|
-
"nightingale-debug": "
|
|
87
|
-
"nightingale-types": "
|
|
75
|
+
"nightingale-browser-console-formatter": "12.1.1",
|
|
76
|
+
"nightingale-console-output": "12.1.1",
|
|
77
|
+
"nightingale-debug": "12.1.1",
|
|
78
|
+
"nightingale-types": "12.1.1"
|
|
88
79
|
},
|
|
89
80
|
"devDependencies": {
|
|
90
|
-
"@babel/core": "7.16.
|
|
91
|
-
"@babel/preset-env": "7.16.
|
|
81
|
+
"@babel/core": "7.16.7",
|
|
82
|
+
"@babel/preset-env": "7.16.7",
|
|
92
83
|
"babel-preset-modern-browsers": "15.0.2",
|
|
93
|
-
"pob-babel": "
|
|
94
|
-
"
|
|
95
|
-
"typescript": "4.5.2"
|
|
84
|
+
"pob-babel": "29.6.1",
|
|
85
|
+
"typescript": "4.5.4"
|
|
96
86
|
},
|
|
97
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "719598e0a3d508801b18542a1054301200b62ed0"
|
|
98
88
|
}
|
package/src/.eslintrc.json
CHANGED
|
@@ -6,5 +6,22 @@
|
|
|
6
6
|
},
|
|
7
7
|
"plugins": ["@typescript-eslint"],
|
|
8
8
|
"extends": ["@pob/eslint-config-typescript"],
|
|
9
|
-
"ignorePatterns": ["*.d.ts"]
|
|
9
|
+
"ignorePatterns": ["*.d.ts"],
|
|
10
|
+
"overrides": [
|
|
11
|
+
{
|
|
12
|
+
"files": ["**/*.test.ts", "__tests__/**/*.ts"],
|
|
13
|
+
"extends": ["@pob/eslint-config-typescript/test"],
|
|
14
|
+
"env": {
|
|
15
|
+
"jest": true
|
|
16
|
+
},
|
|
17
|
+
"rules": {
|
|
18
|
+
"import/no-extraneous-dependencies": [
|
|
19
|
+
"error",
|
|
20
|
+
{
|
|
21
|
+
"devDependencies": true
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
10
27
|
}
|
package/src/debug.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function getDebugString(): string {
|
|
|
10
10
|
// https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
|
|
11
11
|
const debugFromQueryString = decodeURI(
|
|
12
12
|
querystring.replace(
|
|
13
|
-
// eslint-disable-next-line unicorn/no-unsafe-regex
|
|
13
|
+
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
|
|
14
14
|
new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'),
|
|
15
15
|
'$1',
|
|
16
16
|
),
|
package/src/index.ts
CHANGED
|
@@ -1,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","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,uCAA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B;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,qBAA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