@leftium/gg 0.0.31 → 0.0.34
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 +117 -36
- package/dist/GgConsole.svelte +12 -0
- package/dist/GgConsole.svelte.d.ts +4 -0
- package/dist/OpenInEditorLink.svelte +8 -10
- package/dist/OpenInEditorLink.svelte.d.ts +6 -3
- package/dist/debug/browser.d.ts +10 -0
- package/dist/debug/browser.js +102 -0
- package/dist/debug/common.d.ts +41 -0
- package/dist/debug/common.js +191 -0
- package/dist/debug/index.d.ts +9 -0
- package/dist/debug/index.js +11 -0
- package/dist/debug/node.d.ts +10 -0
- package/dist/debug/node.js +137 -0
- package/dist/eruda/loader.js +0 -11
- package/dist/eruda/plugin.js +765 -25
- package/dist/eruda/types.d.ts +8 -5
- package/dist/gg-call-sites-plugin.d.ts +90 -6
- package/dist/gg-call-sites-plugin.js +700 -112
- package/dist/gg.d.ts +18 -2
- package/dist/gg.js +127 -110
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/open-in-editor.js +15 -2
- package/dist/vite.d.ts +37 -0
- package/dist/vite.js +46 -0
- package/package.json +20 -13
- package/dist/debug-bundled.d.ts +0 -2
- package/dist/debug-bundled.js +0 -3
- package/dist/debug.d.ts +0 -2
- package/dist/debug.js +0 -15
- package/patches/debug@4.4.3.patch +0 -35
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js-specific debug implementation.
|
|
3
|
+
*
|
|
4
|
+
* Output: process.stderr via util.formatWithOptions.
|
|
5
|
+
* Persistence: process.env.DEBUG
|
|
6
|
+
* Format (patched): +123ms namespace message (ANSI colored)
|
|
7
|
+
*/
|
|
8
|
+
import { setup, humanize } from './common.js';
|
|
9
|
+
import tty from 'tty';
|
|
10
|
+
import util from 'util';
|
|
11
|
+
/**
|
|
12
|
+
* Basic ANSI colors (6) — used when 256-color support is not detected.
|
|
13
|
+
* Extended 256-color palette matches debug@4 for color-hash stability.
|
|
14
|
+
*/
|
|
15
|
+
const basicColors = [6, 2, 3, 4, 5, 1];
|
|
16
|
+
const extendedColors = [
|
|
17
|
+
20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45,
|
|
18
|
+
56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81,
|
|
19
|
+
92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149,
|
|
20
|
+
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
|
|
21
|
+
172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201,
|
|
22
|
+
202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221
|
|
23
|
+
];
|
|
24
|
+
/** Detect 256-color support via supports-color (optional) or heuristic */
|
|
25
|
+
function detectColors() {
|
|
26
|
+
try {
|
|
27
|
+
// Try supports-color if available (same as debug@4)
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29
|
+
const supportsColor = require('supports-color');
|
|
30
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
31
|
+
return extendedColors;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Not installed — fall through
|
|
36
|
+
}
|
|
37
|
+
return basicColors;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build inspectOpts from DEBUG_* environment variables.
|
|
41
|
+
* Supports: DEBUG_COLORS, DEBUG_DEPTH, DEBUG_SHOW_HIDDEN, DEBUG_HIDE_DATE
|
|
42
|
+
*/
|
|
43
|
+
const inspectOpts = Object.keys(process.env)
|
|
44
|
+
.filter((key) => /^debug_/i.test(key))
|
|
45
|
+
.reduce((obj, key) => {
|
|
46
|
+
const prop = key
|
|
47
|
+
.substring(6)
|
|
48
|
+
.toLowerCase()
|
|
49
|
+
.replace(/_([a-z])/g, (_, k) => k.toUpperCase());
|
|
50
|
+
let val = process.env[key];
|
|
51
|
+
if (/^(yes|on|true|enabled)$/i.test(val))
|
|
52
|
+
val = true;
|
|
53
|
+
else if (/^(no|off|false|disabled)$/i.test(val))
|
|
54
|
+
val = false;
|
|
55
|
+
else if (val === 'null')
|
|
56
|
+
val = null;
|
|
57
|
+
else
|
|
58
|
+
val = Number(val);
|
|
59
|
+
obj[prop] = val;
|
|
60
|
+
return obj;
|
|
61
|
+
}, {});
|
|
62
|
+
function useColors() {
|
|
63
|
+
return 'colors' in inspectOpts
|
|
64
|
+
? Boolean(inspectOpts.colors)
|
|
65
|
+
: tty.isatty(process.stderr.fd);
|
|
66
|
+
}
|
|
67
|
+
function getDate() {
|
|
68
|
+
if (inspectOpts.hideDate)
|
|
69
|
+
return '';
|
|
70
|
+
return new Date().toISOString() + ' ';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Format args with ANSI colors and gg's patched prefix order:
|
|
74
|
+
* +123ms namespace message
|
|
75
|
+
*/
|
|
76
|
+
function formatArgs(args) {
|
|
77
|
+
const name = this.namespace;
|
|
78
|
+
const useCol = this.useColors;
|
|
79
|
+
if (useCol) {
|
|
80
|
+
const c = Number(this.color);
|
|
81
|
+
const colorCode = '\u001B[3' + (c < 8 ? String(c) : '8;5;' + c);
|
|
82
|
+
const h = ('+' + humanize(this.diff)).padStart(6);
|
|
83
|
+
const prefix = `${colorCode};1m${h} ${name} \u001B[0m`;
|
|
84
|
+
args[0] = prefix + String(args[0]).split('\n').join('\n' + prefix);
|
|
85
|
+
// Append empty color reset (preserves arg count parity from original debug)
|
|
86
|
+
args.push(colorCode + '' + '\u001B[0m');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
args[0] = getDate() + name + ' ' + args[0];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function log(...args) {
|
|
93
|
+
process.stderr.write(util.formatWithOptions(inspectOpts, ...args) + '\n');
|
|
94
|
+
}
|
|
95
|
+
function save(namespaces) {
|
|
96
|
+
if (namespaces) {
|
|
97
|
+
process.env.DEBUG = namespaces;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
delete process.env.DEBUG;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function load() {
|
|
104
|
+
return process.env.DEBUG || '';
|
|
105
|
+
}
|
|
106
|
+
function init(instance) {
|
|
107
|
+
// Each instance gets its own inspectOpts copy (for per-instance color override)
|
|
108
|
+
instance.inspectOpts = { ...inspectOpts };
|
|
109
|
+
}
|
|
110
|
+
const env = {
|
|
111
|
+
formatArgs,
|
|
112
|
+
save,
|
|
113
|
+
load,
|
|
114
|
+
useColors,
|
|
115
|
+
colors: detectColors(),
|
|
116
|
+
log,
|
|
117
|
+
init,
|
|
118
|
+
formatters: {
|
|
119
|
+
/** %o → util.inspect, single line */
|
|
120
|
+
o(v) {
|
|
121
|
+
const opts = this.inspectOpts || {};
|
|
122
|
+
opts.colors = this.useColors;
|
|
123
|
+
return util.inspect(v, opts)
|
|
124
|
+
.split('\n')
|
|
125
|
+
.map((str) => str.trim())
|
|
126
|
+
.join(' ');
|
|
127
|
+
},
|
|
128
|
+
/** %O → util.inspect, multi-line */
|
|
129
|
+
O(v) {
|
|
130
|
+
const opts = this.inspectOpts || {};
|
|
131
|
+
opts.colors = this.useColors;
|
|
132
|
+
return util.inspect(v, opts);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const debug = setup(env);
|
|
137
|
+
export default debug;
|
package/dist/eruda/loader.js
CHANGED
|
@@ -79,17 +79,6 @@ export async function loadEruda(options) {
|
|
|
79
79
|
// Ensure tool is always visible in case user customizes
|
|
80
80
|
tool: ['console', 'elements', 'network', 'resources', 'info', 'snippets', 'sources']
|
|
81
81
|
});
|
|
82
|
-
// Auto-enable localStorage.debug if requested and unset
|
|
83
|
-
if (options.autoEnable !== false) {
|
|
84
|
-
try {
|
|
85
|
-
if (!localStorage.getItem('debug')) {
|
|
86
|
-
localStorage.setItem('debug', 'gg:*');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// localStorage might not be available
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
82
|
// Register gg plugin
|
|
94
83
|
// Import gg and pass it to the plugin directly
|
|
95
84
|
const { gg, runGgDiagnostics } = await import('../gg.js');
|