@goodandready/dsh-usage-guard 0.1.11 → 0.1.13
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 +56 -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,47 @@ window.__ModuleLoader__.load({
|
|
|
866
878
|
}
|
|
867
879
|
}
|
|
868
880
|
|
|
881
|
+
// Plugin-list seat (plugins.item) first: the seat the current core
|
|
882
|
+
// (0.1.6-alpha.2) renders as the plugin's own page with its configuration. The
|
|
883
|
+
// label is a static string on purpose — it is resolved while the page renders,
|
|
884
|
+
// and a locale lookup there would take the whole client batch down with it.
|
|
885
|
+
registerSlotWhenReady('plugins.item', () =>
|
|
886
|
+
ctx.slots.register(
|
|
887
|
+
{
|
|
888
|
+
name: 'plugins.item',
|
|
889
|
+
id: ROW_ID,
|
|
890
|
+
order: 60,
|
|
891
|
+
label: () => 'Usage Guard',
|
|
892
|
+
locale: NS,
|
|
893
|
+
inject: () => ({ ctx }),
|
|
894
|
+
},
|
|
895
|
+
(props) =>
|
|
896
|
+
React.createElement(
|
|
897
|
+
ErrorBoundary,
|
|
898
|
+
null,
|
|
899
|
+
React.createElement(PluginCard, { ...props, ctx: (props && props.ctx) || ctx })
|
|
900
|
+
)
|
|
901
|
+
)
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
// Row seat and the legacy seat stay as fallbacks.
|
|
905
|
+
registerSlotWhenReady('plugins.row.config', () =>
|
|
906
|
+
ctx.slots.register(
|
|
907
|
+
{
|
|
908
|
+
name: 'plugins.row.config',
|
|
909
|
+
key: ROW_CONFIG_KEY,
|
|
910
|
+
locale: NS,
|
|
911
|
+
inject: () => ({ ctx }),
|
|
912
|
+
},
|
|
913
|
+
(props) =>
|
|
914
|
+
React.createElement(
|
|
915
|
+
ErrorBoundary,
|
|
916
|
+
null,
|
|
917
|
+
React.createElement(PluginCard, { ...props, ctx: (props && props.ctx) || ctx })
|
|
918
|
+
)
|
|
919
|
+
)
|
|
920
|
+
);
|
|
921
|
+
|
|
869
922
|
registerSlotWhenReady('settings.plugin.item', () =>
|
|
870
923
|
ctx.slots.register(
|
|
871
924
|
{
|
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.13",
|
|
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",
|