| import { InspectOptions } from "node:util"; | ||
| //#region src/types.d.ts | ||
| interface InspectOptions$1 extends InspectOptions { | ||
| hideDate?: boolean; | ||
| } | ||
| interface Formatters { | ||
| [formatter: string]: (this: Debugger, v: any) => string; | ||
| } | ||
| interface Debugger extends Required<DebugOptions> { | ||
| (formatter: any, ...args: any[]): void; | ||
| namespace: string; | ||
| enabled: boolean; | ||
| extend: (namespace: string, delimiter?: string) => Debugger; | ||
| } | ||
| interface DebugOptions { | ||
| useColors?: boolean; | ||
| color?: string | number; | ||
| formatArgs?: (this: Debugger, diff: number, args: [string, ...any[]]) => void; | ||
| formatters?: Formatters; | ||
| /** Node.js only */ | ||
| inspectOpts?: InspectOptions$1; | ||
| log?: (this: Debugger, ...args: any[]) => void; | ||
| } | ||
| //#endregion | ||
| //#region src/core.d.ts | ||
| declare function namespaces(): string; | ||
| declare function disable(): string; | ||
| declare function enabled(name: string): boolean; | ||
| //#endregion | ||
| export { Debugger as a, DebugOptions as i, enabled as n, Formatters as o, namespaces as r, InspectOptions$1 as s, disable as t }; |
+4
-15
@@ -1,18 +0,7 @@ | ||
| import { i as InspectOptions, n as Debugger, r as Formatters, t as Debug } from "./types.js"; | ||
| import { a as Debugger, i as DebugOptions, n as enabled, o as Formatters, r as namespaces, s as InspectOptions, t as disable } from "./core.js"; | ||
| //#region src/browser.d.ts | ||
| /** | ||
| * Colorize log arguments if enabled. | ||
| */ | ||
| declare function formatArgs(this: Debugger, args: [string, ...any[]]): void; | ||
| /** | ||
| * Invokes `console.debug()` when available. | ||
| * No-op when `console.debug` is not a "function". | ||
| * If `console.debug` is not available, falls back | ||
| * to `console.log`. | ||
| */ | ||
| declare const log: Debugger["log"]; | ||
| declare const createDebug: Debug; | ||
| declare function createDebug(namespace: string, options?: DebugOptions): Debugger; | ||
| declare function enable(namespaces: string): void; | ||
| //#endregion | ||
| export { Debug, Debugger, Formatters, InspectOptions, createDebug, createDebug as default, createDebug as "module.exports", formatArgs, log }; | ||
| export { DebugOptions, Debugger, Formatters, InspectOptions, createDebug, disable, enable, enabled, namespaces }; |
+36
-27
@@ -1,2 +0,2 @@ | ||
| import { n as humanize, t as setup } from "./core.js"; | ||
| import { a as namespaces, i as enabled, n as disable, o as humanize, r as enable$1, s as selectColor, t as createDebug$1 } from "./core.js"; | ||
| const colors = [ | ||
@@ -80,9 +80,6 @@ "#0000CC", | ||
| ]; | ||
| function useColors() { | ||
| return true; | ||
| } | ||
| function formatArgs(args) { | ||
| const { useColors: useColors$1 } = this; | ||
| args[0] = `${(useColors$1 ? "%c" : "") + this.namespace + (useColors$1 ? " %c" : " ") + args[0] + (useColors$1 ? "%c " : " ")}+${humanize(this.diff)}`; | ||
| if (!useColors$1) return; | ||
| function formatArgs(diff, args) { | ||
| const { useColors } = this; | ||
| args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${humanize(diff)}`; | ||
| if (!useColors) return; | ||
| const c = `color: ${this.color}`; | ||
@@ -100,2 +97,21 @@ args.splice(1, 0, c, "color: inherit"); | ||
| const log = console.debug || console.log || (() => {}); | ||
| const storage = localstorage(); | ||
| const defaultOptions = { | ||
| useColors: true, | ||
| formatArgs, | ||
| formatters: { j(v) { | ||
| try { | ||
| return JSON.stringify(v); | ||
| } catch (error) { | ||
| return `[UnexpectedJSONParseError]: ${error.message}`; | ||
| } | ||
| } }, | ||
| inspectOpts: {}, | ||
| log | ||
| }; | ||
| function createDebug(namespace, options) { | ||
| var _ref; | ||
| const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace); | ||
| return createDebug$1(namespace, Object.assign(defaultOptions, { color }, options)); | ||
| } | ||
| function localstorage() { | ||
@@ -106,9 +122,2 @@ try { | ||
| } | ||
| const storage = localstorage(); | ||
| function save(namespaces) { | ||
| try { | ||
| if (namespaces) storage.setItem("debug", namespaces); | ||
| else storage.removeItem("debug"); | ||
| } catch (_unused2) {} | ||
| } | ||
| function load() { | ||
@@ -118,17 +127,17 @@ let r; | ||
| r = storage.getItem("debug") || storage.getItem("DEBUG"); | ||
| } catch (_unused3) {} | ||
| } catch (_unused2) {} | ||
| if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG; | ||
| return r || ""; | ||
| } | ||
| const createDebug = setup(useColors(), colors, log, load, save, formatArgs); | ||
| createDebug.formatters.j = function(v) { | ||
| function save(namespaces$1) { | ||
| try { | ||
| return JSON.stringify(v); | ||
| } catch (error) { | ||
| return `[UnexpectedJSONParseError]: ${error.message}`; | ||
| } | ||
| }; | ||
| var browser_default = createDebug; | ||
| createDebug.default = createDebug; | ||
| createDebug.debug = createDebug; | ||
| export { createDebug, createDebug as "module.exports", browser_default as default, formatArgs, log }; | ||
| if (namespaces$1) storage.setItem("debug", namespaces$1); | ||
| else storage.removeItem("debug"); | ||
| } catch (_unused3) {} | ||
| } | ||
| function enable(namespaces$1) { | ||
| save(namespaces$1); | ||
| enable$1(namespaces$1); | ||
| } | ||
| enable$1(load()); | ||
| export { createDebug, disable, enable, enabled, namespaces }; |
@@ -1,1 +0,1 @@ | ||
| function e(e){return e instanceof Error?e.stack||e.message:e}function t(e,t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e[Math.abs(n)%e.length]}function n(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function r(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}function i(r,i,a,o,s,c,l){let u=n=>{let o,s,c,d,f=(...t)=>{if(!f.enabled)return;let n=Date.now();f.diff=n-(o||n),f.prev=o,f.curr=n,o=n,t[0]=e(t[0]),typeof t[0]!=`string`&&t.unshift(`%O`);let r=0;t[0]=t[0].replace(/%([a-z%])/gi,(e,n)=>{if(e===`%%`)return`%`;r++;let i=u.formatters[n];if(typeof i==`function`){let n=t[r];e=i.call(f,n),t.splice(r,1),r--}return e}),u.formatArgs.call(f,t),(f.log||u.log).apply(f,t)};function p(e,t=`:`){let n=u(this.namespace+t+e);return n.log=this.log,n}return f.namespace=n,f.useColors=r,f.color=t(i,n),f.extend=p,f.log=a,Object.defineProperty(f,`enabled`,{enumerable:!0,configurable:!1,get:()=>s==null?(c!==u.namespaces&&(c=u.namespaces,d=u.enabled(n)),d):s,set:e=>{s=e}}),l&&l(f),f};function d(e){s(e),u.namespaces=e,u.names=[],u.skips=[];let t=e.trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?u.skips.push(e.slice(1)):u.names.push(e)}function f(){let e=[...u.names,...u.skips.map(e=>`-${e}`)].join(`,`);return u.enable(``),e}function p(e){for(let t of u.skips)if(n(e,t))return!1;for(let t of u.names)if(n(e,t))return!0;return!1}return u.namespaces=``,u.formatters={},u.enable=d,u.disable=f,u.enabled=p,u.names=[],u.skips=[],u.selectColor=e=>t(i,e),u.formatArgs=c,u.log=a,u.enable(o()),u}const a=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function o(){return!0}function s(e){let{useColors:t}=this;if(e[0]=`${(t?`%c`:``)+this.namespace+(t?` %c`:` `)+e[0]+(t?`%c `:` `)}+${r(this.diff)}`,!t)return;let n=`color: ${this.color}`;e.splice(1,0,n,`color: inherit`);let i=0,a=0;e[0].replace(/%[a-z%]/gi,e=>{e!==`%%`&&(i++,e===`%c`&&(a=i))}),e.splice(a,0,n)}const c=console.debug||console.log||(()=>{});function l(){try{return localStorage}catch(e){}}const u=l();function d(e){try{e?u.setItem(`debug`,e):u.removeItem(`debug`)}catch(e){}}function f(){let e;try{e=u.getItem(`debug`)||u.getItem(`DEBUG`)}catch(e){}return!e&&typeof process<`u`&&`env`in process&&(e=process.env.DEBUG),e||``}const p=i(o(),a,c,f,d,s);p.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: ${e.message}`}};var m=p;p.default=p,p.debug=p;export{p as createDebug,p as "module.exports",m as default,s as formatArgs,c as log}; | ||
| function e(e){return e instanceof Error?e.stack||e.message:e}function t(e,t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e[Math.abs(n)%e.length]}function n(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function r(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}let i=``;function a(){return i}function o(t,n){let r,a,s,c,l=(...t)=>{if(!l.enabled)return;let i=Date.now(),a=i-(r||i);r=i,t[0]=e(t[0]),typeof t[0]!=`string`&&t.unshift(`%O`);let o=0;t[0]=t[0].replace(/%([a-z%])/gi,(e,r)=>{if(e===`%%`)return`%`;o++;let i=n.formatters[r];if(typeof i==`function`){let n=t[o];e=i.call(l,n),t.splice(o,1),o--}return e}),n.formatArgs.call(l,a,t),l.log(...t)};return l.extend=function(e,t=`:`){return o(this.namespace+t+e,{useColors:this.useColors,color:this.color,formatArgs:this.formatArgs,formatters:this.formatters,inspectOpts:this.inspectOpts,log:this.log})},Object.assign(l,n),l.namespace=t,Object.defineProperty(l,`enabled`,{enumerable:!0,configurable:!1,get:()=>a==null?(s!==i&&(s=i,c=d(t)),c):a,set:e=>{a=e}}),l}let s=[],c=[];function l(e){i=e,s=[],c=[];let t=i.trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?c.push(e.slice(1)):s.push(e)}function u(){let e=[...s,...c.map(e=>`-${e}`)].join(`,`);return l(``),e}function d(e){for(let t of c)if(n(e,t))return!1;for(let t of s)if(n(e,t))return!0;return!1}const f=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function p(e,t){let{useColors:n}=this;if(t[0]=`${(n?`%c`:``)+this.namespace+(n?` %c`:` `)+t[0]+(n?`%c `:` `)}+${r(e)}`,!n)return;let i=`color: ${this.color}`;t.splice(1,0,i,`color: inherit`);let a=0,o=0;t[0].replace(/%[a-z%]/gi,e=>{e!==`%%`&&(a++,e===`%c`&&(o=a))}),t.splice(o,0,i)}const m=console.debug||console.log||(()=>{}),h=v(),g={useColors:!0,formatArgs:p,formatters:{j(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: ${e.message}`}}},inspectOpts:{},log:m};function _(e,n){var r;let i=(r=n&&n.color)==null?t(f,e):r;return o(e,Object.assign(g,{color:i},n))}function v(){try{return localStorage}catch(e){}}function y(){let e;try{e=h.getItem(`debug`)||h.getItem(`DEBUG`)}catch(e){}return!e&&typeof process<`u`&&`env`in process&&(e=process.env.DEBUG),e||``}function b(e){try{e?h.setItem(`debug`,e):h.removeItem(`debug`)}catch(e){}}function x(e){b(e),l(e)}l(y());export{_ as createDebug,u as disable,x as enable,d as enabled,a as namespaces}; |
+78
-88
@@ -38,93 +38,83 @@ function coerce(value) { | ||
| } | ||
| function setup(useColors, colors, log, load, save, formatArgs, init) { | ||
| const createDebug = (namespace) => { | ||
| let prevTime; | ||
| let enableOverride; | ||
| let namespacesCache; | ||
| let enabledCache; | ||
| const debug = (...args) => { | ||
| if (!debug.enabled) return; | ||
| const curr = Date.now(); | ||
| debug.diff = curr - (prevTime || curr); | ||
| debug.prev = prevTime; | ||
| debug.curr = curr; | ||
| prevTime = curr; | ||
| args[0] = coerce(args[0]); | ||
| if (typeof args[0] !== "string") args.unshift("%O"); | ||
| let index = 0; | ||
| args[0] = args[0].replace(/%([a-z%])/gi, (match, format) => { | ||
| if (match === "%%") return "%"; | ||
| index++; | ||
| const formatter = createDebug.formatters[format]; | ||
| if (typeof formatter === "function") { | ||
| const value = args[index]; | ||
| match = formatter.call(debug, value); | ||
| args.splice(index, 1); | ||
| index--; | ||
| } | ||
| return match; | ||
| }); | ||
| createDebug.formatArgs.call(debug, args); | ||
| (debug.log || createDebug.log).apply(debug, args); | ||
| }; | ||
| function extend(namespace$1, delimiter = ":") { | ||
| const newDebug = createDebug(this.namespace + delimiter + namespace$1); | ||
| newDebug.log = this.log; | ||
| return newDebug; | ||
| } | ||
| debug.namespace = namespace; | ||
| debug.useColors = useColors; | ||
| debug.color = selectColor(colors, namespace); | ||
| debug.extend = extend; | ||
| debug.log = log; | ||
| Object.defineProperty(debug, "enabled", { | ||
| enumerable: true, | ||
| configurable: false, | ||
| get: () => { | ||
| if (enableOverride != null) return enableOverride; | ||
| if (namespacesCache !== createDebug.namespaces) { | ||
| namespacesCache = createDebug.namespaces; | ||
| enabledCache = createDebug.enabled(namespace); | ||
| } | ||
| return enabledCache; | ||
| }, | ||
| set: (v) => { | ||
| enableOverride = v; | ||
| let globalNamespaces = ""; | ||
| function namespaces() { | ||
| return globalNamespaces; | ||
| } | ||
| function createDebug(namespace, options) { | ||
| let prevTime; | ||
| let enableOverride; | ||
| let namespacesCache; | ||
| let enabledCache; | ||
| const debug = (...args) => { | ||
| if (!debug.enabled) return; | ||
| const curr = Date.now(); | ||
| const diff = curr - (prevTime || curr); | ||
| prevTime = curr; | ||
| args[0] = coerce(args[0]); | ||
| if (typeof args[0] !== "string") args.unshift("%O"); | ||
| let index = 0; | ||
| args[0] = args[0].replace(/%([a-z%])/gi, (match, format) => { | ||
| if (match === "%%") return "%"; | ||
| index++; | ||
| const formatter = options.formatters[format]; | ||
| if (typeof formatter === "function") { | ||
| const value = args[index]; | ||
| match = formatter.call(debug, value); | ||
| args.splice(index, 1); | ||
| index--; | ||
| } | ||
| return match; | ||
| }); | ||
| init && init(debug); | ||
| return debug; | ||
| options.formatArgs.call(debug, diff, args); | ||
| debug.log(...args); | ||
| }; | ||
| function enable(namespaces) { | ||
| save(namespaces); | ||
| createDebug.namespaces = namespaces; | ||
| createDebug.names = []; | ||
| createDebug.skips = []; | ||
| const split = namespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean); | ||
| for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1)); | ||
| else createDebug.names.push(ns); | ||
| } | ||
| function disable() { | ||
| const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => `-${namespace}`)].join(","); | ||
| createDebug.enable(""); | ||
| return namespaces; | ||
| } | ||
| function enabled(name) { | ||
| for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false; | ||
| for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true; | ||
| return false; | ||
| } | ||
| createDebug.namespaces = ""; | ||
| createDebug.formatters = {}; | ||
| createDebug.enable = enable; | ||
| createDebug.disable = disable; | ||
| createDebug.enabled = enabled; | ||
| createDebug.names = []; | ||
| createDebug.skips = []; | ||
| createDebug.selectColor = (ns) => selectColor(colors, ns); | ||
| createDebug.formatArgs = formatArgs; | ||
| createDebug.log = log; | ||
| createDebug.enable(load()); | ||
| return createDebug; | ||
| debug.extend = function(namespace$1, delimiter = ":") { | ||
| return createDebug(this.namespace + delimiter + namespace$1, { | ||
| useColors: this.useColors, | ||
| color: this.color, | ||
| formatArgs: this.formatArgs, | ||
| formatters: this.formatters, | ||
| inspectOpts: this.inspectOpts, | ||
| log: this.log | ||
| }); | ||
| }; | ||
| Object.assign(debug, options); | ||
| debug.namespace = namespace; | ||
| Object.defineProperty(debug, "enabled", { | ||
| enumerable: true, | ||
| configurable: false, | ||
| get: () => { | ||
| if (enableOverride != null) return enableOverride; | ||
| if (namespacesCache !== globalNamespaces) { | ||
| namespacesCache = globalNamespaces; | ||
| enabledCache = enabled(namespace); | ||
| } | ||
| return enabledCache; | ||
| }, | ||
| set: (v) => { | ||
| enableOverride = v; | ||
| } | ||
| }); | ||
| return debug; | ||
| } | ||
| export { humanize as n, setup as t }; | ||
| let names = []; | ||
| let skips = []; | ||
| function enable(namespaces$1) { | ||
| globalNamespaces = namespaces$1; | ||
| names = []; | ||
| skips = []; | ||
| const split = globalNamespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean); | ||
| for (const ns of split) if (ns[0] === "-") skips.push(ns.slice(1)); | ||
| else names.push(ns); | ||
| } | ||
| function disable() { | ||
| const namespaces$1 = [...names, ...skips.map((namespace) => `-${namespace}`)].join(","); | ||
| enable(""); | ||
| return namespaces$1; | ||
| } | ||
| function enabled(name) { | ||
| for (const skip of skips) if (matchesTemplate(name, skip)) return false; | ||
| for (const ns of names) if (matchesTemplate(name, ns)) return true; | ||
| return false; | ||
| } | ||
| export { namespaces as a, enabled as i, disable as n, humanize as o, enable as r, selectColor as s, createDebug as t }; |
+5
-8
@@ -1,2 +0,2 @@ | ||
| import { i as InspectOptions, n as Debugger, r as Formatters, t as Debug } from "./types.js"; | ||
| import { a as Debugger, i as DebugOptions, n as enabled, o as Formatters, r as namespaces, s as InspectOptions, t as disable } from "./core.js"; | ||
@@ -6,11 +6,8 @@ //#region src/node.d.ts | ||
| /** | ||
| * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr. | ||
| */ | ||
| declare function log(...args: any[]): void; | ||
| /** | ||
| * Adds ANSI color escape codes if enabled. | ||
| */ | ||
| declare function formatArgs(this: Debugger, args: [string, ...any[]]): void; | ||
| declare const createDebug: Debug; | ||
| declare function formatArgs(this: Debugger, diff: number, args: [string, ...any[]]): void; | ||
| declare function createDebug(namespace: string, options?: DebugOptions): Debugger; | ||
| declare function enable(namespaces: string): void; | ||
| //#endregion | ||
| export { Debug, Debugger, Formatters, InspectOptions, createDebug, createDebug as default, createDebug as "module.exports", formatArgs, log }; | ||
| export { DebugOptions, Debugger, Formatters, InspectOptions, createDebug, disable, enable, enabled, formatArgs, namespaces }; |
+40
-35
@@ -1,2 +0,2 @@ | ||
| import { n as humanize, t as setup } from "./core.js"; | ||
| import { a as namespaces, i as enabled, n as disable, o as humanize, r as enable$1, s as selectColor, t as createDebug$1 } from "./core.js"; | ||
| import { createRequire } from "node:module"; | ||
@@ -6,5 +6,2 @@ import { isatty } from "node:tty"; | ||
| const require = createRequire(import.meta.url); | ||
| function log(...args) { | ||
| process.stderr.write(`${formatWithOptions(inspectOpts, ...args)}\n`); | ||
| } | ||
| const colors = process.stderr.getColorDepth && process.stderr.getColorDepth() > 2 ? [ | ||
@@ -95,5 +92,3 @@ 20, | ||
| ]; | ||
| const inspectOpts = Object.keys(process.env).filter((key) => { | ||
| return /^debug_/i.test(key); | ||
| }).reduce((obj, key) => { | ||
| const inspectOpts = Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((obj, key) => { | ||
| const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase()); | ||
@@ -108,9 +103,2 @@ let value = process.env[key]; | ||
| }, {}); | ||
| function load() { | ||
| return process.env.DEBUG || ""; | ||
| } | ||
| function save(namespaces) { | ||
| if (namespaces) process.env.DEBUG = namespaces; | ||
| else delete process.env.DEBUG; | ||
| } | ||
| function useColors() { | ||
@@ -125,3 +113,7 @@ return "colors" in inspectOpts ? Boolean(inspectOpts.colors) : isatty(process.stderr.fd); | ||
| } | ||
| function formatArgs(args) { | ||
| function getDate() { | ||
| if (inspectOpts.hideDate) return ""; | ||
| return `${(/* @__PURE__ */ new Date()).toISOString()} `; | ||
| } | ||
| function formatArgs(diff, args) { | ||
| const { namespace: name, useColors: useColors$1 } = this; | ||
@@ -133,25 +125,38 @@ if (useColors$1) { | ||
| args[0] = prefix + args[0].split("\n").join(`\n${prefix}`); | ||
| args.push(`${colorCode}m+${humanize$1(this.diff)}\u001B[0m`); | ||
| args.push(`${colorCode}m+${humanize$1(diff)}\u001B[0m`); | ||
| } else args[0] = `${getDate()}${name} ${args[0]}`; | ||
| } | ||
| function getDate() { | ||
| if (inspectOpts.hideDate) return ""; | ||
| return `${(/* @__PURE__ */ new Date()).toISOString()} `; | ||
| function log(...args) { | ||
| process.stderr.write(`${formatWithOptions(this.inspectOpts, ...args)}\n`); | ||
| } | ||
| function init(debug) { | ||
| debug.inspectOpts = Object.assign({}, inspectOpts); | ||
| const defaultOptions = { | ||
| useColors: useColors(), | ||
| formatArgs, | ||
| formatters: { | ||
| o(v) { | ||
| this.inspectOpts.colors = this.useColors; | ||
| return inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" "); | ||
| }, | ||
| O(v) { | ||
| this.inspectOpts.colors = this.useColors; | ||
| return inspect(v, this.inspectOpts); | ||
| } | ||
| }, | ||
| inspectOpts, | ||
| log | ||
| }; | ||
| function createDebug(namespace, options) { | ||
| var _ref; | ||
| const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace); | ||
| return createDebug$1(namespace, Object.assign(defaultOptions, { color }, options)); | ||
| } | ||
| const createDebug = setup(useColors(), colors, log, load, save, formatArgs, init); | ||
| createDebug.inspectOpts = inspectOpts; | ||
| createDebug.formatters.o = function(v) { | ||
| this.inspectOpts.colors = this.useColors; | ||
| return inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" "); | ||
| }; | ||
| createDebug.formatters.O = function(v) { | ||
| this.inspectOpts.colors = this.useColors; | ||
| return inspect(v, this.inspectOpts); | ||
| }; | ||
| var node_default = createDebug; | ||
| createDebug.default = createDebug; | ||
| createDebug.debug = createDebug; | ||
| export { createDebug, createDebug as "module.exports", node_default as default, formatArgs, log }; | ||
| function save(namespaces$1) { | ||
| if (namespaces$1) process.env.DEBUG = namespaces$1; | ||
| else delete process.env.DEBUG; | ||
| } | ||
| function enable(namespaces$1) { | ||
| save(namespaces$1); | ||
| enable$1(namespaces$1); | ||
| } | ||
| enable$1(process.env.DEBUG || ""); | ||
| export { createDebug, disable, enable, enabled, formatArgs, namespaces }; |
+1
-1
| { | ||
| "name": "obug", | ||
| "version": "1.0.0", | ||
| "version": "2.0.0-beta.1", | ||
| "description": "A lightweight JavaScript debugging utility, forked from debug, featuring TypeScript and ESM support.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+5
-10
@@ -12,3 +12,3 @@ # obug | ||
| > | ||
| > The upcoming v2 refactors some API imports and usage for better support of ESM and TypeScript, easier customization, and an even smaller package size. | ||
| > obug v2 refactors some API imports and usage for better support of ESM and TypeScript, easier customization, and an even smaller package size. | ||
@@ -18,2 +18,4 @@ ## Key Differences from `debug` | ||
| - ✨ Minimal footprint | ||
| - 7.7 kB package size | ||
| - 1.4 KB minified + gzipped for browsers | ||
| - 📦 Zero dependencies | ||
@@ -34,8 +36,2 @@ - 📝 Full TypeScript support | ||
| Please refer to the original [debug](https://github.com/debug-js/debug#usage) package for usage instructions. | ||
| ## Refactor Plan | ||
| The obug package is currently a direct fork of the debug package with minimal modifications. The following refactor plan outlines the intended changes to be made in future releases. | ||
| ```ts | ||
@@ -47,7 +43,6 @@ import { createDebug, disable, enable, enabled, namespaces } from 'obug' | ||
| // createDebug has no extra properties or methods. | ||
| const debug = createDebug('my-namespace', { | ||
| // All options are optional | ||
| useColors: true, // false, true, 'auto' | ||
| useColors: true, // false, true, undefined for auto-detect | ||
| color: 2, // custom color | ||
@@ -86,3 +81,3 @@ // custom formatArgs | ||
| As obug is a fork of debug, we would like to acknowledge the original authors: | ||
| As obug is a fork of debug with significant modifications, we would like to acknowledge the original authors: | ||
@@ -89,0 +84,0 @@ - TJ Holowaychuk |
| import { InspectOptions } from "node:util"; | ||
| //#region src/types.d.ts | ||
| interface InspectOptions$1 extends InspectOptions { | ||
| hideDate?: boolean; | ||
| } | ||
| interface Debugger { | ||
| (formatter: any, ...args: any[]): void; | ||
| useColors: boolean; | ||
| color: string | number; | ||
| enabled: boolean; | ||
| namespace: string; | ||
| inspectOpts?: InspectOptions$1; | ||
| log: (...args: any[]) => any; | ||
| extend: (namespace: string, delimiter?: string) => Debugger; | ||
| /** | ||
| * @internal | ||
| * @deprecated It will removed in the next major version. This is internal cache. | ||
| */ | ||
| diff?: number; | ||
| /** | ||
| * @internal | ||
| * @deprecated It will removed in the next major version. This is internal cache. | ||
| */ | ||
| prev?: number; | ||
| /** | ||
| * @internal | ||
| * @deprecated It will removed in the next major version. This is internal cache. | ||
| */ | ||
| curr?: number; | ||
| } | ||
| interface Formatters { | ||
| [formatter: string]: (this: Debugger, v: any) => string; | ||
| } | ||
| interface Debug { | ||
| (namespace: string): Debugger; | ||
| namespaces: string; | ||
| /** | ||
| * Disable debug output. | ||
| */ | ||
| disable: () => string; | ||
| /** | ||
| * Enables a debug mode by namespaces. This can include modes | ||
| * separated by a colon and wildcards. | ||
| */ | ||
| enable: (namespaces: string) => void; | ||
| /** | ||
| * Returns true if the given mode name is enabled, false otherwise. | ||
| */ | ||
| enabled: (namespaces: string) => boolean; | ||
| formatters: Formatters; | ||
| inspectOpts?: InspectOptions$1; | ||
| /** | ||
| * @deprecated It will removed in the next major version. | ||
| */ | ||
| formatArgs: (this: Debugger, args: [string, ...any[]]) => void; | ||
| /** | ||
| * @deprecated It will removed in the next major version. | ||
| */ | ||
| selectColor: (namespace: string) => string | number; | ||
| /** | ||
| * @deprecated It will removed in the next major version. | ||
| */ | ||
| log: (...args: any[]) => void; | ||
| /** | ||
| * @internal | ||
| * @deprecated It will removed in the next major version. This is internal cache. | ||
| */ | ||
| names: string[]; | ||
| /** | ||
| * @internal | ||
| * @deprecated It will removed in the next major version. This is internal cache. | ||
| */ | ||
| skips: string[]; | ||
| } | ||
| //#endregion | ||
| export { InspectOptions$1 as i, Debugger as n, Formatters as r, Debug as t }; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
20749
-7.81%458
-10.72%2
100%108
-4.42%