@goodandready/dsh-cost-meter 0.8.3 → 0.8.5

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.
Files changed (2) hide show
  1. package/lib/client.js +34 -4
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -11,6 +11,10 @@ window.__ModuleLoader__.load({
11
11
  const h = React.createElement
12
12
 
13
13
  const NS = 'dsh-cost-meter'
14
+ // Plugins page row seat (DSH 0.1.6-alpha.2): key = '<package name>#<row id>'.
15
+ const PKG = '@goodandready/dsh-cost-meter'
16
+ const ROW_ID = 'dsh-cost-meter'
17
+ const ROW_CONFIG_KEY = PKG + '#' + ROW_ID
14
18
  const STATE_PATH = '/dsh-cost-meter/state'
15
19
  const REFRESH_PATH = '/dsh-cost-meter/refresh'
16
20
  const UPDATE_PATH = '/dsh-cost-meter/update'
@@ -439,7 +443,8 @@ window.__ModuleLoader__.load({
439
443
  const ctx = props.ctx
440
444
  const locale = useActiveLocale(ctx)
441
445
  const t = props.t || makeT(locale === 'zh' ? zh : en, en)
442
- const [open, setOpen] = React.useState(false)
446
+ const page = !!(props && props.view === 'page')
447
+ const [open, setOpen] = React.useState(!!page)
443
448
  const [draft, setDraft] = React.useState(null)
444
449
  const [saving, setSaving] = React.useState(false)
445
450
  const [err, setErr] = React.useState('')
@@ -650,9 +655,15 @@ window.__ModuleLoader__.load({
650
655
  const catalogHasErr = diagState && Boolean(diagState.catalogError)
651
656
  const openRouterEnabled = draft ? Boolean(draft.useOpenRouter) : true
652
657
 
653
- return React.createElement('li', { className: 'dcm-card' },
658
+ // Row seat (plugins.row.config): the host page draws title/icon/crumb and the
659
+ // padding, so the summary is a one-liner and the page drops our card chrome.
660
+ if (props && props.view === 'summary') {
661
+ return React.createElement('span', { className: 'dcm-sub' }, t('header.sub'))
662
+ }
663
+
664
+ return React.createElement(page ? 'div' : 'li', { className: page ? 'dcm-page' : 'dcm-card' },
654
665
  React.createElement('button', {
655
- type: 'button', className: 'dcm-head', 'aria-expanded': open,
666
+ type: 'button', className: 'dcm-head', style: page ? { display: 'none' } : undefined, 'aria-expanded': page ? true : open,
656
667
  onClick: () => setOpen((v) => !v),
657
668
  },
658
669
  React.createElement('div', { style: { flex: 1, display: 'flex', flexDirection: 'column', gap: 2 } },
@@ -675,7 +686,7 @@ window.__ModuleLoader__.load({
675
686
  ),
676
687
  React.createElement(Chevron, { open }),
677
688
  ),
678
- open ? React.createElement('div', { className: 'dcm-body' },
689
+ (page || open) ? React.createElement('div', { className: 'dcm-body' },
679
690
  status === 'loading'
680
691
  ? React.createElement('div', { className: 'dcm-hint', style: { padding: '12px 0' } }, t('settings.loading'))
681
692
  : status !== 'ready'
@@ -1396,6 +1407,25 @@ window.__ModuleLoader__.load({
1396
1407
  ),
1397
1408
  )
1398
1409
 
1410
+ // List seat (plugins.item): the seat the Plugins page renders as the plugin's
1411
+ // own page with its configuration. The label is a static string on purpose —
1412
+ // it is resolved while the page renders, and a locale lookup there would take
1413
+ // the whole client batch down with it.
1414
+ ctx.slots.inject('plugins.item', () =>
1415
+ ctx.slots.register(
1416
+ { name: 'plugins.item', id: ROW_ID, order: 20, label: () => 'Cost Meter', locale: NS, inject: () => ({ ctx }) },
1417
+ (p) => React.createElement(ErrorBoundary, null, React.createElement(CostMeterCard, { ...p, ctx: (p && p.ctx) || ctx })),
1418
+ ),
1419
+ )
1420
+
1421
+ // Row seat and the legacy seat kept as fallbacks.
1422
+ ctx.slots.inject('plugins.row.config', () =>
1423
+ ctx.slots.register(
1424
+ { name: 'plugins.row.config', key: ROW_CONFIG_KEY, locale: NS, order: 20, inject: () => ({ ctx }) },
1425
+ (p) => React.createElement(ErrorBoundary, null, React.createElement(CostMeterCard, { ...p, ctx: (p && p.ctx) || ctx })),
1426
+ ),
1427
+ )
1428
+
1399
1429
  ctx.slots.inject('settings.plugin.item', () =>
1400
1430
  ctx.slots.register(
1401
1431
  { name: 'settings.plugin.item', key: NS, locale: NS, order: 20, inject: () => ({ ctx }) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cost-meter",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "DeepSeek Harness plugin: a session cost chip in the conversation header - live token usage by bucket, peak/off-peak tariff, and a countdown to the next tariff switch.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",