@alwatr/logger 5.6.0 โ†’ 5.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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
+ ## [5.6.2](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.6.1...@alwatr/logger@5.6.2) (2025-09-13)
7
+
8
+ ### ๐Ÿ”— Dependencies update
9
+
10
+ * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
11
+
12
+ ## [5.6.1](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.6.0...@alwatr/logger@5.6.1) (2025-09-13)
13
+
14
+ ### ๐Ÿงน Miscellaneous Chores
15
+
16
+ * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
17
+ * remove package-tracer dependency and related code from logger ([7dcc7e2](https://github.com/Alwatr/nanolib/commit/7dcc7e27d6d4aeb1b3efe262b10e12cb80363fd1))
18
+
6
19
  ## [5.6.0](https://github.com/Alwatr/nanolib/compare/@alwatr/logger@5.5.10...@alwatr/logger@5.6.0) (2025-09-13)
7
20
 
8
21
  ### โœจ Features
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AA6D5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,mBAA4B,KAAG,YAwD3E,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AA2D5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,mBAA4B,KAAG,YAwD3E,CAAC"}
package/dist/main.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /* @alwatr/logger v5.6.0 */
1
+ /* @alwatr/logger v5.6.2 */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,9 +26,7 @@ __export(main_exports, {
26
26
  module.exports = __toCommonJS(main_exports);
27
27
 
28
28
  // src/logger.ts
29
- var import_package_tracer = require("@alwatr/package-tracer");
30
29
  var import_platform_info = require("@alwatr/platform-info");
31
- __dev_mode__: import_package_tracer.packageTracer.add("@alwatr/logger", "5.6.0");
32
30
  var defaultDebugMode = /* @__PURE__ */ (() => {
33
31
  return import_platform_info.platformInfo.development || (import_platform_info.platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== "undefined" && localStorage.getItem("ALWATR_DEBUG") === "1");
34
32
  })();
package/dist/main.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/main.ts", "../src/logger.ts"],
4
- "sourcesContent": ["export * from './logger.js';\nexport * from './type.js';\n", "import {packageTracer} from '@alwatr/package-tracer';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nconst defaultDebugMode = /* #__PURE__ */ (() => {\n return (\n platformInfo.development ||\n (platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1')\n );\n})();\n\n/**\n * Color list storage for logger.\n */\nconst colorList = /* #__PURE__ */ (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ])();\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = /* #__PURE__ */ (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\nconst _keySection = /* #__PURE__ */ (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '{' + domain + '}';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}โš ๏ธ\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\n ? console.error.bind(console, `${styleScope}โŒ\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logFileModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}๐Ÿšธ\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%s`!', styleScope, domain, 'color: orange;'),\n\n time: (label: string) => console.time(domain + '.' + label + ' duration time'),\n timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'),\n } as const;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,4BAA4B;AAC5B,2BAA2B;AAI3B,aAAc,qCAAc,IAAI,kBAAkB,OAAmB;AAErE,IAAM,mBAAoC,uBAAM;AAC9C,SACE,kCAAa,gBACZ,kCAAa,QAAQ,QAAQ,QAAQ,IAAI,KAAK,IAAI,OAAO,iBAAiB,eAAe,aAAa,QAAQ,cAA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AAQ,gBAAgB;AAAA,EACrF;AACF;",
4
+ "sourcesContent": ["export * from './logger.js';\nexport * from './type.js';\n", "import {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst defaultDebugMode = /* #__PURE__ */ (() => {\n return (\n platformInfo.development ||\n (platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1')\n );\n})();\n\n/**\n * Color list storage for logger.\n */\nconst colorList = /* #__PURE__ */ (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ])();\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = /* #__PURE__ */ (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\nconst _keySection = /* #__PURE__ */ (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '{' + domain + '}';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}โš ๏ธ\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\n ? console.error.bind(console, `${styleScope}โŒ\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logFileModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}๐Ÿšธ\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%s`!', styleScope, domain, 'color: orange;'),\n\n time: (label: string) => console.time(domain + '.' + label + ' duration time'),\n timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'),\n } as const;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAA2B;AAI3B,IAAM,mBAAoC,uBAAM;AAC9C,SACE,kCAAa,gBACZ,kCAAa,QAAQ,QAAQ,QAAQ,IAAI,KAAK,IAAI,OAAO,iBAAiB,eAAe,aAAa,QAAQ,cAAc,MAAM;AAEvI,GAAG;AAKH,IAAM,YAA6B,uBACjC,kCAAa,QACT,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,IACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AAEP,IAAI,cAAc;AAClB,IAAM,gBAAgB,MAAc;AAClC,QAAM,QAAQ,UAAU,WAAW;AACnC;AACA,MAAI,eAAe,UAAU,QAAQ;AACnC,kBAAc;AAAA,EAChB;AACA,SAAO;AACT;AAEA,IAAM,SAA0B,wBAAO;AAAA,EACrC,OAAO,kCAAa,QAAQ,oBAAoB;AAAA,EAChD,OAAO,kCAAa,QAAQ,YAAY;AAC1C,IAAI;AAEJ,IAAM,cAA+B,uBAAO,kCAAa,QAAQ,WAAW,UAAW;AAEvF,IAAM,kBAAkB,CAAC,WAA2B;AAClD,WAAS,OAAO,KAAK;AACrB,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,MAAI,UAAU,OAAO,UAAU,OAAO,UAAU,KAAK;AACnD,aAAS,MAAM,SAAS;AAAA,EAC1B;AACA,SAAO;AACT;AAeO,IAAM,eAAe,CAAC,QAAgB,YAAY,qBAAmC;AAC1F,QAAM,QAAQ,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,SAAS,aAAa,YAAY,QAAQ,OAAO,KAAK;AAAA,IAEnF,UAAU,kCAAa,QACnB,QAAQ,IAAI,KAAK,SAAS,GAAG,UAAU;AAAA,IAAS,OAAO,KAAK,yBAAyB,OAAO,KAAK,IAAI,MAAM,IAC3G,QAAQ,IAAI,KAAK,SAAS,8BAA8B,YAAY,QAAQ,gBAAgB;AAAA,IAEhG,MAAM,CAAC,UAAkB,QAAQ,KAAK,SAAS,MAAM,QAAQ,gBAAgB;AAAA,IAC7E,SAAS,CAAC,UAAkB,QAAQ,QAAQ,SAAS,MAAM,QAAQ,gBAAgB;AAAA,EACrF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/main.mjs CHANGED
@@ -1,9 +1,7 @@
1
- /* @alwatr/logger v5.6.0 */
1
+ /* @alwatr/logger v5.6.2 */
2
2
 
3
3
  // src/logger.ts
4
- import { packageTracer } from "@alwatr/package-tracer";
5
4
  import { platformInfo } from "@alwatr/platform-info";
6
- __dev_mode__: packageTracer.add("@alwatr/logger", "5.6.0");
7
5
  var defaultDebugMode = /* @__PURE__ */ (() => {
8
6
  return platformInfo.development || (platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== "undefined" && localStorage.getItem("ALWATR_DEBUG") === "1");
9
7
  })();
package/dist/main.mjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/logger.ts"],
4
- "sourcesContent": ["import {packageTracer} from '@alwatr/package-tracer';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nconst defaultDebugMode = /* #__PURE__ */ (() => {\n return (\n platformInfo.development ||\n (platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1')\n );\n})();\n\n/**\n * Color list storage for logger.\n */\nconst colorList = /* #__PURE__ */ (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ])();\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = /* #__PURE__ */ (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\nconst _keySection = /* #__PURE__ */ (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '{' + domain + '}';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}โš ๏ธ\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\n ? console.error.bind(console, `${styleScope}โŒ\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logFileModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}๐Ÿšธ\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%s`!', styleScope, domain, 'color: orange;'),\n\n time: (label: string) => console.time(domain + '.' + label + ' duration time'),\n timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'),\n } as const;\n};\n"],
5
- "mappings": ";;;AAAA,SAAQ,qBAAoB;AAC5B,SAAQ,oBAAmB;AAI3B,aAAc,eAAc,IAAI,kBAAkB,OAAmB;AAErE,IAAM,mBAAoC,uBAAM;AAC9C,SACE,aAAa,gBACZ,aAAa,QAAQ,QAAQ,QAAQ,IAAI,KAAK,IAAI,OAAO,iBAAiB,e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AAS,MAAM,QAAQ,gBAAgB;AAAA,EACrF;AACF;",
4
+ "sourcesContent": ["import {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst defaultDebugMode = /* #__PURE__ */ (() => {\n return (\n platformInfo.development ||\n (platformInfo.isCli ? Boolean(process.env.DEBUG) : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1')\n );\n})();\n\n/**\n * Color list storage for logger.\n */\nconst colorList = /* #__PURE__ */ (() =>\n platformInfo.isCli\n ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted\n : [\n '#35b997',\n '#f05561',\n '#ee224a',\n '#91c13e',\n '#22af4b',\n '#f0e995',\n '#0fe995',\n '#0f89ca',\n '#08b9a5',\n '#fee851',\n '#ee573d',\n '#f9df30',\n '#1da2dc',\n '#f05123',\n '#ee2524',\n ])();\n\nlet _colorIndex = 0;\nconst _getNextColor = (): string => {\n const color = colorList[_colorIndex];\n _colorIndex++;\n if (_colorIndex >= colorList.length) {\n _colorIndex = 0;\n }\n return color;\n};\n\nconst _style = /* #__PURE__ */ (() => ({\n scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\nconst _keySection = /* #__PURE__ */ (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\nconst _sanitizeDomain = (domain: string): string => {\n domain = domain.trim();\n const first = domain.charAt(0);\n if (first !== '[' && first !== '{' && first !== '<') {\n domain = '{' + domain + '}';\n }\n return domain;\n};\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - **color** is optional and automatically select from internal fancy color list.\n * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG`\n *\n * Example:\n *\n * ```ts\n * import {createLogger} from 'https://esm.run/@alwatr/logger';\n * const logger = createLogger('logger/demo');\n * ```\n */\nexport const createLogger = (domain: string, debugMode = defaultDebugMode): AlwatrLogger => {\n const color = _getNextColor();\n const styleScope = _style.scope.replace('{{color}}', color);\n domain = _sanitizeDomain(domain);\n\n /**\n * Required logger object, accident, error always reported even when the devMode is false.\n */\n const requiredItems: AlwatrLogger = {\n debugMode,\n\n banner: platformInfo.isCli\n ? console.log.bind(console, `\\x1b[1;37;45m {{{ %s }}} ${_style.reset}`)\n : console.log.bind(\n console,\n '%c%s',\n 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n ),\n\n accident: platformInfo.isCli\n ? console.warn.bind(console, `${styleScope}โš ๏ธ\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${_style.reset}`, domain)\n : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset),\n\n error: platformInfo.isCli\n ? console.error.bind(console, `${styleScope}โŒ\\n%s\\x1b[31m.%s() Error \\`%s\\`${_style.reset}\\n`, domain)\n : console.error.bind(console, '%c%s%c.%s() Error `%s`\\n', styleScope, domain, _style.reset),\n };\n\n if (!debugMode) {\n return requiredItems;\n }\n // else\n return {\n ...requiredItems,\n\n logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset),\n\n logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset),\n\n logFileModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset),\n\n logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset),\n\n logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),\n\n logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),\n\n logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),\n\n incident: platformInfo.isCli\n ? console.log.bind(console, `${styleScope}๐Ÿšธ\\n%s${_style.reset}.%s() Incident \\`%s\\`!${_style.reset}`, domain)\n : console.log.bind(console, '%c%s%c.%s() Incident `%s`!', styleScope, domain, 'color: orange;'),\n\n time: (label: string) => console.time(domain + '.' + label + ' duration time'),\n timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'),\n } as const;\n};\n"],
5
+ "mappings": ";;;AAAA,SAAQ,oBAAmB;AAI3B,IAAM,mBAAoC,uBAAM;AAC9C,SACE,aAAa,gBACZ,aAAa,QAAQ,QAAQ,QAAQ,IAAI,KAAK,IAAI,OAAO,iBAAiB,eAAe,aAAa,QAAQ,cAAc,MAAM;AAEvI,GAAG;AAKH,IAAM,YAA6B,uBACjC,aAAa,QACT,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,IACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AAEP,IAAI,cAAc;AAClB,IAAM,gBAAgB,MAAc;AAClC,QAAM,QAAQ,UAAU,WAAW;AACnC;AACA,MAAI,eAAe,UAAU,QAAQ;AACnC,kBAAc;AAAA,EAChB;AACA,SAAO;AACT;AAEA,IAAM,SAA0B,wBAAO;AAAA,EACrC,OAAO,aAAa,QAAQ,oBAAoB;AAAA,EAChD,OAAO,aAAa,QAAQ,YAAY;AAC1C,IAAI;AAEJ,IAAM,cAA+B,uBAAO,aAAa,QAAQ,WAAW,UAAW;AAEvF,IAAM,kBAAkB,CAAC,WAA2B;AAClD,WAAS,OAAO,KAAK;AACrB,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,MAAI,UAAU,OAAO,UAAU,OAAO,UAAU,KAAK;AACnD,aAAS,MAAM,SAAS;AAAA,EAC1B;AACA,SAAO;AACT;AAeO,IAAM,eAAe,CAAC,QAAgB,YAAY,qBAAmC;AAC1F,QAAM,QAAQ,cAAc;AAC5B,QAAM,aAAa,OAAO,MAAM,QAAQ,aAAa,KAAK;AAC1D,WAAS,g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,IAAI,KAAK,SAAS,GAAG,UAAU;AAAA,IAAS,OAAO,KAAK,yBAAyB,OAAO,KAAK,IAAI,MAAM,IAC3G,QAAQ,IAAI,KAAK,SAAS,8BAA8B,YAAY,QAAQ,gBAAgB;AAAA,IAEhG,MAAM,CAAC,UAAkB,QAAQ,KAAK,SAAS,MAAM,QAAQ,gBAAgB;AAAA,IAC7E,SAAS,CAAC,UAAkB,QAAQ,QAAQ,SAAS,MAAM,QAAQ,gBAAgB;AAAA,EACrF;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@alwatr/logger",
3
3
  "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
4
- "version": "5.6.0",
4
+ "version": "5.6.2",
5
5
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
6
  "bugs": "https://github.com/Alwatr/nanolib/issues",
7
7
  "dependencies": {
8
- "@alwatr/package-tracer": "5.5.10",
9
- "@alwatr/platform-info": "5.5.10"
8
+ "@alwatr/platform-info": "5.5.12"
10
9
  },
11
10
  "devDependencies": {
12
- "@alwatr/nano-build": "6.1.1",
11
+ "@alwatr/nano-build": "6.1.2",
13
12
  "@alwatr/prettier-config": "5.0.3",
14
13
  "@alwatr/tsconfig-base": "6.0.1",
15
- "@types/node": "^22.18.1",
14
+ "@types/node": "^22.18.3",
16
15
  "typescript": "^5.9.2"
17
16
  },
18
17
  "exports": {
@@ -75,5 +74,5 @@
75
74
  },
76
75
  "type": "module",
77
76
  "types": "./dist/main.d.ts",
78
- "gitHead": "69e0e70d697cc0a9c68f2c6e64c241e89d74699a"
77
+ "gitHead": "4da18811162df49c118acd71086cdbe38b27f250"
79
78
  }