@leftium/gg 0.0.42 → 0.0.43
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 +26 -34
- package/package.json +1 -1
package/dist/eruda/plugin.js
CHANGED
|
@@ -106,6 +106,30 @@ export function createGgPlugin(options, gg) {
|
|
|
106
106
|
localStorage.setItem(COPY_FORMAT_KEY, copyFormat);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Format a single log entry for clipboard copy
|
|
111
|
+
* Produces: HH:MM:SS.mmm namespace args [optional expression]
|
|
112
|
+
*/
|
|
113
|
+
function formatEntryForClipboard(entry, includeExpressions) {
|
|
114
|
+
// Extract HH:MM:SS.mmm from timestamp (with milliseconds)
|
|
115
|
+
const time = new Date(entry.timestamp).toISOString().slice(11, 23);
|
|
116
|
+
// Trim namespace and strip 'gg:' prefix to save tokens
|
|
117
|
+
const ns = entry.namespace.trim().replace(/^gg:/, '');
|
|
118
|
+
// Include expression suffix when toggle is enabled
|
|
119
|
+
const hasSrcExpr = !entry.level && entry.src?.trim() && !/^['"`]/.test(entry.src);
|
|
120
|
+
const exprSuffix = includeExpressions && hasSrcExpr ? ` \u2039${entry.src}\u203A` : '';
|
|
121
|
+
// Format args: compact JSON for objects, primitives as-is
|
|
122
|
+
const argsStr = entry.args
|
|
123
|
+
.map((arg) => {
|
|
124
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
125
|
+
return JSON.stringify(arg);
|
|
126
|
+
}
|
|
127
|
+
// Strip ANSI escape codes from string args
|
|
128
|
+
return stripAnsi(String(arg));
|
|
129
|
+
})
|
|
130
|
+
.join(' ');
|
|
131
|
+
return `${time} ${ns} ${argsStr}${exprSuffix}`;
|
|
132
|
+
}
|
|
109
133
|
const plugin = {
|
|
110
134
|
name: 'GG',
|
|
111
135
|
init($container) {
|
|
@@ -1355,26 +1379,7 @@ export function createGgPlugin(options, gg) {
|
|
|
1355
1379
|
// Apply same filtering as renderLogs() - only copy visible entries
|
|
1356
1380
|
const entries = allEntries.filter((entry) => enabledNamespaces.has(entry.namespace));
|
|
1357
1381
|
const text = entries
|
|
1358
|
-
.map((e) =>
|
|
1359
|
-
// Extract just HH:MM:SS from timestamp (compact for LLMs)
|
|
1360
|
-
const time = new Date(e.timestamp).toISOString().slice(11, 19);
|
|
1361
|
-
// Trim namespace and strip 'gg:' prefix to save tokens
|
|
1362
|
-
const ns = e.namespace.trim().replace(/^gg:/, '');
|
|
1363
|
-
// Include expression suffix when toggle is enabled
|
|
1364
|
-
const hasSrcExpr = !e.level && e.src?.trim() && !/^['"`]/.test(e.src);
|
|
1365
|
-
const exprSuffix = showExpressions && hasSrcExpr ? ` \u2039${e.src}\u203A` : '';
|
|
1366
|
-
// Format args: compact JSON for objects, primitives as-is
|
|
1367
|
-
const argsStr = e.args
|
|
1368
|
-
.map((arg) => {
|
|
1369
|
-
if (typeof arg === 'object' && arg !== null) {
|
|
1370
|
-
return JSON.stringify(arg);
|
|
1371
|
-
}
|
|
1372
|
-
// Strip ANSI escape codes from string args
|
|
1373
|
-
return stripAnsi(String(arg));
|
|
1374
|
-
})
|
|
1375
|
-
.join(' ');
|
|
1376
|
-
return `${time} ${ns} ${argsStr}${exprSuffix}`;
|
|
1377
|
-
})
|
|
1382
|
+
.map((e) => formatEntryForClipboard(e, showExpressions))
|
|
1378
1383
|
.join('\n');
|
|
1379
1384
|
try {
|
|
1380
1385
|
await navigator.clipboard.writeText(text);
|
|
@@ -1795,20 +1800,7 @@ export function createGgPlugin(options, gg) {
|
|
|
1795
1800
|
if (!entry)
|
|
1796
1801
|
return;
|
|
1797
1802
|
e.preventDefault();
|
|
1798
|
-
const
|
|
1799
|
-
const ns = entry.namespace.trim().replace(/^gg:/, '');
|
|
1800
|
-
// Include expression suffix when toggle is enabled
|
|
1801
|
-
const hasSrcExpr = !entry.level && entry.src?.trim() && !/^['"`]/.test(entry.src);
|
|
1802
|
-
const exprSuffix = showExpressions && hasSrcExpr ? ` \u2039${entry.src}\u203A` : '';
|
|
1803
|
-
const argsStr = entry.args
|
|
1804
|
-
.map((arg) => {
|
|
1805
|
-
if (typeof arg === 'object' && arg !== null) {
|
|
1806
|
-
return JSON.stringify(arg);
|
|
1807
|
-
}
|
|
1808
|
-
return stripAnsi(String(arg));
|
|
1809
|
-
})
|
|
1810
|
-
.join(' ');
|
|
1811
|
-
const text = `${time} ${ns} ${argsStr}${exprSuffix}`;
|
|
1803
|
+
const text = formatEntryForClipboard(entry, showExpressions);
|
|
1812
1804
|
navigator.clipboard.writeText(text).then(() => {
|
|
1813
1805
|
showConfirmationTooltip(containerEl, contentEl, 'Copied message');
|
|
1814
1806
|
});
|