From 2d90e1ed789edb8aa4f90bcb91a69d95a7d08752 Mon Sep 17 00:00:00 2001 From: arpu Date: Fri, 5 Apr 2024 21:13:20 +0200 Subject: [PATCH 1/5] use debug ^4.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 001d5ffb33c..80d9f558e51 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ ], "dependencies": { "buffer": "^6.0.3", - "debug": "ngokevin/debug#noTimestamp", + "debug": "^4.3.4", "deep-assign": "^2.0.0", "load-bmfont": "^1.2.3", "super-animejs": "^3.1.0", From 07e6fd03d010ac9642cae70a70bf74b0c20bcc8c Mon Sep 17 00:00:00 2001 From: arpu Date: Sat, 6 Apr 2024 00:11:57 +0200 Subject: [PATCH 2/5] Update debug.js --- src/utils/debug.js | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/utils/debug.js b/src/utils/debug.js index 2f1fb45aacf..70c21af4c3d 100644 --- a/src/utils/debug.js +++ b/src/utils/debug.js @@ -1,4 +1,4 @@ -var debugLib = require('debug'); +var debug = require('debug'); var settings = { colors: { @@ -10,18 +10,46 @@ var settings = { }; /** - * Monkeypatches `debug` so we can colorize error/warning messages. + * Overwrite `debug` so we can colorize error/warning messages and remove Time Diff * - * (See issue: https://github.com/visionmedia/debug/issues/137) + * (See issue: https://github.com/debug-js/debug/issues/582#issuecomment-1755718739) */ -var debug = function (namespace) { - var d = debugLib(namespace); +debug.formatArgs = formatArgs; - d.color = getDebugNamespaceColor(namespace); +function formatArgs(args) { + args[0] = + (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' '); - return d; -}; -Object.assign(debug, debugLib); + if (!this.useColors) { + return; + } + this.color = getDebugNamespaceColor(this.namespace); + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, (match) => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} /** * Returns the type of the namespace (e.g., `error`, `warn`). From c2e15bfc32c43633c437dc66d85f8e35338967ea Mon Sep 17 00:00:00 2001 From: arpu Date: Mon, 8 Apr 2024 13:53:33 +0200 Subject: [PATCH 3/5] Update debug.js --- src/utils/debug.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/debug.js b/src/utils/debug.js index 70c21af4c3d..c0bf093b817 100644 --- a/src/utils/debug.js +++ b/src/utils/debug.js @@ -28,14 +28,14 @@ function formatArgs(args) { return; } this.color = getDebugNamespaceColor(this.namespace); - const c = 'color: ' + this.color; + var c = 'color: ' + this.color; args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; + var index = 0; + var lastC = 0; args[0].replace(/%[a-zA-Z%]/g, (match) => { if (match === '%%') { return; From 146c6a49ace9bfd81e3c910c367530cba0d9905a Mon Sep 17 00:00:00 2001 From: arpu Date: Mon, 8 Apr 2024 14:05:58 +0200 Subject: [PATCH 4/5] Update debug.js --- src/utils/debug.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/debug.js b/src/utils/debug.js index c0bf093b817..85143aeec05 100644 --- a/src/utils/debug.js +++ b/src/utils/debug.js @@ -36,7 +36,7 @@ function formatArgs(args) { // figure out the correct index to insert the CSS into var index = 0; var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, (match) => { + args[0].replace(/%[a-zA-Z%]/g, function (match) { if (match === '%%') { return; } From 514986bd0ea13856bbe456862f1eaf0a51f989b6 Mon Sep 17 00:00:00 2001 From: arpu Date: Mon, 8 Apr 2024 14:10:34 +0200 Subject: [PATCH 5/5] Update debug.js --- src/utils/debug.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/debug.js b/src/utils/debug.js index 85143aeec05..acec07dad28 100644 --- a/src/utils/debug.js +++ b/src/utils/debug.js @@ -16,7 +16,7 @@ var settings = { */ debug.formatArgs = formatArgs; -function formatArgs(args) { +function formatArgs (args) { args[0] = (this.useColors ? '%c' : '') + this.namespace +