claude-code-cost 1.2.1 → 1.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cost",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Cost dashboard for Claude Code usage",
5
5
  "main": "server.js",
6
6
  "type": "commonjs",
package/public/app.js CHANGED
@@ -2880,11 +2880,29 @@ const SHORTCUT_PAIRS = [
2880
2880
  title: 'Hub',
2881
2881
  hub: true,
2882
2882
  rows: [
2883
- { keys: ['Ctrl', 'Alt', '←/→'], combo: true, label: 'Previous / next hub app' },
2884
- { keys: ['Alt', '1…9'], combo: true, label: 'Jump to hub app by number' },
2885
- { keys: ['Ctrl', 'Alt', 'P'], combo: true, label: 'Project picker' },
2886
- { keys: ['Ctrl', 'Alt', 'W'], combo: true, label: 'Config dir picker' },
2887
- { keys: ['Ctrl', 'Alt', 'A'], combo: true, label: 'App launcher' },
2883
+ {
2884
+ keys: ['Ctrl', 'Alt', '←/→'],
2885
+ action: ['hub.prevApp', 'hub.nextApp'],
2886
+ combo: true,
2887
+ hubMod: true,
2888
+ label: 'Previous / next hub app',
2889
+ },
2890
+ {
2891
+ keys: ['Alt', '1…9'],
2892
+ action: 'hub.appByNumber',
2893
+ combo: true,
2894
+ hubMod: true,
2895
+ label: 'Jump to hub app by number',
2896
+ },
2897
+ { keys: ['Ctrl', 'Alt', 'P'], action: 'hub.projectPicker', combo: true, hubMod: true, label: 'Project picker' },
2898
+ {
2899
+ keys: ['Ctrl', 'Alt', 'W'],
2900
+ action: 'hub.configDirPicker',
2901
+ combo: true,
2902
+ hubMod: true,
2903
+ label: 'Config dir picker',
2904
+ },
2905
+ { keys: ['Ctrl', 'Alt', 'A'], action: 'hub.appLauncher', combo: true, hubMod: true, label: 'App launcher' },
2888
2906
  ],
2889
2907
  },
2890
2908
  ],
@@ -2892,6 +2910,21 @@ const SHORTCUT_PAIRS = [
2892
2910
 
2893
2911
  const EMPTY_GROUP = { title: '', rows: [] };
2894
2912
 
2913
+ // macOS names Control, Option and Shift by their symbols.
2914
+ const IS_MAC = /^Mac/i.test(navigator.userAgentData?.platform || navigator.platform || '');
2915
+ const MAC_KEYS = { Ctrl: '⌃', Alt: '⌥', Shift: '⇧' };
2916
+
2917
+ // The keys of a help row as they read on this system. The hub's modifier is Ctrl+Alt, and on
2918
+ // macOS Control+Option for the tab numbers too (Windows and Linux use bare Alt for those). A hub
2919
+ // row shows the keys the hub reports, which the user can change; row.keys until it answers.
2920
+ function helpKeys(row, mac = IS_MAC, keyLabel = hub.keyLabel) {
2921
+ const live = row.action && keyLabel(row.action);
2922
+ if (live) return live;
2923
+ if (!mac) return row.keys;
2924
+ if (row.hubMod) return ['⌃', '⌥', ...row.keys.filter((k) => k !== 'Ctrl' && k !== 'Alt')];
2925
+ return row.keys.map((k) => MAC_KEYS[k] || k);
2926
+ }
2927
+
2895
2928
  // Interleaves each pair's rows left-then-right so CSS grid auto-placement lands
2896
2929
  // them on shared row tracks (see .shortcuts in style.css).
2897
2930
  function buildHelpShortcuts() {
@@ -2908,9 +2941,10 @@ function buildHelpShortcuts() {
2908
2941
  for (let i = 0; i < Math.max(left.rows.length, right.rows.length); i++) {
2909
2942
  for (const [group, side] of sides) {
2910
2943
  const row = group.rows[i];
2911
- if (!row) continue;
2944
+ const parts = row && helpKeys(row);
2945
+ if (!parts?.length) continue;
2912
2946
  const sep = row.combo ? '<span class="sc-plus">+</span>' : '<span class="sc-or">/</span>';
2913
- const keys = row.keys.map((k) => `<kbd>${esc(k)}</kbd>`).join(sep);
2947
+ const keys = parts.map((k) => `<kbd>${esc(k)}</kbd>`).join(sep);
2914
2948
  const cls = side + (group.hub ? ' sc-hub' : '');
2915
2949
  cells.push(`<dt class="${esc(cls)}">${keys}</dt><dd class="${esc(cls)}">${esc(row.label)}</dd>`);
2916
2950
  }
@@ -1,18 +1,51 @@
1
- // claude-hub-sdk 1.2.0 (sha256 62c7d9f477b2). Copied by npm run sdk:sync in claude-code-hub. Do not edit.
2
- // Claude Code Hub SDK stub: what an app serves when no hub runs it. Under a hub, the hub hands the
3
- // app its real SDK (client.js) in place of this file. The API must match client.js; a test checks it.
4
- ((root) => {
1
+ // claude-hub-sdk 1.4.0 (sha256 7d559a8888ce). Copied by npm run sdk:sync in claude-code-hub. Do not edit.
2
+ // Claude Code Hub SDK: the one rule that names a key press, shared by the hub page, client.js and
3
+ // stub.js. The hub serves it to its page as /sdk/keys.js; mount() and sdk:sync put it in front of
4
+ // client.js and stub.js, so an app still loads one file.
5
+ // var, not const: the hub page and an app page each load it as a classic script, and a second
6
+ // const declaration in the same page would throw.
7
+ var ClaudeHubKeys = (() => {
5
8
  'use strict';
6
9
 
7
- // A copy of client.js comboOf(); a test checks they match.
10
+ // Modifiers in ctrl, alt, shift, meta order, joined by '+' to the key. macOS composes
11
+ // Option+<key> into a character (Option+1 is '¡', Option+P is 'π') and holding Control does not
12
+ // undo it, so e.key alone cannot name these presses there. e.code is the physical key, which is
13
+ // wrong for non-US layouts, hence only as a fallback. No fallback under AltGraph: Chromium sets it
14
+ // when AltGr types a character, and that press is text. Takes a real KeyboardEvent or a forwarded
15
+ // {key, code} payload; a payload without code degrades to key. A payload needs no AltGraph: the
16
+ // SDK forwards only a press whose key already names a bound combo.
17
+ // Self-contained on purpose: cck puts its source text into a sandboxed frame.
8
18
  function comboOf(e) {
9
19
  const lower = typeof e.key === 'string' ? e.key.toLowerCase() : '';
10
- const m = /^(?:Key|Digit)([A-Z1-9])$/.exec(e.code || '');
20
+ const m = !e.getModifierState?.('AltGraph') && /^(?:Key|Digit)([A-Z1-9])$/.exec(e.code || '');
11
21
  const key = /^[a-z1-9]$/.test(lower) ? lower : m ? m[1].toLowerCase() : e.key;
12
22
  const mods = [e.ctrlKey && 'ctrl', e.altKey && 'alt', e.shiftKey && 'shift', e.metaKey && 'meta'];
13
23
  return [...mods, key].filter(Boolean).join('+');
14
24
  }
15
25
 
26
+ // The keys of a combo as a help row shows them: ['Ctrl', 'Alt', 'P'], or ['⌃', '⌥', 'P'] on macOS.
27
+ // The {n} of a numbered combo reads 1…9.
28
+ function keyParts(combo, mac) {
29
+ const mods = mac
30
+ ? { ctrl: '⌃', alt: '⌥', shift: '⇧', meta: '⌘' }
31
+ : { ctrl: 'Ctrl', alt: 'Alt', shift: 'Shift', meta: 'Win' };
32
+ const named = { '{n}': '1…9', ArrowLeft: '←', ArrowRight: '→', ArrowUp: '↑', ArrowDown: '↓' };
33
+ return combo.split('+').map((k) => mods[k] ?? named[k] ?? (k.length === 1 ? k.toUpperCase() : k));
34
+ }
35
+
36
+ return { comboOf, keyParts };
37
+ })();
38
+
39
+ if (typeof module === 'object' && module.exports) module.exports = ClaudeHubKeys;
40
+
41
+ // Claude Code Hub SDK stub: what an app serves when no hub runs it. Under a hub, the hub hands the
42
+ // app its real SDK (client.js) in place of this file. The API must match client.js; a test checks it.
43
+ ((root) => {
44
+ 'use strict';
45
+
46
+ // keys.js comes first in the synced file. Required as a module, stub.js loads it itself.
47
+ const { comboOf } = typeof ClaudeHubKeys === 'object' ? ClaudeHubKeys : require('./keys');
48
+
16
49
  function createClaudeHub(win) {
17
50
  let hub = null;
18
51
  const off = () => {};
@@ -43,6 +76,7 @@
43
76
  can: (action) => !!standaloneFn(action),
44
77
  forwards: () => false,
45
78
  forwardCombos: () => [],
79
+ keyLabel: () => null,
46
80
  closeGuard() {},
47
81
  openExternal(url) {
48
82
  win.open(url, '_blank', 'noopener');