@leftium/gg 0.0.23 → 0.0.24
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 +2 -0
- package/dist/debug-bundled.js +2 -0
- package/dist/eruda/loader.js +1 -0
- package/dist/eruda/plugin.d.ts +18 -3
- package/dist/eruda/plugin.js +12 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,11 +29,13 @@ _Coming soon..._
|
|
|
29
29
|
This library includes a **patched version** of the [`debug`](https://www.npmjs.com/package/debug) package. The patch reformats the output to display time diffs **before** the namespace for better readability:
|
|
30
30
|
|
|
31
31
|
**Standard debug output:**
|
|
32
|
+
|
|
32
33
|
```
|
|
33
34
|
gg:routes/+page.svelte +123ms
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
**Patched output (this library):**
|
|
38
|
+
|
|
37
39
|
```
|
|
38
40
|
+123ms gg:routes/+page.svelte
|
|
39
41
|
```
|
package/dist/debug-bundled.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Auto-generated bundled debug library - type checking disabled
|
|
1
3
|
import e from"tty";import t from"util";function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var s,o,i,c,a,u={exports:{}},l={exports:{}};function f(){if(o)return s;o=1;var e=1e3,t=60*e,r=60*t,n=24*r,i=7*n,c=365.25*n;function a(e,t,r,n){var s=t>=1.5*r;return Math.round(e/r)+" "+n+(s?"s":"")}return s=function(s,o){o=o||{};var u=typeof s;if("string"===u&&s.length>0)return function(s){if((s=String(s)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!o)return;var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*c;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(s);if("number"===u&&isFinite(s))return o.long?function(s){var o=Math.abs(s);if(o>=n)return a(s,o,n,"day");if(o>=r)return a(s,o,r,"hour");if(o>=t)return a(s,o,t,"minute");if(o>=e)return a(s,o,e,"second");return s+" ms"}(s):function(s){var o=Math.abs(s);if(o>=n)return Math.round(s/n)+"d";if(o>=r)return Math.round(s/r)+"h";if(o>=t)return Math.round(s/t)+"m";if(o>=e)return Math.round(s/e)+"s";return s+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function p(){if(c)return i;return c=1,i=function(e){function t(e){let n,s,o,i=null;function c(...e){if(!c.enabled)return;const r=c,s=Number(new Date),o=s-(n||s);r.diff=o,r.prev=n,r.curr=s,n=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,s)=>{if("%%"===n)return"%";i++;const o=t.formatters[s];if("function"==typeof o){const t=e[i];n=o.call(r,t),e.splice(i,1),i--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return c.namespace=e,c.useColors=t.useColors(),c.color=t.selectColor(e),c.extend=r,c.destroy=t.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(s!==t.namespaces&&(s=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(c),c}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,s=-1,o=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(s=n,o=r,n++):(r++,n++);else{if(-1===s)return!1;n=s+1,o++,r=o}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=f(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t},i}var d={exports:{}};const C=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e?.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),m=0!==C&&{level:C,hasBasic:!0,has256:C>=2,has16m:C>=3},g={stdout:m,stderr:m};var h,F,y=n(Object.freeze({__proto__:null,default:g}));function b(){return h||(h=1,function(r,n){const s=e,o=t;n.init=function(e){e.inspectOpts={};const t=Object.keys(n.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=n.inspectOpts[t[r]]},n.log=function(...e){return process.stderr.write(o.formatWithOptions(n.inspectOpts,...e)+"\n")},n.formatArgs=function(e){const{namespace:t,useColors:s}=this;if(s){const n=this.color,s="[3"+(n<8?n:"8;5;"+n),o=`${s};1m${("+"+r.exports.humanize(this.diff)).padStart(6)} ${t} [0m`;e[0]=o+e[0].split("\n").join("\n"+o),e.push(s+"[0m")}else e[0]=function(){if(n.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+t+" "+e[0]},n.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},n.load=function(){return process.env.DEBUG},n.useColors=function(){return"colors"in n.inspectOpts?Boolean(n.inspectOpts.colors):s.isatty(process.stderr.fd)},n.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),n.colors=[6,2,3,4,5,1];try{const e=y;e&&(e.stderr||e).level>=2&&(n.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}n.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e},{}),r.exports=p()(n);const{formatters:i}=r.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}}(d,d.exports)),d.exports}var v=(F||(F=1,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?u.exports=(a||(a=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+`${("+"+e.exports.humanize(this.diff)).padStart(6)} ${this.namespace}`+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" "),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,s=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(s=n))}),t.splice(s,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#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"],t.log=console.debug||console.log||(()=>{}),e.exports=p()(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(l,l.exports)),l.exports):u.exports=b()),u.exports),w=r(v);export{w as default};
|
package/dist/eruda/loader.js
CHANGED
|
@@ -84,6 +84,7 @@ export async function loadEruda(options) {
|
|
|
84
84
|
const { gg } = await import('../gg.js');
|
|
85
85
|
const { createGgPlugin } = await import('./plugin.js');
|
|
86
86
|
const ggPlugin = createGgPlugin(options, gg);
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
88
|
eruda.add(ggPlugin);
|
|
88
89
|
// Make GG tab the default selected tab
|
|
89
90
|
eruda.show('GG');
|
package/dist/eruda/plugin.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
import type { GgErudaOptions } from './types.js';
|
|
1
|
+
import type { GgErudaOptions, CapturedEntry } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Licia jQuery-like wrapper used by Eruda
|
|
4
|
+
*/
|
|
5
|
+
interface LiciaElement {
|
|
6
|
+
html(content: string): void;
|
|
7
|
+
show(): void;
|
|
8
|
+
hide(): void;
|
|
9
|
+
find(selector: string): LiciaElement;
|
|
10
|
+
on(event: string, handler: (e: Event) => void): void;
|
|
11
|
+
get(index: number): HTMLElement | undefined;
|
|
12
|
+
length: number;
|
|
13
|
+
}
|
|
2
14
|
/**
|
|
3
15
|
* Creates the gg Eruda plugin
|
|
4
16
|
*
|
|
5
17
|
* Uses Eruda's plugin API where $el is a jQuery-like (licia) wrapper.
|
|
6
18
|
* Methods: $el.html(), $el.show(), $el.hide(), $el.find(), $el.on()
|
|
7
19
|
*/
|
|
8
|
-
export declare function createGgPlugin(options: GgErudaOptions, gg:
|
|
20
|
+
export declare function createGgPlugin(options: GgErudaOptions, gg: {
|
|
21
|
+
_onLog?: ((entry: CapturedEntry) => void) | null;
|
|
22
|
+
}): {
|
|
9
23
|
name: string;
|
|
10
|
-
init($container:
|
|
24
|
+
init($container: LiciaElement): void;
|
|
11
25
|
show(): void;
|
|
12
26
|
hide(): void;
|
|
13
27
|
destroy(): void;
|
|
14
28
|
};
|
|
29
|
+
export {};
|
package/dist/eruda/plugin.js
CHANGED
|
@@ -16,7 +16,7 @@ export function createGgPlugin(options, gg) {
|
|
|
16
16
|
// Filter UI state
|
|
17
17
|
let filterExpanded = false;
|
|
18
18
|
let filterPattern = '';
|
|
19
|
-
|
|
19
|
+
const enabledNamespaces = new Set();
|
|
20
20
|
const plugin = {
|
|
21
21
|
name: 'GG',
|
|
22
22
|
init($container) {
|
|
@@ -48,11 +48,15 @@ export function createGgPlugin(options, gg) {
|
|
|
48
48
|
renderLogs();
|
|
49
49
|
},
|
|
50
50
|
show() {
|
|
51
|
-
$el
|
|
52
|
-
|
|
51
|
+
if ($el) {
|
|
52
|
+
$el.show();
|
|
53
|
+
renderLogs();
|
|
54
|
+
}
|
|
53
55
|
},
|
|
54
56
|
hide() {
|
|
55
|
-
$el
|
|
57
|
+
if ($el) {
|
|
58
|
+
$el.hide();
|
|
59
|
+
}
|
|
56
60
|
},
|
|
57
61
|
destroy() {
|
|
58
62
|
if (gg) {
|
|
@@ -61,19 +65,6 @@ export function createGgPlugin(options, gg) {
|
|
|
61
65
|
buffer.clear();
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
|
-
function loadFilterState() {
|
|
65
|
-
filterPattern = localStorage.getItem('debug') || '';
|
|
66
|
-
// Rebuild enabledNamespaces based on current pattern and captured logs
|
|
67
|
-
const allNamespaces = getAllCapturedNamespaces();
|
|
68
|
-
enabledNamespaces.clear();
|
|
69
|
-
// If no pattern, default to 'gg:*' (show all gg logs)
|
|
70
|
-
const effectivePattern = filterPattern || 'gg:*';
|
|
71
|
-
allNamespaces.forEach((ns) => {
|
|
72
|
-
if (namespaceMatchesPattern(ns, effectivePattern)) {
|
|
73
|
-
enabledNamespaces.add(ns);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
68
|
function toggleNamespace(namespace, enable) {
|
|
78
69
|
const currentPattern = filterPattern || 'gg:*';
|
|
79
70
|
const ns = namespace.trim();
|
|
@@ -423,7 +414,9 @@ export function createGgPlugin(options, gg) {
|
|
|
423
414
|
renderLogs();
|
|
424
415
|
});
|
|
425
416
|
$el.find('.gg-copy-btn').on('click', async () => {
|
|
426
|
-
const
|
|
417
|
+
const allEntries = buffer.getEntries();
|
|
418
|
+
// Apply same filtering as renderLogs() - only copy visible entries
|
|
419
|
+
const entries = allEntries.filter((entry) => enabledNamespaces.has(entry.namespace));
|
|
427
420
|
const text = entries
|
|
428
421
|
.map((e) => {
|
|
429
422
|
const timestamp = new Date(e.timestamp).toISOString();
|
|
@@ -562,10 +555,7 @@ export function createGgPlugin(options, gg) {
|
|
|
562
555
|
// Format each arg individually - objects are expandable
|
|
563
556
|
let argsHTML = '';
|
|
564
557
|
let detailsHTML = '';
|
|
565
|
-
if (entry.args.length
|
|
566
|
-
argsHTML = '';
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
558
|
+
if (entry.args.length > 0) {
|
|
569
559
|
argsHTML = entry.args
|
|
570
560
|
.map((arg, argIdx) => {
|
|
571
561
|
if (typeof arg === 'object' && arg !== null) {
|