@leftium/gg 0.0.35 → 0.0.37
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/dist/eruda/plugin.js +18 -7
- package/dist/eruda/types.d.ts +1 -1
- package/dist/gg-call-sites-plugin.js +7 -5
- package/dist/gg.d.ts +9 -1
- package/dist/gg.js +28 -2
- package/package.json +1 -1
package/dist/eruda/plugin.js
CHANGED
|
@@ -521,7 +521,16 @@ export function createGgPlugin(options, gg) {
|
|
|
521
521
|
padding-bottom: 4px;
|
|
522
522
|
border-bottom: 1px solid #ddd;
|
|
523
523
|
}
|
|
524
|
-
/* Level-based styling for warn/error entries */
|
|
524
|
+
/* Level-based styling for info/warn/error entries */
|
|
525
|
+
.gg-level-info .gg-log-diff,
|
|
526
|
+
.gg-level-info .gg-log-ns,
|
|
527
|
+
.gg-level-info .gg-log-content {
|
|
528
|
+
background: rgba(23, 162, 184, 0.08);
|
|
529
|
+
}
|
|
530
|
+
.gg-level-info .gg-log-content {
|
|
531
|
+
border-left: 3px solid #17a2b8;
|
|
532
|
+
padding-left: 6px;
|
|
533
|
+
}
|
|
525
534
|
.gg-level-warn .gg-log-diff,
|
|
526
535
|
.gg-level-warn .gg-log-ns,
|
|
527
536
|
.gg-level-warn .gg-log-content {
|
|
@@ -1539,12 +1548,14 @@ export function createGgPlugin(options, gg) {
|
|
|
1539
1548
|
}
|
|
1540
1549
|
}
|
|
1541
1550
|
const fileTitle = fileTitleText ? ` title="${escapeHtml(fileTitleText)}"` : '';
|
|
1542
|
-
// Level class for warn/error styling
|
|
1543
|
-
const levelClass = entry.level === '
|
|
1544
|
-
? ' gg-level-
|
|
1545
|
-
: entry.level === '
|
|
1546
|
-
? ' gg-level-
|
|
1547
|
-
: ''
|
|
1551
|
+
// Level class for info/warn/error styling
|
|
1552
|
+
const levelClass = entry.level === 'info'
|
|
1553
|
+
? ' gg-level-info'
|
|
1554
|
+
: entry.level === 'warn'
|
|
1555
|
+
? ' gg-level-warn'
|
|
1556
|
+
: entry.level === 'error'
|
|
1557
|
+
? ' gg-level-error'
|
|
1558
|
+
: '';
|
|
1548
1559
|
// Stack trace toggle (for error/trace entries with captured stacks)
|
|
1549
1560
|
let stackHTML = '';
|
|
1550
1561
|
if (entry.stack) {
|
package/dist/eruda/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface GgErudaOptions {
|
|
|
19
19
|
erudaOptions?: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
21
|
/** Log severity level */
|
|
22
|
-
export type LogLevel = 'debug' | 'warn' | 'error';
|
|
22
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
23
23
|
/**
|
|
24
24
|
* A captured log entry from gg()
|
|
25
25
|
*/
|
|
@@ -38,9 +38,14 @@ export default function ggCallSitesPlugin(options = {}) {
|
|
|
38
38
|
// Only process JS/TS/Svelte files
|
|
39
39
|
if (!/\.(js|ts|svelte|jsx|tsx|mjs|mts)(\?.*)?$/.test(id))
|
|
40
40
|
return null;
|
|
41
|
+
// Don't transform code inside node_modules
|
|
42
|
+
// This prevents rewriting library code (including gg itself when published)
|
|
43
|
+
if (id.includes('/node_modules/'))
|
|
44
|
+
return null;
|
|
41
45
|
// Quick bail: no gg calls in this file
|
|
42
46
|
if (!code.includes('gg(') &&
|
|
43
47
|
!code.includes('gg.ns(') &&
|
|
48
|
+
!code.includes('gg.info(') &&
|
|
44
49
|
!code.includes('gg.warn(') &&
|
|
45
50
|
!code.includes('gg.error(') &&
|
|
46
51
|
!code.includes('gg.table(') &&
|
|
@@ -50,9 +55,6 @@ export default function ggCallSitesPlugin(options = {}) {
|
|
|
50
55
|
!code.includes('gg.timeLog(') &&
|
|
51
56
|
!code.includes('gg.timeEnd('))
|
|
52
57
|
return null;
|
|
53
|
-
// Don't transform gg's own source files
|
|
54
|
-
if (id.includes('/lib/gg.') || id.includes('/lib/debug'))
|
|
55
|
-
return null;
|
|
56
58
|
// Build the short callpoint from the file path (strips src/ prefix)
|
|
57
59
|
// e.g. "/Users/me/project/src/routes/+page.svelte" → "routes/+page.svelte"
|
|
58
60
|
const shortPath = id.replace(srcRootRegex, '');
|
|
@@ -799,11 +801,11 @@ export function transformGgCalls(code, shortPath, filePath, svelteInfo, jsFuncti
|
|
|
799
801
|
i += 6;
|
|
800
802
|
continue;
|
|
801
803
|
}
|
|
802
|
-
// Case 1b: gg.warn/error/table/trace/assert → gg._warn/_error/_table/_trace/_assert
|
|
804
|
+
// Case 1b: gg.info/warn/error/table/trace/assert → gg._info/_warn/_error/_table/_trace/_assert
|
|
803
805
|
// These methods are rewritten like bare gg() but with their internal variant.
|
|
804
806
|
const dotMethodMatch = code
|
|
805
807
|
.slice(i + 2)
|
|
806
|
-
.match(/^\.(warn|error|table|trace|assert|time|timeLog|timeEnd)\(/);
|
|
808
|
+
.match(/^\.(info|warn|error|table|trace|assert|time|timeLog|timeEnd)\(/);
|
|
807
809
|
if (dotMethodMatch) {
|
|
808
810
|
const methodName = dotMethodMatch[1];
|
|
809
811
|
const internalName = `_${methodName}`;
|
package/dist/gg.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook for capturing gg() output (used by Eruda plugin)
|
|
3
3
|
*/
|
|
4
|
-
type LogLevel = 'debug' | 'warn' | 'error';
|
|
4
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
5
|
interface CapturedEntry {
|
|
6
6
|
namespace: string;
|
|
7
7
|
color: string;
|
|
@@ -110,6 +110,7 @@ export declare namespace gg {
|
|
|
110
110
|
col?: number;
|
|
111
111
|
src?: string;
|
|
112
112
|
};
|
|
113
|
+
let info: (...args: unknown[]) => unknown;
|
|
113
114
|
let warn: (...args: unknown[]) => unknown;
|
|
114
115
|
let error: (...args: unknown[]) => unknown;
|
|
115
116
|
let assert: (condition: unknown, ...args: unknown[]) => unknown;
|
|
@@ -118,6 +119,13 @@ export declare namespace gg {
|
|
|
118
119
|
let timeLog: (label?: string, ...args: unknown[]) => void;
|
|
119
120
|
let timeEnd: (label?: string) => void;
|
|
120
121
|
let trace: (...args: unknown[]) => unknown;
|
|
122
|
+
let _info: (options: {
|
|
123
|
+
ns: string;
|
|
124
|
+
file?: string;
|
|
125
|
+
line?: number;
|
|
126
|
+
col?: number;
|
|
127
|
+
src?: string;
|
|
128
|
+
}, ...args: unknown[]) => unknown;
|
|
121
129
|
let _warn: (options: {
|
|
122
130
|
ns: string;
|
|
123
131
|
file?: string;
|
package/dist/gg.js
CHANGED
|
@@ -282,8 +282,11 @@ function ggLog(options, ...args) {
|
|
|
282
282
|
logArgs = [args[0], ...args.slice(1)];
|
|
283
283
|
returnValue = args[0];
|
|
284
284
|
}
|
|
285
|
-
// Add level prefix emoji for warn/error
|
|
286
|
-
if (level === '
|
|
285
|
+
// Add level prefix emoji for info/warn/error
|
|
286
|
+
if (level === 'info') {
|
|
287
|
+
logArgs[0] = `ℹ️ ${logArgs[0]}`;
|
|
288
|
+
}
|
|
289
|
+
else if (level === 'warn') {
|
|
287
290
|
logArgs[0] = `⚠️ ${logArgs[0]}`;
|
|
288
291
|
}
|
|
289
292
|
else if (level === 'error') {
|
|
@@ -390,6 +393,29 @@ function getErrorStack(firstArg, skipFrames) {
|
|
|
390
393
|
}
|
|
391
394
|
return captureStack(skipFrames);
|
|
392
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* gg.info() - Log at info level.
|
|
398
|
+
*
|
|
399
|
+
* Passthrough: returns the first argument.
|
|
400
|
+
* In Eruda, entries are styled with a blue/info indicator.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* gg.info('System startup complete');
|
|
404
|
+
* const config = gg.info(loadedConfig, 'loaded config');
|
|
405
|
+
*/
|
|
406
|
+
gg.info = function (...args) {
|
|
407
|
+
if (!ggConfig.enabled || isCloudflareWorker()) {
|
|
408
|
+
return args.length ? args[0] : undefined;
|
|
409
|
+
}
|
|
410
|
+
const callpoint = resolveCallpoint(3);
|
|
411
|
+
return ggLog({ ns: callpoint, level: 'info' }, ...args);
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* gg._info() - Internal: info with call-site metadata from Vite plugin.
|
|
415
|
+
*/
|
|
416
|
+
gg._info = function (options, ...args) {
|
|
417
|
+
return ggLog({ ...options, level: 'info' }, ...args);
|
|
418
|
+
};
|
|
393
419
|
/**
|
|
394
420
|
* gg.warn() - Log at warning level.
|
|
395
421
|
*
|