@microphi/debug 1.1.5 → 1.1.6

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
@@ -1,17 +1,28 @@
1
- # @microphi/store
1
+ # @microphi/debug
2
2
 
3
- > A typescript library to handle states in a human way
3
+ > Super simple wrapper around console.log
4
4
 
5
- Please refer to the following post for some more info. Documentation will come at a later stage
5
+ # Install
6
+ ```
7
+ @microphi/debug
8
+ ```
6
9
 
7
- https://dev.to/davidecavaliere/a-state-manager-for-angular-that-makes-sense-finally-at-least-for-me-2kij-temp-slug-6701935?preview=27e5680771de4a8c93dd2c825b0691b68605d25f1e4ff583e6c4116ba4d30b3b863c98dcfe41b7d059672a5bc3b6e892ceba1b8272e8123594ac0843
10
+ # Log
8
11
 
9
- Be aware this is just a PoC at this moment *do not use it on your production apps*
12
+ ```javascript
13
+ import { getDebugger } from "@microphi/debug";
10
14
 
11
- ## Build and deploy @microphi/store
15
+ export const d = getDebugger('namespace1');
12
16
 
17
+ // any where in the code
18
+ d('test');
19
+ setTimeout(() => {
20
+ d('hello there');
21
+ }, 500);
13
22
  ```
14
- yarn version
15
- yarn build store --prod
16
- yarn deploy store
17
- ```
23
+ You need to set the `DEBUG` environment variable if running on nodejs or `localStorage.debug` if running in the browser.
24
+ In any case its value is a comma separated list of regex: if a match happens with the namespace then the text will be logged using `console.log`.
25
+
26
+ On each line a timestap is printed and if two or more line from the same namespace are printed out in less the one second then they will show `+ xxx ms` to indicate their offset.
27
+
28
+ ![nodejs example output](../../.github/assets/debug_nodejs_output.png)
package/lib/index.js CHANGED
@@ -1,5 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
1
17
  /*
2
18
  * Public API Surface of store
3
19
  */
4
- export * from './lib/debug';
20
+ __exportStar(require("./lib/debug"), exports);
5
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,aAAa,CAAC","sourcesContent":["/*\n * Public API Surface of store\n */\nexport * from './lib/debug';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,8CAA4B","sourcesContent":["/*\n * Public API Surface of store\n */\nexport * from './lib/debug';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AA+CA,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE/C,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CA2DlD"}
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AA2CA,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE/C,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CA8DlD"}
package/lib/lib/debug.js CHANGED
@@ -1,7 +1,11 @@
1
- import { getEnvironmentVariables } from "./get-environment-varialbles";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDebugger = void 0;
4
+ const get_environment_varialbles_1 = require("./get-environment-varialbles");
5
+ const is_nodejs_1 = require("./is_nodejs");
2
6
  const colors = new Map();
3
7
  const colorPalette = [];
4
- if (process) {
8
+ if ((0, is_nodejs_1.isNodejs)()) {
5
9
  colorPalette.push("\x1b[30m", "\x1b[31m", "\x1b[32m", "\x1b[33m", "\x1b[34m", "\x1b[35m", "\x1b[36m", "\x1b[37m", "\x1b[90m", "\x1b[91m", "\x1b[92m", "\x1b[93m", "\x1b[94m", "\x1b[95m", "\x1b[96m", "\x1b[97m");
6
10
  }
7
11
  else {
@@ -15,9 +19,9 @@ else {
15
19
  "#40E0D0", "#66CCCC" // Turquoise
16
20
  );
17
21
  }
18
- export function getDebugger(namespace) {
22
+ function getDebugger(namespace) {
19
23
  let lastTimeStamp = 0;
20
- const { DEBUG } = getEnvironmentVariables(process);
24
+ const { DEBUG } = (0, get_environment_varialbles_1.getEnvironmentVariables)();
21
25
  const random = Math.floor(Math.random() * (colorPalette.length - 1));
22
26
  // Generate a random color
23
27
  const randomColor = colors.get(namespace) ||
@@ -45,7 +49,7 @@ export function getDebugger(namespace) {
45
49
  const match = namespace.match(regex);
46
50
  if (match) {
47
51
  // Print formatted time with namespace
48
- if (process) {
52
+ if ((0, is_nodejs_1.isNodejs)()) {
49
53
  console.log(`\x1b[7m${formattedTime}\x1b[0m`, `\x1b[1m${randomColor}${namespace}\x1b[0m`, ...args);
50
54
  }
51
55
  else {
@@ -56,4 +60,5 @@ export function getDebugger(namespace) {
56
60
  }
57
61
  };
58
62
  }
63
+ exports.getDebugger = getDebugger;
59
64
  //# sourceMappingURL=debug.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;A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SAAS,EAAE,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,CAAC;qBAC/F;iBACF;aAEF;SAEF;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { getEnvironmentVariables } from \"./get-environment-varialbles\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const process: any;\n\nconst colors = new Map<string, string>();\n\nconst colorPalette: string[] = [];\n\nif (process) {\n\n colorPalette.push(\n \"\\x1b[30m\",\n \"\\x1b[31m\",\n \"\\x1b[32m\",\n \"\\x1b[33m\",\n \"\\x1b[34m\",\n \"\\x1b[35m\",\n \"\\x1b[36m\",\n \"\\x1b[37m\",\n \"\\x1b[90m\",\n \"\\x1b[91m\",\n \"\\x1b[92m\",\n \"\\x1b[93m\",\n \"\\x1b[94m\",\n \"\\x1b[95m\",\n \"\\x1b[96m\",\n \"\\x1b[97m\",\n );\n\n} else {\n\n colorPalette.push(\n \"#0000FF\", \"#6699FF\", // Blue\n \"#FF0000\", \"#FF6666\", // Red\n \"#00FF00\", \"#66FF66\", // Green\n \"#FFFF00\", \"#FFFF66\", // Yellow\n \"#800080\", \"#CC66CC\", // Purple\n \"#FFA500\", \"#FFCC99\", // Orange\n \"#FFC0CB\", \"#FFCCCC\", // Pink\n \"#40E0D0\", \"#66CCCC\" // Turquoise\n );\n}\n\n\n\n\nexport type Log = (...args: unknown[]) => void;\n\nexport function getDebugger(namespace: string): Log {\n\n\n let lastTimeStamp = 0;\n const {DEBUG} = getEnvironmentVariables(process);\n\n\n const random = Math.floor(Math.random() * (colorPalette.length - 1));\n // Generate a random color\n const randomColor = colors.get(namespace) ||\n colors.set(namespace, colorPalette[random]).get(namespace) as string;\n\n\n // CSS style for the namespace with random color and bold\n const namespaceStyle = `color: ${randomColor}; font-weight: bold;`;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (...args: any[]) => {\n\n let formattedTime = '';\n const now = Date.now();\n\n if ((now - lastTimeStamp) > 1000) {\n\n const currentTime = new Date();\n const hours = currentTime.getHours().toString().padStart(2, '0');\n const minutes = currentTime.getMinutes().toString().padStart(2, '0');\n const seconds = currentTime.getSeconds().toString().padStart(2, '0');\n\n formattedTime = `${hours}:${minutes}:${seconds}`;\n lastTimeStamp = now;\n\n } else {\n formattedTime = `+${now - lastTimeStamp}`.padStart(8, ' ');\n }\n\n\n if (DEBUG) {\n\n const regexs = DEBUG.split(',');\n for (const regex of regexs) {\n\n const match = namespace.match(regex);\n\n if (match) {\n // Print formatted time with namespace\n if (process) {\n console.log(`\\x1b[7m${formattedTime}\\x1b[0m`, `\\x1b[1m${randomColor}${namespace}\\x1b[0m`, ...args);\n\n } else {\n\n console.log(`%c${formattedTime} %c${namespace}`, 'color: lightblue', namespaceStyle, ...args);\n }\n }\n\n }\n\n }\n }\n}\n"]}
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":";;;AAAA,6EAAuE;AACvE,2CAAuC;AAGvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEzC,MAAM,YAAY,GAAa,EAAE,CAAC;AAElC,IAAI,IAAA,oBAAQ,GAAE,EAAE;IAEd,YAAY,CAAC,IAAI,CACf,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,CACX,CAAC;CAEH;KAAM;IAEL,YAAY,CAAC,IAAI,CACf,SAAS,EAAE,SAAS,EAAE,OAAO;IAC7B,SAAS,EAAE,SAAS,EAAE,MAAM;IAC5B,SAAS,EAAE,SAAS,EAAE,QAAQ;IAC9B,SAAS,EAAE,SAAS,EAAE,SAAS;IAC/B,SAAS,EAAE,SAAS,EAAE,SAAS;IAC/B,SAAS,EAAE,SAAS,EAAE,SAAS;IAC/B,SAAS,EAAE,SAAS,EAAE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AAI,OAAO,EAAE,CAAC;YACjD,aAAa,GAAG,GAAG,CAAC;SAErB;aAAM;YACL,aAAa,GAAG,IAAI,GAAG,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC5D;QAGD,IAAI,KAAK,EAAE;YAET,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAE1B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAErC,IAAI,KAAK,EAAE;oBACT,sCAAsC;oBAEtC,IAAI,IAAA,oBAAQ,GAAE,EAAE;wBAEd,OAAO,CAAC,GAAG,CAAC,UAAU,aAAa,SAAS,EAAE,UAAU,WAAW,GAAG,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;qBAEpG;yBAAM;wBAEL,OAAO,CAAC,GAAG,CAAC,KAAK,aAAa,MAAM,SAAS,EAAE,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,CAAC;qBAE/F;iBACF;aAEF;SAEF;IACH,CAAC,CAAA;AACH,CAAC;AA9DD,kCA8DC","sourcesContent":["import { getEnvironmentVariables } from \"./get-environment-varialbles\";\nimport { isNodejs } from \"./is_nodejs\";\n\n\nconst colors = new Map<string, string>();\n\nconst colorPalette: string[] = [];\n\nif (isNodejs()) {\n\n colorPalette.push(\n \"\\x1b[30m\",\n \"\\x1b[31m\",\n \"\\x1b[32m\",\n \"\\x1b[33m\",\n \"\\x1b[34m\",\n \"\\x1b[35m\",\n \"\\x1b[36m\",\n \"\\x1b[37m\",\n \"\\x1b[90m\",\n \"\\x1b[91m\",\n \"\\x1b[92m\",\n \"\\x1b[93m\",\n \"\\x1b[94m\",\n \"\\x1b[95m\",\n \"\\x1b[96m\",\n \"\\x1b[97m\",\n );\n\n} else {\n\n colorPalette.push(\n \"#0000FF\", \"#6699FF\", // Blue\n \"#FF0000\", \"#FF6666\", // Red\n \"#00FF00\", \"#66FF66\", // Green\n \"#FFFF00\", \"#FFFF66\", // Yellow\n \"#800080\", \"#CC66CC\", // Purple\n \"#FFA500\", \"#FFCC99\", // Orange\n \"#FFC0CB\", \"#FFCCCC\", // Pink\n \"#40E0D0\", \"#66CCCC\" // Turquoise\n )\n}\n\nexport type Log = (...args: unknown[]) => void;\n\nexport function getDebugger(namespace: string): Log {\n\n\n let lastTimeStamp = 0;\n const {DEBUG} = getEnvironmentVariables();\n\n\n const random = Math.floor(Math.random() * (colorPalette.length - 1));\n // Generate a random color\n const randomColor = colors.get(namespace) ||\n colors.set(namespace, colorPalette[random]).get(namespace) as string;\n\n\n // CSS style for the namespace with random color and bold\n const namespaceStyle = `color: ${randomColor}; font-weight: bold;`;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (...args: any[]) => {\n\n let formattedTime = '';\n const now = Date.now();\n\n if ((now - lastTimeStamp) > 1000) {\n\n const currentTime = new Date();\n const hours = currentTime.getHours().toString().padStart(2, '0');\n const minutes = currentTime.getMinutes().toString().padStart(2, '0');\n const seconds = currentTime.getSeconds().toString().padStart(2, '0');\n\n formattedTime = `${hours}:${minutes}:${seconds}`;\n lastTimeStamp = now;\n\n } else {\n formattedTime = `+${now - lastTimeStamp}`.padStart(8, ' ');\n }\n\n\n if (DEBUG) {\n\n const regexs = DEBUG.split(',');\n for (const regex of regexs) {\n\n const match = namespace.match(regex);\n\n if (match) {\n // Print formatted time with namespace\n\n if (isNodejs()) {\n\n console.log(`\\x1b[7m${formattedTime}\\x1b[0m`, `\\x1b[1m${randomColor}${namespace}\\x1b[0m`, ...args);\n\n } else {\n\n console.log(`%c${formattedTime} %c${namespace}`, 'color: lightblue', namespaceStyle, ...args);\n\n }\n }\n\n }\n\n }\n }\n}\n"]}
@@ -1,8 +1,4 @@
1
- export declare function getEnvironmentVariables(process: {
2
- env: {
3
- [k: string]: string;
4
- };
5
- }): {
1
+ export declare function getEnvironmentVariables(): {
6
2
  DEBUG: string;
7
3
  };
8
4
  //# sourceMappingURL=get-environment-varialbles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-environment-varialbles.d.ts","sourceRoot":"","sources":["../../src/lib/get-environment-varialbles.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAC,GAAG,EAAE;QAAC,CAAC,CAAC,EAAC,MAAM,GAAG,MAAM,CAAA;KAAC,CAAA;CAAC;;EAc3E"}
1
+ {"version":3,"file":"get-environment-varialbles.d.ts","sourceRoot":"","sources":["../../src/lib/get-environment-varialbles.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB;;EAatC"}
@@ -1,11 +1,16 @@
1
- export function getEnvironmentVariables(process) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnvironmentVariables = void 0;
4
+ const is_nodejs_1 = require("./is_nodejs");
5
+ function getEnvironmentVariables() {
2
6
  let DEBUG;
3
- if (typeof window === 'object') {
4
- DEBUG = localStorage.getItem('debug') || '';
7
+ if ((0, is_nodejs_1.isNodejs)()) {
8
+ DEBUG = process.env['DEBUG'] || '';
5
9
  }
6
10
  else {
7
- DEBUG = process.env['DEBUG'];
11
+ DEBUG = localStorage.getItem('debug') || '';
8
12
  }
9
13
  return { DEBUG };
10
14
  }
15
+ exports.getEnvironmentVariables = getEnvironmentVariables;
11
16
  //# sourceMappingURL=get-environment-varialbles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-environment-varialbles.js","sourceRoot":"","sources":["../../src/lib/get-environment-varialbles.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,uBAAuB,CAAC,OAAoC;IACxE,IAAI,KAAa,CAAC;IAElB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAE5B,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;KAE/C;SAAM;QAEH,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAEhC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC","sourcesContent":["export function getEnvironmentVariables(process: {env: {[k:string]: string}}) {\n let DEBUG: string;\n\n if (typeof window === 'object') {\n\n DEBUG = localStorage.getItem('debug') || '';\n\n } else {\n\n DEBUG = process.env['DEBUG'];\n\n }\n\n return { DEBUG };\n}\n"]}
1
+ {"version":3,"file":"get-environment-varialbles.js","sourceRoot":"","sources":["../../src/lib/get-environment-varialbles.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,SAAgB,uBAAuB;IAErC,IAAI,KAAa,CAAC;IAElB,IAAI,IAAA,oBAAQ,GAAE,EAAE;QAEd,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;KACpC;SAAM;QAEL,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;KAC7C;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AAbD,0DAaC","sourcesContent":["import { isNodejs } from \"./is_nodejs\";\n\nexport function getEnvironmentVariables() {\n\n let DEBUG: string;\n\n if (isNodejs()) {\n\n DEBUG = process.env['DEBUG'] || '';\n } else {\n\n DEBUG = localStorage.getItem('debug') || '';\n }\n\n return { DEBUG };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function isNodejs(): boolean;
2
+ //# sourceMappingURL=is_nodejs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_nodejs.d.ts","sourceRoot":"","sources":["../../src/lib/is_nodejs.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,YAcvB"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNodejs = void 0;
4
+ function isNodejs() {
5
+ let isNode = false;
6
+ try {
7
+ if (typeof process === 'object') {
8
+ isNode = true;
9
+ }
10
+ }
11
+ catch (error) {
12
+ console.log('process is not an object. this is likely the browser');
13
+ }
14
+ return isNode;
15
+ }
16
+ exports.isNodejs = isNodejs;
17
+ //# sourceMappingURL=is_nodejs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_nodejs.js","sourceRoot":"","sources":["../../src/lib/is_nodejs.ts"],"names":[],"mappings":";;;AAEA,SAAgB,QAAQ;IACtB,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,IAAI;QAEF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,MAAM,GAAG,IAAI,CAAC;SACf;KACF;IAAC,OAAO,KAAK,EAAE;QAEd,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;KACrE;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAdD,4BAcC","sourcesContent":["declare const process: object;\n\nexport function isNodejs() {\n let isNode = false;\n\n try {\n\n if (typeof process === 'object') {\n isNode = true;\n }\n } catch (error) {\n\n console.log('process is not an object. this is likely the browser');\n }\n\n return isNode;\n}\n"]}
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "@microphi/debug",
3
+ "description": "A very simple wrapper to console.log",
3
4
  "private": false,
4
5
  "keywords": [
5
6
  "log",
@@ -15,7 +16,7 @@
15
16
  "files": [
16
17
  "lib"
17
18
  ],
18
- "version": "1.1.5",
19
+ "version": "1.1.6",
19
20
  "dependencies": {
20
21
  "tslib": "^2.5.0"
21
22
  },
@@ -26,5 +27,5 @@
26
27
  "prepack": "yarn build",
27
28
  "lint": "eslint ./src"
28
29
  },
29
- "gitHead": "82e5091939c81ad825089316a5ddf66638e8c32f"
30
+ "gitHead": "10a222aaa58a5dd76f40e52ab79a0f7cc9249226"
30
31
  }