@goodandready/dsh-usage-guard 0.1.11 → 0.1.12
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/lib/client.js +32 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -5,6 +5,10 @@ window.__ModuleLoader__.load({
|
|
|
5
5
|
const module = { exports: {} };
|
|
6
6
|
const React = require('react');
|
|
7
7
|
const NS = 'dsh-usage-guard';
|
|
8
|
+
// Plugins page row seat (DSH 0.1.6-alpha.2): key = '<package name>#<row id>'.
|
|
9
|
+
const PKG = '@goodandready/dsh-usage-guard';
|
|
10
|
+
const ROW_ID = 'dsh-usage-guard';
|
|
11
|
+
const ROW_CONFIG_KEY = PKG + '#' + ROW_ID;
|
|
8
12
|
|
|
9
13
|
const en = {
|
|
10
14
|
title: 'Usage Guard',
|
|
@@ -716,7 +720,8 @@ window.__ModuleLoader__.load({
|
|
|
716
720
|
|
|
717
721
|
// Accordion PluginCard for settings.plugin.item
|
|
718
722
|
function PluginCard(props) {
|
|
719
|
-
const
|
|
723
|
+
const page = !!(props && props.view === 'page');
|
|
724
|
+
const [open, setOpen] = React.useState(!!page);
|
|
720
725
|
const hostCtx = (props && props.ctx) || ctx;
|
|
721
726
|
const locale = getActiveLocale(hostCtx);
|
|
722
727
|
const dict = locale === 'zh' ? zh : en;
|
|
@@ -726,18 +731,25 @@ window.__ModuleLoader__.load({
|
|
|
726
731
|
ensureCss();
|
|
727
732
|
}, []);
|
|
728
733
|
|
|
734
|
+
// Row seat (plugins.row.config): the host page draws title/icon/crumb and the
|
|
735
|
+
// padding, so the summary is a one-liner and the page drops our card chrome.
|
|
736
|
+
if (props && props.view === 'summary') {
|
|
737
|
+
return React.createElement('span', { className: 'ug-sub' }, t('title'));
|
|
738
|
+
}
|
|
739
|
+
|
|
729
740
|
const isRepairActive = props?.repair !== false;
|
|
730
741
|
const badgeText = isRepairActive ? t('badge_active') : t('badge_report_only');
|
|
731
742
|
const badgeClass = isRepairActive ? 'ug-badge ug-badge-ok' : 'ug-badge ug-badge-warn';
|
|
732
743
|
|
|
733
744
|
return React.createElement(
|
|
734
|
-
'li',
|
|
735
|
-
{ className: 'ug-section-card' },
|
|
745
|
+
page ? 'div' : 'li',
|
|
746
|
+
{ className: page ? 'ug-page' : 'ug-section-card' },
|
|
736
747
|
React.createElement(
|
|
737
748
|
'button',
|
|
738
749
|
{
|
|
739
750
|
type: 'button',
|
|
740
751
|
className: 'ug-head-btn',
|
|
752
|
+
style: page ? { display: 'none' } : undefined,
|
|
741
753
|
'aria-expanded': open,
|
|
742
754
|
onClick: () => setOpen((v) => !v),
|
|
743
755
|
},
|
|
@@ -866,6 +878,23 @@ window.__ModuleLoader__.load({
|
|
|
866
878
|
}
|
|
867
879
|
}
|
|
868
880
|
|
|
881
|
+
registerSlotWhenReady('plugins.row.config', () =>
|
|
882
|
+
ctx.slots.register(
|
|
883
|
+
{
|
|
884
|
+
name: 'plugins.row.config',
|
|
885
|
+
key: ROW_CONFIG_KEY,
|
|
886
|
+
locale: NS,
|
|
887
|
+
inject: () => ({ ctx }),
|
|
888
|
+
},
|
|
889
|
+
(props) =>
|
|
890
|
+
React.createElement(
|
|
891
|
+
ErrorBoundary,
|
|
892
|
+
null,
|
|
893
|
+
React.createElement(PluginCard, { ...props, ctx: (props && props.ctx) || ctx })
|
|
894
|
+
)
|
|
895
|
+
)
|
|
896
|
+
);
|
|
897
|
+
|
|
869
898
|
registerSlotWhenReady('settings.plugin.item', () =>
|
|
870
899
|
ctx.slots.register(
|
|
871
900
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-usage-guard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Keeps a malformed token-usage sample from taking a whole session history down with it: a missing or non-numeric counter becomes zero before the harness adds it up, so the fold never yields NaN and already-broken sessions open again.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|