@leftium/gg 0.0.51 → 0.0.52
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/gg.js +19 -20
- package/package.json +1 -1
package/dist/gg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import debugFactory, { debugReady } from './debug/index.js';
|
|
2
1
|
import { BROWSER, DEV } from 'esm-env';
|
|
2
|
+
import debugFactory, { debugReady } from './debug/index.js';
|
|
3
3
|
import { toWordTuple } from './words.js';
|
|
4
4
|
const _ggCallSitesPlugin = typeof __GG_TAG_PLUGIN__ !== 'undefined' ? __GG_TAG_PLUGIN__ : false;
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ function createGgDebugger(namespace) {
|
|
|
11
11
|
// Store the original formatArgs
|
|
12
12
|
const originalFormatArgs = dbg.formatArgs;
|
|
13
13
|
// Override formatArgs to add padding to the namespace display
|
|
14
|
-
dbg.formatArgs =
|
|
14
|
+
dbg.formatArgs = (args) => {
|
|
15
15
|
// Call original formatArgs first
|
|
16
16
|
if (originalFormatArgs) {
|
|
17
17
|
originalFormatArgs.call(dbg, args);
|
|
@@ -232,7 +232,7 @@ export function gg(...args) {
|
|
|
232
232
|
* @example
|
|
233
233
|
* <OpenInEditorLink gg={gg.here()} />
|
|
234
234
|
*/
|
|
235
|
-
gg.here =
|
|
235
|
+
gg.here = () => {
|
|
236
236
|
if (!ggConfig.enabled) {
|
|
237
237
|
return { fileName: '', functionName: '', url: '' };
|
|
238
238
|
}
|
|
@@ -448,14 +448,15 @@ function ggLog(options, ...args) {
|
|
|
448
448
|
// on CapturedEntry for the Eruda UI to display on hover)
|
|
449
449
|
const logArgs = args.length === 0 ? ['(no args)'] : [...args];
|
|
450
450
|
// Add level prefix emoji for info/warn/error
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
451
|
+
const levelEmoji = level === 'info' ? 'ℹ️' : level === 'warn' ? '⚠️' : level === 'error' ? '⛔' : '';
|
|
452
|
+
if (levelEmoji) {
|
|
453
|
+
if (typeof logArgs[0] === 'string') {
|
|
454
|
+
logArgs[0] = `${levelEmoji} ${logArgs[0]}`;
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
// Don't coerce objects to string via template literal — prepend emoji as separate arg
|
|
458
|
+
logArgs.unshift(levelEmoji);
|
|
459
|
+
}
|
|
459
460
|
}
|
|
460
461
|
// Compute diff independently of the debug library's enabled state.
|
|
461
462
|
// ggLogFunction.diff only updates when the debugger is enabled (i.e. localStorage.debug
|
|
@@ -508,7 +509,7 @@ function ggLog(options, ...args) {
|
|
|
508
509
|
*
|
|
509
510
|
* Returns a GgChain for chaining modifiers (.ns(), .warn(), etc.)
|
|
510
511
|
*/
|
|
511
|
-
gg._ns =
|
|
512
|
+
gg._ns = (options, ...args) => {
|
|
512
513
|
const disabled = !ggConfig.enabled;
|
|
513
514
|
return new GgChain(args[0], args, options, disabled);
|
|
514
515
|
};
|
|
@@ -517,7 +518,7 @@ gg._ns = function (options, ...args) {
|
|
|
517
518
|
*
|
|
518
519
|
* Called by the ggCallSitesPlugin when it rewrites gg.here() calls.
|
|
519
520
|
*/
|
|
520
|
-
gg._here =
|
|
521
|
+
gg._here = (options) => {
|
|
521
522
|
if (!ggConfig.enabled) {
|
|
522
523
|
return { fileName: '', functionName: '', url: '' };
|
|
523
524
|
}
|
|
@@ -540,9 +541,7 @@ gg._here = function (options) {
|
|
|
540
541
|
* In <script> blocks: gg._ns({ns:'...', file:'...', line:1, col:1}, args)
|
|
541
542
|
* In template markup: gg._ns(gg._o('...','...',1,1), args)
|
|
542
543
|
*/
|
|
543
|
-
gg._o =
|
|
544
|
-
return { ns, file, line, col, src };
|
|
545
|
-
};
|
|
544
|
+
gg._o = (ns, file, line, col, src) => ({ ns, file, line, col, src });
|
|
546
545
|
gg.disable = isCloudflareWorker() ? () => '' : () => debugFactory.disable();
|
|
547
546
|
gg.enable = isCloudflareWorker() ? () => { } : (ns) => debugFactory.enable(ns);
|
|
548
547
|
/**
|
|
@@ -633,7 +632,7 @@ gg.time = function (label = 'default') {
|
|
|
633
632
|
return new GgTimerChain(label, options);
|
|
634
633
|
};
|
|
635
634
|
/** gg._time() - Internal: time with call-site metadata from Vite plugin. */
|
|
636
|
-
gg._time =
|
|
635
|
+
gg._time = (options, label = 'default') => {
|
|
637
636
|
if (ggConfig.enabled) {
|
|
638
637
|
timers.set(label, { start: performance.now(), options });
|
|
639
638
|
}
|
|
@@ -665,7 +664,7 @@ gg.timeLog = function (label = 'default', ...args) {
|
|
|
665
664
|
ggLog({ ...timer.options, ns }, `${label}: ${formatElapsed(elapsed)}`, ...args);
|
|
666
665
|
};
|
|
667
666
|
/** gg._timeLog() - Internal: timeLog with call-site metadata from Vite plugin. */
|
|
668
|
-
gg._timeLog =
|
|
667
|
+
gg._timeLog = (options, label = 'default', ...args) => {
|
|
669
668
|
if (!ggConfig.enabled)
|
|
670
669
|
return;
|
|
671
670
|
const timer = timers.get(label);
|
|
@@ -702,7 +701,7 @@ gg.timeEnd = function (label = 'default') {
|
|
|
702
701
|
ggLog({ ...timer.options, ns }, `${label}: ${formatElapsed(elapsed)}`);
|
|
703
702
|
};
|
|
704
703
|
/** gg._timeEnd() - Internal: timeEnd with call-site metadata from Vite plugin. */
|
|
705
|
-
gg._timeEnd =
|
|
704
|
+
gg._timeEnd = (options, label = 'default') => {
|
|
706
705
|
if (!ggConfig.enabled)
|
|
707
706
|
return;
|
|
708
707
|
const timer = timers.get(label);
|
|
@@ -871,7 +870,7 @@ const STYLE_CODES = {
|
|
|
871
870
|
* Internal helper to create chainable color function with method chaining
|
|
872
871
|
*/
|
|
873
872
|
function createColorFunction(fgCode = '', bgCode = '', styleCode = '') {
|
|
874
|
-
const tagFn =
|
|
873
|
+
const tagFn = (strings, ...values) => {
|
|
875
874
|
const text = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? String(values[i]) : ''), '');
|
|
876
875
|
return fgCode + bgCode + styleCode + text + '\x1b[0m';
|
|
877
876
|
};
|