@ribbon-studios/logger 2.0.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,19 +9,19 @@
9
9
  [![Semantic Release][semantic-release-image]][semantic-release-url]
10
10
  [![Code Style: Prettier][code-style-image]][code-style-url]
11
11
 
12
- A simple logger for all Rainbow Cafe Apps & Libraries
12
+ A simple logger for all Ribbon Studios Apps & Libraries
13
13
 
14
14
  ### Usage
15
15
 
16
16
  ```ts
17
- import { Logger, LogLevel } from '@ribbon-studios/logger';
17
+ import { logger, LogLevel } from '@ribbon-studios/logger';
18
18
 
19
- Logger.setLevel(LogLevel.INFO); // This is the default LogLevel
19
+ logger.setLevel(LogLevel.INFO); // This is the default LogLevel
20
20
 
21
- Logger.silly('hello', 'world!'); // Outputs nothing since its lower then the configured level!
22
- Logger.info('hello', 'world!'); // '[info]: hello world!'
23
- Logger.warn('hello', 'world!'); // '[warn]: hello world!'
24
- Logger.error('hello', 'world!'); // '[error]: hello world!'
21
+ logger.silly('hello', 'world!'); // Outputs nothing since its lower then the configured level!
22
+ logger.info('hello', 'world!'); // '[info]: hello world!'
23
+ logger.warn('hello', 'world!'); // '[warn]: hello world!'
24
+ logger.error('hello', 'world!'); // '[error]: hello world!'
25
25
  ```
26
26
 
27
27
  [npm-version-image]: https://img.shields.io/npm/v/@ribbon-studios/logger.svg
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`chalk`);c=s(c);function l(e){let t=new Set;return JSON.stringify(e,(e,n)=>{if(typeof n==`object`&&n){if(t.has(n))return;t.add(n)}return n},4)}function u(e){return e.map(e=>e instanceof Error||typeof e!=`object`?e:l(e))}var d=function(e){return e[e.ERROR=0]=`ERROR`,e[e.WARN=1]=`WARN`,e[e.INFO=2]=`INFO`,e[e.SILLY=3]=`SILLY`,e}({}),f=Object.keys(d).reduce((e,t)=>Math.max(e,t.length),0)+3,p={[d.ERROR]:c.default.red,[d.WARN]:c.default.yellow,[d.INFO]:c.default.cyan,[d.SILLY]:c.default.magenta},m=class{#e;constructor(e){this.#e={level:d.INFO,...typeof e==`string`?{scope:e}:e},this.#e.scope&&(this.prefix=c.default.rgb(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))(`[${this.#e.scope}]`))}isLevel(e){return e!=null&&this.#e.level>=e}isNotLevel(e){return!this.isLevel(e)}setLevel(e){this.#e.level=e}log(e,...t){if(this.isNotLevel(e))return;let n=p[e],r=u(t).map(e=>e instanceof Error?e:n(e)),i=[this.prefix,n(`[${d[e].toLowerCase()}]:`).padEnd(f,` `)].filter(Boolean).join(``);console.log(i,...r)}error(...e){this.log(d.ERROR,...e)}warn(...e){this.log(d.WARN,...e)}info(...e){this.log(d.INFO,...e)}silly(...e){this.log(d.SILLY,...e)}},h=new m;exports.LEVEL_CHALK=p,exports.LogLevel=d,exports.MAX_LENGTH=f,exports.RibbonLogger=m,exports.logger=h;
package/dist/index.js CHANGED
@@ -1,2 +1,63 @@
1
- function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,o,n=/*#__PURE__*/e(require("chalk")),r=0;function l(e){return"__private_"+r+++"_"+e}function c(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}exports.LogLevel=void 0,(o=exports.LogLevel||(exports.LogLevel={}))[o.ERROR=0]="ERROR",o[o.WARN=1]="WARN",o[o.INFO=2]="INFO",o[o.SILLY=3]="SILLY";var a=Object.keys(exports.LogLevel).reduce(function(e,t){return Math.max(e,t.length)},0)+3,L=((t={})[exports.LogLevel.ERROR]=n.default.red,t[exports.LogLevel.WARN]=n.default.yellow,t[exports.LogLevel.INFO]=n.default.cyan,t[exports.LogLevel.SILLY]=n.default.magenta,t),i=/*#__PURE__*/l("level"),p=/*#__PURE__*/function(){function e(){}return e.isLevel=function(t){return c(e,i)[i]>=t},e.isNotLevel=function(t){return!e.isLevel(t)},e.setLevel=function(t){c(e,i)[i]=t},e.log=function(t){var o;if(!e.isNotLevel(t)){var n=L[t],r=function(e){return e.map(function(e){return e instanceof Error||"object"!=typeof e?e:(t=e,o=new Set,JSON.stringify(t,function(e,t){if("object"==typeof t&&null!==t){if(o.has(t))return;o.add(t)}return t},4));var t,o})}([].slice.call(arguments,1)).map(function(e){return e instanceof Error?e:n(e)});(o=console).log.apply(o,[n("["+exports.LogLevel[t].toLowerCase()+"]:").padEnd(a," ")].concat(r))}},e.error=function(){e.log.apply(e,[exports.LogLevel.ERROR].concat([].slice.call(arguments)))},e.warn=function(){e.log.apply(e,[exports.LogLevel.WARN].concat([].slice.call(arguments)))},e.info=function(){e.log.apply(e,[exports.LogLevel.INFO].concat([].slice.call(arguments)))},e.silly=function(){e.log.apply(e,[exports.LogLevel.SILLY].concat([].slice.call(arguments)))},e}();Object.defineProperty(p,i,{writable:!0,value:exports.LogLevel.INFO}),exports.LEVEL_CHALK=L,exports.Logger=p,exports.MAX_LENGTH=a;
2
- //# sourceMappingURL=index.js.map
1
+ import e from "chalk";
2
+ //#region src/utils/stringify.ts
3
+ function t(e) {
4
+ let t = /* @__PURE__ */ new Set();
5
+ return JSON.stringify(e, (e, n) => {
6
+ if (typeof n == "object" && n) {
7
+ if (t.has(n)) return;
8
+ t.add(n);
9
+ }
10
+ return n;
11
+ }, 4);
12
+ }
13
+ //#endregion
14
+ //#region src/utils/messages.ts
15
+ function n(e) {
16
+ return e.map((e) => e instanceof Error || typeof e != "object" ? e : t(e));
17
+ }
18
+ //#endregion
19
+ //#region src/logger.ts
20
+ var r = /* @__PURE__ */ function(e) {
21
+ return e[e.ERROR = 0] = "ERROR", e[e.WARN = 1] = "WARN", e[e.INFO = 2] = "INFO", e[e.SILLY = 3] = "SILLY", e;
22
+ }({}), i = Object.keys(r).reduce((e, t) => Math.max(e, t.length), 0) + 3, a = {
23
+ [r.ERROR]: e.red,
24
+ [r.WARN]: e.yellow,
25
+ [r.INFO]: e.cyan,
26
+ [r.SILLY]: e.magenta
27
+ }, o = class {
28
+ #e;
29
+ constructor(t) {
30
+ this.#e = {
31
+ level: r.INFO,
32
+ ...typeof t == "string" ? { scope: t } : t
33
+ }, this.#e.scope && (this.prefix = e.rgb(Math.floor(Math.random() * 255), Math.floor(Math.random() * 255), Math.floor(Math.random() * 255))(`[${this.#e.scope}]`));
34
+ }
35
+ isLevel(e) {
36
+ return e != null && this.#e.level >= e;
37
+ }
38
+ isNotLevel(e) {
39
+ return !this.isLevel(e);
40
+ }
41
+ setLevel(e) {
42
+ this.#e.level = e;
43
+ }
44
+ log(e, ...t) {
45
+ if (this.isNotLevel(e)) return;
46
+ let o = a[e], s = n(t).map((e) => e instanceof Error ? e : o(e)), c = [this.prefix, o(`[${r[e].toLowerCase()}]:`).padEnd(i, " ")].filter(Boolean).join("");
47
+ console.log(c, ...s);
48
+ }
49
+ error(...e) {
50
+ this.log(r.ERROR, ...e);
51
+ }
52
+ warn(...e) {
53
+ this.log(r.WARN, ...e);
54
+ }
55
+ info(...e) {
56
+ this.log(r.INFO, ...e);
57
+ }
58
+ silly(...e) {
59
+ this.log(r.SILLY, ...e);
60
+ }
61
+ }, s = new o();
62
+ //#endregion
63
+ export { a as LEVEL_CHALK, r as LogLevel, i as MAX_LENGTH, o as RibbonLogger, s as logger };
package/dist/logger.d.ts CHANGED
@@ -12,8 +12,14 @@ export declare const LEVEL_CHALK: {
12
12
  /**
13
13
  * A simple wrapper around 'console.log'
14
14
  */
15
- export declare class Logger {
15
+ export declare class RibbonLogger {
16
16
  #private;
17
+ readonly prefix?: string;
18
+ /**
19
+ * @param scope prefixes the messages with the given scope
20
+ */
21
+ constructor(scope?: string);
22
+ constructor(options?: Partial<RibbonLogger.Options>);
17
23
  /**
18
24
  * Returns whether the logger is configured to allow the given log level to output.
19
25
  * @param level the level to validate
@@ -26,42 +32,49 @@ export declare class Logger {
26
32
  * // Also returns true
27
33
  * Logger.isLevel(LogLevel.INFO);
28
34
  */
29
- static isLevel(level?: LogLevel): boolean;
35
+ isLevel(level?: LogLevel): boolean;
30
36
  /**
31
37
  * Returns whether the logger is configured to deny the given log level to output.
32
38
  * @param level the level to validate
33
39
  * @returns true if the given level is lower priority then the configured level
34
40
  */
35
- static isNotLevel(level?: LogLevel): boolean;
41
+ isNotLevel(level?: LogLevel): boolean;
36
42
  /**
37
43
  * Sets the level to allow to output
38
44
  * @param level the level to set
39
45
  */
40
- static setLevel(level: LogLevel): void;
46
+ setLevel(level: LogLevel): void;
41
47
  /**
42
48
  * A wrapper around console.log with color formatting and filtering by the set LogLevel.
43
49
  * @param level the LogLevel of this message
44
50
  * @param rawMessages the messages to send
45
51
  */
46
- static log(level: LogLevel, ...rawMessages: any[]): void;
52
+ log(level: LogLevel, ...rawMessages: any[]): void;
47
53
  /**
48
54
  * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}
49
55
  * @param messages the messages to send
50
56
  */
51
- static error(...messages: any[]): void;
57
+ error(...messages: any[]): void;
52
58
  /**
53
59
  * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}
54
60
  * @param messages the messages to send
55
61
  */
56
- static warn(...messages: any[]): void;
62
+ warn(...messages: any[]): void;
57
63
  /**
58
64
  * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}
59
65
  * @param messages the messages to send
60
66
  */
61
- static info(...messages: any[]): void;
67
+ info(...messages: any[]): void;
62
68
  /**
63
69
  * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}
64
70
  * @param messages the messages to send
65
71
  */
66
- static silly(...messages: any[]): void;
72
+ silly(...messages: any[]): void;
73
+ }
74
+ export declare namespace RibbonLogger {
75
+ type Options = {
76
+ scope?: string;
77
+ level: LogLevel;
78
+ };
67
79
  }
80
+ export declare const logger: RibbonLogger;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,34 +1,36 @@
1
1
  {
2
2
  "name": "@ribbon-studios/logger",
3
- "version": "2.0.2",
4
- "description": "A simple logger for all Rainbow Cafe Apps & Libraries",
3
+ "version": "3.0.1",
4
+ "type": "module",
5
+ "description": "A simple logger for all Ribbon Studios Apps & Libraries",
5
6
  "source": "src/index.ts",
6
- "main": "dist/index.js",
7
- "umd:main": "dist/index.umd.js",
8
- "module": "dist/index.mjs",
9
- "exports": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "default": "./dist/index.modern.mjs"
13
- },
7
+ "main": "dist/index.cjs",
8
+ "module": "dist/index.js",
14
9
  "types": "dist/index.d.ts",
15
10
  "scripts": {
16
11
  "lint": "eslint 'src/**/*.ts'",
17
- "build": "microbundle"
12
+ "build": "vite build",
13
+ "test": "vitest",
14
+ "test:coverage": "vitest --coverage"
18
15
  },
19
- "dependencies": {
20
- "chalk": "^5"
16
+ "peerDependencies": {
17
+ "chalk": "^5.4.1"
21
18
  },
22
19
  "devDependencies": {
23
- "@types/node": "^18",
24
- "@typescript-eslint/eslint-plugin": "^6.1.0",
25
- "@typescript-eslint/parser": "^6.1.0",
26
- "chance": "^1.1.11",
27
- "dedent": "^1.5.1",
28
- "eslint": "^8.45.0",
29
- "microbundle": "^0.15.1",
30
- "string-dedent": "^3.0.1",
31
- "typescript": "^5.1.6"
20
+ "@types/chance": "^1.1.7",
21
+ "@types/node": "^22.19.15",
22
+ "@vitest/coverage-v8": "4.1.0",
23
+ "ajv": "^8.18.0",
24
+ "chance": "^1.1.13",
25
+ "dedent": "^1.7.2",
26
+ "eslint-plugin-unused-imports": "^4.4.1",
27
+ "jiti": "^2.6.1",
28
+ "string-dedent": "^3.0.2",
29
+ "typescript": "^5.9.3",
30
+ "typescript-eslint": "^8.57.0",
31
+ "vite": "^8.0.0",
32
+ "vite-plugin-dts": "^4.5.4",
33
+ "vitest": "^4.1.0"
32
34
  },
33
35
  "publishConfig": {
34
36
  "access": "public"
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"8EAGYA,iOAAAA,QAAZA,cAAA,GAAYA,EAAAA,QAAAA,WAAAA,QAAAA,SAKX,CAAA,IAJCA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,QAGW,IAAAC,EACXC,OAAOC,KAAKH,QAAQA,UAAEI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,QAAAA,SAASY,OAAQC,EAAK,QAACC,IAAGH,EAC1BX,QAAQA,SAACe,MAAOF,EAAK,QAACG,OAAML,EAC5BX,QAAQA,SAACiB,MAAOJ,EAAAA,QAAMK,KAAIP,EAC1BX,QAAAA,SAASmB,OAAQN,EAAK,QAACO,QAAOT,GAC/BU,eAAAC,EAAA,SAKWC,eAAM,WAAA,SAAAA,IAAAA,CAmFhB,OAnFgBA,EAeHC,QAAP,SAAeC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,EAACF,EAOaI,WAAP,SAAkBF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,EAACF,EAMaK,SAAP,SAAgBH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,EAACF,EAOaM,IAAP,SAAWJ,GAAsC,IAAAK,EACtD,IAAIP,EAAOI,WAAWF,GAAtB,CAEA,IAAMZ,EAAQH,EAAYe,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,IAAI,SAACC,GACnB,OAAIA,aAAmBC,OAA4B,iBAAZD,EAC9BA,GCLaE,EDQLF,ECPbG,EAAQ,IAAIC,IAEXC,KAAKC,UACVJ,EACA,SAACK,EAAKlC,GACJ,GAAqB,iBAAVA,GAAgC,OAAVA,EAAgB,CAC/C,GAAI8B,EAAMK,IAAInC,GAEZ,OAGF8B,EAAMM,IAAIpC,EACZ,CACA,OAAOA,CACT,EACA,IAhBY,IAAU6B,EAClBC,CDQN,EACF,CD+DqBO,CAAgB,GAAAC,MAAAC,KAAAC,UAAA,IAAcd,IAAI,SAACC,GAAO,OACzDA,aAAmBC,MAAQD,EAAUpB,EAAMoB,EAAQ,IAGrDH,EAAAiB,SAAQlB,IAAGmB,MAAAlB,EAAA,CAACjB,EAAK,IAAKb,QAAQA,SAACyB,GAAOwB,cAAa,MAAMC,OAAOjD,EAAY,MAAIkD,OAAKpB,GANrF,CAOF,EAACR,EAMa6B,MAAP,WACL7B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,QAAAA,SAASY,OAAKuC,UAAAP,MAAAC,KAAAC,YAC3B,EAACvB,EAMa8B,KAAP,WACL9B,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,QAAQA,SAACe,MAAIoC,OAAAP,GAAAA,MAAAC,KAAAC,YAC1B,EAACvB,EAMa+B,KAAP,WACL/B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,QAAQA,SAACiB,MAAIkC,OAAA,GAAAP,MAAAC,KAAAC,YAC1B,EAACvB,EAMagC,MAAP,WACLhC,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,QAAAA,SAASmB,OAAKgC,OAAAP,GAAAA,MAAAC,KAAAC,YAC3B,EAACvB,CAAA,CAnFgB,yBAANA,EAAMF,EAAA,CAAAmC,UAAA,EAAAlD,MACSN,QAAAA,SAASiB"}
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import n from"chalk";var e,t,o=0;function r(n){return"__private_"+o+++"_"+n}function c(n,e){if(!Object.prototype.hasOwnProperty.call(n,e))throw new TypeError("attempted to use private field on non-instance");return n}!function(n){n[n.ERROR=0]="ERROR",n[n.WARN=1]="WARN",n[n.INFO=2]="INFO",n[n.SILLY=3]="SILLY"}(t||(t={}));var l=Object.keys(t).reduce(function(n,e){return Math.max(n,e.length)},0)+3,i=((e={})[t.ERROR]=n.red,e[t.WARN]=n.yellow,e[t.INFO]=n.cyan,e[t.SILLY]=n.magenta,e),a=/*#__PURE__*/r("level"),u=/*#__PURE__*/function(){function n(){}return n.isLevel=function(e){return c(n,a)[a]>=e},n.isNotLevel=function(e){return!n.isLevel(e)},n.setLevel=function(e){c(n,a)[a]=e},n.log=function(e){var o;if(!n.isNotLevel(e)){var r=i[e],c=function(n){return n.map(function(n){return n instanceof Error||"object"!=typeof n?n:(e=n,t=new Set,JSON.stringify(e,function(n,e){if("object"==typeof e&&null!==e){if(t.has(e))return;t.add(e)}return e},4));var e,t})}([].slice.call(arguments,1)).map(function(n){return n instanceof Error?n:r(n)});(o=console).log.apply(o,[r("["+t[e].toLowerCase()+"]:").padEnd(l," ")].concat(c))}},n.error=function(){n.log.apply(n,[t.ERROR].concat([].slice.call(arguments)))},n.warn=function(){n.log.apply(n,[t.WARN].concat([].slice.call(arguments)))},n.info=function(){n.log.apply(n,[t.INFO].concat([].slice.call(arguments)))},n.silly=function(){n.log.apply(n,[t.SILLY].concat([].slice.call(arguments)))},n}();Object.defineProperty(u,a,{writable:!0,value:t.INFO});export{i as LEVEL_CHALK,t as LogLevel,u as Logger,l as MAX_LENGTH};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"2BAGYA,+LAAZ,SAAYA,GACVA,EAAAA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,OACD,CALD,CAAYA,IAAAA,EAKX,CAAA,IAEY,IAAAC,EACXC,OAAOC,KAAKH,GAAUI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,EAASY,OAAQC,EAAMC,IAAGH,EAC1BX,EAASe,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,MAAVzB,EAAM,CAAKvB,EAASe,MAAIoC,OAAAP,GAAAA,MAAAC,KAAAC,YAC1B,EAACvB,EAMa+B,KAAP,WACL/B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,EAASiB,MAAIkC,OAAA,GAAAP,MAAAC,KAAAC,YAC1B,EAACvB,EAMagC,MAAP,WACLhC,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,EAASmB,OAAKgC,OAAAP,GAAAA,MAAAC,KAAAC,YAC3B,EAACvB,CAAA,CAnFgB,yBAANA,EAAMF,EAAA,CAAAmC,UAAA,EAAAlD,MACSN,EAASiB"}
@@ -1,2 +0,0 @@
1
- import t from"chalk";var e,r=0;function n(t){return"__private_"+r+++"_"+t}function o(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}!function(t){t[t.ERROR=0]="ERROR",t[t.WARN=1]="WARN",t[t.INFO=2]="INFO",t[t.SILLY=3]="SILLY"}(e||(e={}));const a=Object.keys(e).reduce((t,e)=>Math.max(t,e.length),0)+3,i={[e.ERROR]:t.red,[e.WARN]:t.yellow,[e.INFO]:t.cyan,[e.SILLY]:t.magenta};var c=/*#__PURE__*/n("level");class s{static isLevel(t){return o(s,c)[c]>=t}static isNotLevel(t){return!s.isLevel(t)}static setLevel(t){o(s,c)[c]=t}static log(t,...r){if(s.isNotLevel(t))return;const n=i[t],o=function(t){return t.map(t=>t instanceof Error||"object"!=typeof t?t:function(t){const e=new Set;return JSON.stringify(t,(t,r)=>{if("object"==typeof r&&null!==r){if(e.has(r))return;e.add(r)}return r},4)}(t))}(r).map(t=>t instanceof Error?t:n(t));console.log(n(`[${e[t].toLowerCase()}]:`).padEnd(a," "),...o)}static error(...t){s.log(e.ERROR,...t)}static warn(...t){s.log(e.WARN,...t)}static info(...t){s.log(e.INFO,...t)}static silly(...t){s.log(e.SILLY,...t)}}Object.defineProperty(s,c,{writable:!0,value:e.INFO});export{i as LEVEL_CHALK,e as LogLevel,s as Logger,a as MAX_LENGTH};
2
- //# sourceMappingURL=index.modern.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.mjs","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","rawMessages","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","console","toLowerCase","padEnd","error","warn","info","silly","writable"],"mappings":"yBAGYA,+LAAZ,SAAYA,GACVA,EAAAA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACA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,WAAOiB,IAAQjB,GACpBR,EAAOM,IAAI5B,EAASc,QAASgB,EAC/B,CAMO,WAAOkB,IAAQlB,GACpBR,EAAOM,IAAI5B,EAASgB,QAASc,EAC/B,CAMO,YAAOmB,IAASnB,GACrBR,EAAOM,IAAI5B,EAASkB,SAAUY,EAChC,wBAnFWR,EAAMF,EAAA8B,CAAAA,YAAA5C,MACSN,EAASgB"}
package/dist/index.umd.js DELETED
@@ -1,2 +0,0 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("chalk")):"function"==typeof define&&define.amd?define(["exports","chalk"],n):n((e||self).logger={},e.chalk)}(this,function(e,n){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,l,r=/*#__PURE__*/o(n),c=0;function i(e){return"__private_"+c+++"_"+e}function a(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw new TypeError("attempted to use private field on non-instance");return e}e.LogLevel=void 0,(l=e.LogLevel||(e.LogLevel={}))[l.ERROR=0]="ERROR",l[l.WARN=1]="WARN",l[l.INFO=2]="INFO",l[l.SILLY=3]="SILLY";var f=Object.keys(e.LogLevel).reduce(function(e,n){return Math.max(e,n.length)},0)+3,u=((t={})[e.LogLevel.ERROR]=r.default.red,t[e.LogLevel.WARN]=r.default.yellow,t[e.LogLevel.INFO]=r.default.cyan,t[e.LogLevel.SILLY]=r.default.magenta,t),L=/*#__PURE__*/i("level"),p=/*#__PURE__*/function(){function n(){}return n.isLevel=function(e){return a(n,L)[L]>=e},n.isNotLevel=function(e){return!n.isLevel(e)},n.setLevel=function(e){a(n,L)[L]=e},n.log=function(o){var t;if(!n.isNotLevel(o)){var l=u[o],r=function(e){return e.map(function(e){return e instanceof Error||"object"!=typeof e?e:(n=e,o=new Set,JSON.stringify(n,function(e,n){if("object"==typeof n&&null!==n){if(o.has(n))return;o.add(n)}return n},4));var n,o})}([].slice.call(arguments,1)).map(function(e){return e instanceof Error?e:l(e)});(t=console).log.apply(t,[l("["+e.LogLevel[o].toLowerCase()+"]:").padEnd(f," ")].concat(r))}},n.error=function(){n.log.apply(n,[e.LogLevel.ERROR].concat([].slice.call(arguments)))},n.warn=function(){n.log.apply(n,[e.LogLevel.WARN].concat([].slice.call(arguments)))},n.info=function(){n.log.apply(n,[e.LogLevel.INFO].concat([].slice.call(arguments)))},n.silly=function(){n.log.apply(n,[e.LogLevel.SILLY].concat([].slice.call(arguments)))},n}();Object.defineProperty(p,L,{writable:!0,value:e.LogLevel.INFO}),e.LEVEL_CHALK=u,e.Logger=p,e.MAX_LENGTH=f});
2
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"iVAGYA,kNAAAA,EAAZA,cAAA,GAAYA,EAAAA,EAAAA,WAAAA,EAAAA,SAKX,CAAA,IAJCA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,QAGW,IAAAC,EACXC,OAAOC,KAAKH,EAAQA,UAAEI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,EAAAA,SAASY,OAAQC,EAAK,QAACC,IAAGH,EAC1BX,EAAQA,SAACe,MAAOF,EAAK,QAACG,OAAML,EAC5BX,EAAQA,SAACiB,MAAOJ,EAAAA,QAAMK,KAAIP,EAC1BX,EAAAA,SAASmB,OAAQN,EAAK,QAACO,QAAOT,GAC/BU,eAAAC,EAAA,SAKWC,eAAM,WAAA,SAAAA,IAAAA,CAmFhB,OAnFgBA,EAeHC,QAAP,SAAeC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,EAACF,EAOaI,WAAP,SAAkBF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,EAACF,EAMaK,SAAP,SAAgBH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,EAACF,EAOaM,IAAP,SAAWJ,GAAsC,IAAAK,EACtD,IAAIP,EAAOI,WAAWF,GAAtB,CAEA,IAAMZ,EAAQH,EAAYe,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,I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