nightingale-browser-console 12.1.4 → 13.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 +22 -0
- package/README.md +3 -0
- package/dist/{debug.d.ts → definitions/debug.d.ts} +0 -0
- package/dist/definitions/debug.d.ts.map +1 -0
- package/dist/{index.d.ts → definitions/index.d.ts} +2 -2
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/index-browser.es.js +5 -14
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +5 -13
- package/dist/index-browsermodern.es.js.map +1 -1
- package/package.json +23 -30
- package/src/index.ts +1 -1
- package/dist/debug.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/rollup.config.mjs +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
# [13.0.0](https://github.com/christophehurpeau/nightingale/compare/v12.1.4...v13.0.0) (2022-11-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Code Refactoring
|
|
10
|
+
|
|
11
|
+
* drop node 14 and cjs ([9a8ca06](https://github.com/christophehurpeau/nightingale/commit/9a8ca064449ddc0d69e26543e21c2d522536c50a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* build for node 16 ([30ae3e9](https://github.com/christophehurpeau/nightingale/commit/30ae3e9c455dbad793c2f704b9d860069dc80c32))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* dropped node 14 and cjs
|
|
22
|
+
* drop node 14
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [12.1.4](https://github.com/christophehurpeau/nightingale/compare/v12.1.3...v12.1.4) (2022-02-05)
|
|
7
29
|
|
|
8
30
|
|
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://npmjs.org/package/nightingale-browser-console"><img src="https://img.shields.io/npm/v/nightingale-browser-console.svg?style=flat-square"></a>
|
|
11
|
+
<a href="https://npmjs.org/package/nightingale-browser-console"><img src="https://img.shields.io/npm/dw/nightingale-browser-console.svg?style=flat-square"></a>
|
|
12
|
+
<a href="https://npmjs.org/package/nightingale-browser-console"><img src="https://img.shields.io/node/v/nightingale-browser-console.svg?style=flat-square"></a>
|
|
13
|
+
<a href="https://npmjs.org/package/nightingale-browser-console"><img src="https://img.shields.io/npm/types/nightingale-browser-console.svg?style=flat-square"></a>
|
|
11
14
|
</p>
|
|
12
15
|
|
|
13
16
|
## Install
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,IAAI,MAAM,CAsBvC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Level, Handle, IsHandling, Handler } from 'nightingale-types';
|
|
2
|
-
|
|
3
|
-
interface BrowserConsoleHandlerOptions {
|
|
2
|
+
type Theme = 'light' | 'dark';
|
|
3
|
+
export interface BrowserConsoleHandlerOptions {
|
|
4
4
|
theme?: Theme;
|
|
5
5
|
}
|
|
6
6
|
export declare class BrowserConsoleHandler implements Handler {
|
|
@@ -0,0 +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"}
|
package/dist/index-browser.es.js
CHANGED
|
@@ -4,58 +4,49 @@ import { createFindDebugLevel } from 'nightingale-debug';
|
|
|
4
4
|
|
|
5
5
|
function getDebugString() {
|
|
6
6
|
var _document$location;
|
|
7
|
-
|
|
8
7
|
var querystring = (_document$location = document.location) == null ? void 0 : _document$location.search;
|
|
9
8
|
var debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
|
|
10
|
-
|
|
11
9
|
if (!querystring) {
|
|
12
10
|
return debugFromLocalStorage;
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
}
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
|
|
14
|
+
var debugFromQueryString = decodeURI(querystring.replace(
|
|
15
|
+
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
|
|
17
16
|
new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
|
|
18
17
|
return (debugFromLocalStorage ? debugFromLocalStorage + "," : '') + debugFromQueryString;
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
// debug string can change any time (localStorage), so we need a new object each time.
|
|
21
21
|
var findDebugLevel = function findDebugLevel(minLevel, key) {
|
|
22
22
|
return createFindDebugLevel(getDebugString())(minLevel, key);
|
|
23
23
|
};
|
|
24
|
-
|
|
25
24
|
var getDefaultTheme = function getDefaultTheme() {
|
|
26
25
|
try {
|
|
27
26
|
var configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
|
|
28
|
-
|
|
29
27
|
if (configInLocalStorage && configInLocalStorage === 'dark') {
|
|
30
28
|
return configInLocalStorage;
|
|
31
29
|
}
|
|
32
30
|
} catch (_unused) {}
|
|
33
|
-
|
|
34
31
|
return 'light';
|
|
35
32
|
};
|
|
36
|
-
|
|
37
33
|
var createHandler = function createHandler(theme) {
|
|
38
34
|
if (theme === void 0) {
|
|
39
35
|
theme = getDefaultTheme();
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
var browserConsoleFormatter = createBrowserConsoleFormatter(theme);
|
|
43
38
|
return function (record) {
|
|
44
39
|
consoleOutput(browserConsoleFormatter(record), record);
|
|
45
40
|
};
|
|
46
41
|
};
|
|
47
|
-
|
|
48
42
|
var BrowserConsoleHandler = function BrowserConsoleHandler(minLevel, options) {
|
|
49
43
|
if (options === void 0) {
|
|
50
44
|
options = {};
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
this.minLevel = 0;
|
|
54
|
-
|
|
55
47
|
this.isHandling = function (level, key) {
|
|
56
48
|
return level >= findDebugLevel(minLevel, key);
|
|
57
49
|
};
|
|
58
|
-
|
|
59
50
|
this.handle = createHandler(options.theme);
|
|
60
51
|
};
|
|
61
52
|
|
|
@@ -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\
|
|
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,E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EY,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;;;;"}
|
|
@@ -4,50 +4,42 @@ import { createFindDebugLevel } from 'nightingale-debug';
|
|
|
4
4
|
|
|
5
5
|
function getDebugString() {
|
|
6
6
|
var _document$location;
|
|
7
|
-
|
|
8
7
|
const querystring = (_document$location = document.location) === null || _document$location === void 0 ? void 0 : _document$location.search;
|
|
9
8
|
const debugFromLocalStorage = window.localStorage && localStorage.getItem('debug') || '';
|
|
10
|
-
|
|
11
9
|
if (!querystring) {
|
|
12
10
|
return debugFromLocalStorage;
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
}
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URLUtils/search#Get_the_value_of_a_single_search_param
|
|
14
|
+
const debugFromQueryString = decodeURI(querystring.replace(
|
|
15
|
+
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-regex-literals
|
|
17
16
|
new RegExp('^(?:.*[&\\?]DEBUG(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
|
|
18
17
|
return (debugFromLocalStorage ? `${debugFromLocalStorage},` : '') + debugFromQueryString;
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
// debug string can change any time (localStorage), so we need a new object each time.
|
|
21
21
|
const findDebugLevel = (minLevel, key) => createFindDebugLevel(getDebugString())(minLevel, key);
|
|
22
|
-
|
|
23
22
|
const getDefaultTheme = () => {
|
|
24
23
|
try {
|
|
25
24
|
const configInLocalStorage = localStorage.getItem('NIGHTINGALE_THEME');
|
|
26
|
-
|
|
27
25
|
if (configInLocalStorage && configInLocalStorage === 'dark') {
|
|
28
26
|
return configInLocalStorage;
|
|
29
27
|
}
|
|
30
28
|
} catch {}
|
|
31
|
-
|
|
32
29
|
return 'light';
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
const createHandler = (theme = getDefaultTheme()) => {
|
|
36
32
|
const browserConsoleFormatter = createBrowserConsoleFormatter(theme);
|
|
37
33
|
return record => {
|
|
38
34
|
consoleOutput(browserConsoleFormatter(record), record);
|
|
39
35
|
};
|
|
40
36
|
};
|
|
41
|
-
|
|
42
37
|
class BrowserConsoleHandler {
|
|
43
38
|
minLevel = 0;
|
|
44
|
-
|
|
45
39
|
constructor(minLevel, options = {}) {
|
|
46
40
|
this.isHandling = (level, key) => level >= findDebugLevel(minLevel, key);
|
|
47
|
-
|
|
48
41
|
this.handle = createHandler(options.theme);
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
export { BrowserConsoleHandler };
|
|
@@ -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\
|
|
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,CAA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AI,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": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Browser console handler for nightingale",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nightingale",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
17
17
|
"type": "module",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=16.0.0"
|
|
20
|
+
},
|
|
18
21
|
"browserslist": [
|
|
19
22
|
"defaults",
|
|
20
23
|
"> 0.2%",
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
"not safari < 10",
|
|
23
26
|
"not ios_saf < 10"
|
|
24
27
|
],
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
28
|
+
"types": "./dist/definitions/index.d.ts",
|
|
26
29
|
"module": "./dist/index-browser.es.js",
|
|
27
30
|
"browser": "./dist/index-browser.es.js",
|
|
28
31
|
"exports": {
|
|
@@ -36,35 +39,25 @@
|
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
},
|
|
39
|
-
"module:modern-browsers": "./dist/index-browsermodern.es.js",
|
|
40
42
|
"sideEffects": false,
|
|
41
43
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build:definitions": "tsc -p
|
|
44
|
-
"clean": "
|
|
44
|
+
"build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
|
|
45
|
+
"build:definitions": "tsc -p",
|
|
46
|
+
"clean": "yarn clean:build",
|
|
47
|
+
"clean:build": "pob-babel-clean-out dist",
|
|
45
48
|
"lint": "yarn run lint:eslint",
|
|
46
|
-
"lint:eslint": "
|
|
47
|
-
"watch": "
|
|
48
|
-
},
|
|
49
|
-
"prettier": {
|
|
50
|
-
"trailingComma": "all",
|
|
51
|
-
"singleQuote": true,
|
|
52
|
-
"arrowParens": "always"
|
|
49
|
+
"lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-browser-console",
|
|
50
|
+
"watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
|
|
53
51
|
},
|
|
52
|
+
"prettier": "@pob/root/prettier-config",
|
|
54
53
|
"pob": {
|
|
55
54
|
"babelEnvs": [
|
|
56
55
|
{
|
|
57
56
|
"target": "browser",
|
|
58
|
-
"version": "modern"
|
|
59
|
-
"formats": [
|
|
60
|
-
"es"
|
|
61
|
-
]
|
|
57
|
+
"version": "modern"
|
|
62
58
|
},
|
|
63
59
|
{
|
|
64
|
-
"target": "browser"
|
|
65
|
-
"formats": [
|
|
66
|
-
"es"
|
|
67
|
-
]
|
|
60
|
+
"target": "browser"
|
|
68
61
|
}
|
|
69
62
|
],
|
|
70
63
|
"entries": [
|
|
@@ -72,17 +65,17 @@
|
|
|
72
65
|
]
|
|
73
66
|
},
|
|
74
67
|
"dependencies": {
|
|
75
|
-
"nightingale-browser-console-formatter": "
|
|
76
|
-
"nightingale-console-output": "
|
|
77
|
-
"nightingale-debug": "
|
|
78
|
-
"nightingale-types": "
|
|
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"
|
|
79
72
|
},
|
|
80
73
|
"devDependencies": {
|
|
81
|
-
"@babel/core": "7.
|
|
82
|
-
"@babel/preset-env": "7.
|
|
74
|
+
"@babel/core": "7.20.2",
|
|
75
|
+
"@babel/preset-env": "7.20.2",
|
|
83
76
|
"babel-preset-modern-browsers": "15.0.2",
|
|
84
|
-
"pob-babel": "
|
|
85
|
-
"typescript": "4.
|
|
77
|
+
"pob-babel": "35.3.0",
|
|
78
|
+
"typescript": "4.9.3"
|
|
86
79
|
},
|
|
87
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "52cf7e3c8762a07891da9dde497ec03298c15654"
|
|
88
81
|
}
|
package/src/index.ts
CHANGED
package/dist/debug.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,IAAI,MAAM,CAsBvC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/rollup.config.mjs
DELETED