claude-scope 0.8.25 → 0.8.27
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/claude-scope.cjs +58 -30
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -1633,6 +1633,8 @@ var init_renderer = __esm({
|
|
|
1633
1633
|
* on separate lines. Widgets that throw errors are logged (via onError
|
|
1634
1634
|
* callback) and skipped, allowing other widgets to continue rendering.
|
|
1635
1635
|
*
|
|
1636
|
+
* Empty lines are preserved to maintain correct line positioning.
|
|
1637
|
+
*
|
|
1636
1638
|
* @param widgets - Array of widgets to render
|
|
1637
1639
|
* @param context - Render context with width and timestamp
|
|
1638
1640
|
* @returns Array of rendered lines (one per line number)
|
|
@@ -1649,9 +1651,9 @@ var init_renderer = __esm({
|
|
|
1649
1651
|
}
|
|
1650
1652
|
lineMap.get(line)?.push(widget);
|
|
1651
1653
|
}
|
|
1652
|
-
const
|
|
1654
|
+
const lineOutputs = /* @__PURE__ */ new Map();
|
|
1653
1655
|
const sortedLines = Array.from(lineMap.entries()).sort((a, b) => a[0] - b[0]);
|
|
1654
|
-
for (const [, widgetsForLine] of sortedLines) {
|
|
1656
|
+
for (const [lineNum, widgetsForLine] of sortedLines) {
|
|
1655
1657
|
const outputs = [];
|
|
1656
1658
|
for (const widget of widgetsForLine) {
|
|
1657
1659
|
try {
|
|
@@ -1667,10 +1669,10 @@ var init_renderer = __esm({
|
|
|
1667
1669
|
}
|
|
1668
1670
|
}
|
|
1669
1671
|
const line = outputs.join(this.separator);
|
|
1670
|
-
|
|
1671
|
-
lines.push(line);
|
|
1672
|
-
}
|
|
1672
|
+
lineOutputs.set(lineNum, line);
|
|
1673
1673
|
}
|
|
1674
|
+
const sortedEntries = Array.from(lineOutputs.entries()).sort((a, b) => a[0] - b[0]);
|
|
1675
|
+
const lines = sortedEntries.map(([, output]) => output);
|
|
1674
1676
|
return lines;
|
|
1675
1677
|
}
|
|
1676
1678
|
/**
|
|
@@ -26242,6 +26244,40 @@ init_model_widget();
|
|
|
26242
26244
|
|
|
26243
26245
|
// src/widgets/sysmon-widget.ts
|
|
26244
26246
|
init_widget_types();
|
|
26247
|
+
|
|
26248
|
+
// src/providers/metrics-cache.ts
|
|
26249
|
+
var MetricsCache = class {
|
|
26250
|
+
cached = null;
|
|
26251
|
+
cacheTime = 0;
|
|
26252
|
+
ttlMs;
|
|
26253
|
+
constructor(ttlMs = 1e3) {
|
|
26254
|
+
this.ttlMs = ttlMs;
|
|
26255
|
+
}
|
|
26256
|
+
/**
|
|
26257
|
+
* Get cached metrics or fetch fresh if cache expired
|
|
26258
|
+
* @param fetcher - Function to fetch fresh metrics
|
|
26259
|
+
* @returns Cached or fresh metrics, or null if fetcher returns null
|
|
26260
|
+
*/
|
|
26261
|
+
async get(fetcher) {
|
|
26262
|
+
const now = Date.now();
|
|
26263
|
+
if (this.cached && now - this.cacheTime < this.ttlMs) {
|
|
26264
|
+
return this.cached;
|
|
26265
|
+
}
|
|
26266
|
+
const fresh = await fetcher();
|
|
26267
|
+
this.cached = fresh;
|
|
26268
|
+
this.cacheTime = now;
|
|
26269
|
+
return fresh;
|
|
26270
|
+
}
|
|
26271
|
+
/**
|
|
26272
|
+
* Clear the cache
|
|
26273
|
+
*/
|
|
26274
|
+
clear() {
|
|
26275
|
+
this.cached = null;
|
|
26276
|
+
this.cacheTime = 0;
|
|
26277
|
+
}
|
|
26278
|
+
};
|
|
26279
|
+
|
|
26280
|
+
// src/widgets/sysmon-widget.ts
|
|
26245
26281
|
init_theme();
|
|
26246
26282
|
|
|
26247
26283
|
// src/widgets/sysmon/styles.ts
|
|
@@ -26313,29 +26349,27 @@ var SysmonWidget = class {
|
|
|
26313
26349
|
provider;
|
|
26314
26350
|
_lineOverride;
|
|
26315
26351
|
styleFn = sysmonStyles.balanced;
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
//
|
|
26352
|
+
cache;
|
|
26353
|
+
cacheTtlMs = 1e3;
|
|
26354
|
+
// 1 second cache
|
|
26319
26355
|
enabled = true;
|
|
26320
26356
|
constructor(colors2, provider) {
|
|
26321
26357
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
26322
26358
|
this.provider = provider ?? null;
|
|
26359
|
+
this.cache = new MetricsCache(this.cacheTtlMs);
|
|
26323
26360
|
}
|
|
26324
26361
|
async initialize(context) {
|
|
26325
26362
|
this.enabled = context.config?.enabled !== false;
|
|
26326
|
-
if (!this.provider || !this.enabled) {
|
|
26327
|
-
return;
|
|
26328
|
-
}
|
|
26329
|
-
this.currentMetrics = await this.provider.getMetrics();
|
|
26330
|
-
this.provider.startUpdate(this.updateIntervalMs, (metrics) => {
|
|
26331
|
-
this.currentMetrics = metrics;
|
|
26332
|
-
});
|
|
26333
26363
|
}
|
|
26334
26364
|
async render(_context) {
|
|
26335
|
-
if (!this.
|
|
26365
|
+
if (!this.provider || !this.isEnabled()) {
|
|
26336
26366
|
return null;
|
|
26337
26367
|
}
|
|
26338
|
-
|
|
26368
|
+
const metrics = await this.cache.get(() => this.provider.getMetrics());
|
|
26369
|
+
if (!metrics) {
|
|
26370
|
+
return null;
|
|
26371
|
+
}
|
|
26372
|
+
return this.styleFn(metrics, this.colors.sysmon);
|
|
26339
26373
|
}
|
|
26340
26374
|
async update(_data) {
|
|
26341
26375
|
}
|
|
@@ -26343,7 +26377,7 @@ var SysmonWidget = class {
|
|
|
26343
26377
|
return this.enabled && this.provider !== null;
|
|
26344
26378
|
}
|
|
26345
26379
|
async cleanup() {
|
|
26346
|
-
this.
|
|
26380
|
+
this.cache.clear();
|
|
26347
26381
|
}
|
|
26348
26382
|
setStyle(style = "balanced") {
|
|
26349
26383
|
const fn = sysmonStyles[style];
|
|
@@ -26459,19 +26493,13 @@ async function loadSystemInformation() {
|
|
|
26459
26493
|
}
|
|
26460
26494
|
siLoadAttempted = true;
|
|
26461
26495
|
try {
|
|
26462
|
-
console.error("[DEBUG SystemProvider] Trying dynamic import...");
|
|
26463
26496
|
si = await Promise.resolve().then(() => __toESM(require_lib2(), 1));
|
|
26464
|
-
|
|
26465
|
-
} catch (importError) {
|
|
26466
|
-
console.error("[DEBUG SystemProvider] Dynamic import failed:", importError);
|
|
26497
|
+
} catch {
|
|
26467
26498
|
try {
|
|
26468
|
-
console.error("[DEBUG SystemProvider] Trying require fallback...");
|
|
26469
26499
|
const module2 = await import("node:module");
|
|
26470
26500
|
const require2 = module2.createRequire(import_meta.url);
|
|
26471
26501
|
si = require2("systeminformation");
|
|
26472
|
-
|
|
26473
|
-
} catch (requireError) {
|
|
26474
|
-
console.error("[DEBUG SystemProvider] Require fallback failed:", requireError);
|
|
26502
|
+
} catch {
|
|
26475
26503
|
}
|
|
26476
26504
|
}
|
|
26477
26505
|
}
|
|
@@ -26539,6 +26567,9 @@ var SystemProvider = class {
|
|
|
26539
26567
|
this.logError(error);
|
|
26540
26568
|
});
|
|
26541
26569
|
}, intervalMs);
|
|
26570
|
+
if (this.intervalId && typeof this.intervalId.unref === "function") {
|
|
26571
|
+
this.intervalId.unref();
|
|
26572
|
+
}
|
|
26542
26573
|
}
|
|
26543
26574
|
stopUpdate() {
|
|
26544
26575
|
if (this.intervalId) {
|
|
@@ -27584,9 +27615,7 @@ async function main() {
|
|
|
27584
27615
|
...widgetConfigItem,
|
|
27585
27616
|
line: parseInt(lineNum, 10)
|
|
27586
27617
|
});
|
|
27587
|
-
console.error("[DEBUG] Registering widget:", widget.id);
|
|
27588
27618
|
await registry.register(widget, { config: { ...widgetConfigItem } });
|
|
27589
|
-
console.error("[DEBUG] Widget registered:", widget.id, "enabled:", widget.isEnabled());
|
|
27590
27619
|
}
|
|
27591
27620
|
}
|
|
27592
27621
|
}
|
|
@@ -27613,8 +27642,7 @@ async function main() {
|
|
|
27613
27642
|
timestamp: Date.now()
|
|
27614
27643
|
});
|
|
27615
27644
|
return lines.join("\n");
|
|
27616
|
-
} catch (
|
|
27617
|
-
console.error("[claude-scope ERROR]", error);
|
|
27645
|
+
} catch (_error) {
|
|
27618
27646
|
const fallback = await tryGitFallback();
|
|
27619
27647
|
return fallback;
|
|
27620
27648
|
}
|