claude-scope 0.8.18 → 0.8.20
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 +33 -27
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -1529,24 +1529,27 @@ var init_widget_registry = __esm({
|
|
|
1529
1529
|
"src/core/widget-registry.ts"() {
|
|
1530
1530
|
"use strict";
|
|
1531
1531
|
WidgetRegistry = class {
|
|
1532
|
-
widgets =
|
|
1532
|
+
widgets = [];
|
|
1533
1533
|
/**
|
|
1534
1534
|
* Register a widget
|
|
1535
1535
|
*/
|
|
1536
1536
|
async register(widget, context) {
|
|
1537
|
-
if (this.widgets.has(widget.id)) {
|
|
1538
|
-
throw new Error(`Widget with id '${widget.id}' already registered`);
|
|
1539
|
-
}
|
|
1540
1537
|
if (context) {
|
|
1541
1538
|
await widget.initialize(context);
|
|
1542
1539
|
}
|
|
1543
|
-
this.widgets.
|
|
1540
|
+
this.widgets.push(widget);
|
|
1544
1541
|
}
|
|
1545
1542
|
/**
|
|
1546
1543
|
* Unregister a widget
|
|
1544
|
+
* @param widgetOrId Widget instance or widget id
|
|
1547
1545
|
*/
|
|
1548
|
-
async unregister(
|
|
1549
|
-
|
|
1546
|
+
async unregister(widgetOrId) {
|
|
1547
|
+
let widget;
|
|
1548
|
+
if (typeof widgetOrId === "string") {
|
|
1549
|
+
widget = this.widgets.find((w) => w.id === widgetOrId);
|
|
1550
|
+
} else {
|
|
1551
|
+
widget = this.widgets.find((w) => w === widgetOrId);
|
|
1552
|
+
}
|
|
1550
1553
|
if (!widget) {
|
|
1551
1554
|
return;
|
|
1552
1555
|
}
|
|
@@ -1555,26 +1558,29 @@ var init_widget_registry = __esm({
|
|
|
1555
1558
|
await widget.cleanup();
|
|
1556
1559
|
}
|
|
1557
1560
|
} finally {
|
|
1558
|
-
this.widgets.
|
|
1561
|
+
const index = this.widgets.indexOf(widget);
|
|
1562
|
+
if (index !== -1) {
|
|
1563
|
+
this.widgets.splice(index, 1);
|
|
1564
|
+
}
|
|
1559
1565
|
}
|
|
1560
1566
|
}
|
|
1561
1567
|
/**
|
|
1562
1568
|
* Get a widget by id
|
|
1563
1569
|
*/
|
|
1564
1570
|
get(id) {
|
|
1565
|
-
return this.widgets.
|
|
1571
|
+
return this.widgets.find((w) => w.id === id);
|
|
1566
1572
|
}
|
|
1567
1573
|
/**
|
|
1568
1574
|
* Check if widget is registered
|
|
1569
1575
|
*/
|
|
1570
1576
|
has(id) {
|
|
1571
|
-
return this.widgets.
|
|
1577
|
+
return this.widgets.some((w) => w.id === id);
|
|
1572
1578
|
}
|
|
1573
1579
|
/**
|
|
1574
1580
|
* Get all registered widgets
|
|
1575
1581
|
*/
|
|
1576
1582
|
getAll() {
|
|
1577
|
-
return
|
|
1583
|
+
return [...this.widgets];
|
|
1578
1584
|
}
|
|
1579
1585
|
/**
|
|
1580
1586
|
* Get only enabled widgets
|
|
@@ -1586,12 +1592,12 @@ var init_widget_registry = __esm({
|
|
|
1586
1592
|
* Clear all widgets
|
|
1587
1593
|
*/
|
|
1588
1594
|
async clear() {
|
|
1589
|
-
for (const widget of this.widgets
|
|
1595
|
+
for (const widget of this.widgets) {
|
|
1590
1596
|
if (widget.cleanup) {
|
|
1591
1597
|
await widget.cleanup();
|
|
1592
1598
|
}
|
|
1593
1599
|
}
|
|
1594
|
-
this.widgets
|
|
1600
|
+
this.widgets = [];
|
|
1595
1601
|
}
|
|
1596
1602
|
};
|
|
1597
1603
|
}
|
|
@@ -8082,6 +8088,9 @@ async function ensureDefaultConfig() {
|
|
|
8082
8088
|
|
|
8083
8089
|
// src/config/config-loader.ts
|
|
8084
8090
|
function getConfigPath() {
|
|
8091
|
+
if (process.env.CLAUDE_SCOPE_CONFIG) {
|
|
8092
|
+
return process.env.CLAUDE_SCOPE_CONFIG;
|
|
8093
|
+
}
|
|
8085
8094
|
return (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".claude-scope", "config.json");
|
|
8086
8095
|
}
|
|
8087
8096
|
async function loadWidgetConfig() {
|
|
@@ -9079,18 +9088,12 @@ async function readStdin() {
|
|
|
9079
9088
|
}
|
|
9080
9089
|
return Buffer.concat(chunks).toString("utf8");
|
|
9081
9090
|
}
|
|
9082
|
-
function applyWidgetConfig(widget,
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
}
|
|
9089
|
-
if (typeof widget.setLine === "function") {
|
|
9090
|
-
widget.setLine(parseInt(lineNum, 10));
|
|
9091
|
-
}
|
|
9092
|
-
break;
|
|
9093
|
-
}
|
|
9091
|
+
function applyWidgetConfig(widget, widgetConfig) {
|
|
9092
|
+
if (typeof widget.setStyle === "function" && isValidWidgetStyle(widgetConfig.style)) {
|
|
9093
|
+
widget.setStyle(widgetConfig.style);
|
|
9094
|
+
}
|
|
9095
|
+
if (typeof widget.setLine === "function" && typeof widgetConfig.line === "number") {
|
|
9096
|
+
widget.setLine(widgetConfig.line);
|
|
9094
9097
|
}
|
|
9095
9098
|
}
|
|
9096
9099
|
async function main() {
|
|
@@ -9111,11 +9114,14 @@ async function main() {
|
|
|
9111
9114
|
const widgetConfig = await loadWidgetConfig();
|
|
9112
9115
|
const factory = new WidgetFactory();
|
|
9113
9116
|
if (widgetConfig) {
|
|
9114
|
-
for (const [
|
|
9117
|
+
for (const [lineNum, widgets] of Object.entries(widgetConfig.lines)) {
|
|
9115
9118
|
for (const widgetConfigItem of widgets) {
|
|
9116
9119
|
const widget = factory.createWidget(widgetConfigItem.id);
|
|
9117
9120
|
if (widget) {
|
|
9118
|
-
applyWidgetConfig(widget,
|
|
9121
|
+
applyWidgetConfig(widget, {
|
|
9122
|
+
...widgetConfigItem,
|
|
9123
|
+
line: parseInt(lineNum, 10)
|
|
9124
|
+
});
|
|
9119
9125
|
await registry.register(widget);
|
|
9120
9126
|
}
|
|
9121
9127
|
}
|