tokmon 0.22.2 → 0.22.4
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/README.md +4 -1
- package/dist/{bootstrap-ink-F7P7Q5J4.js → bootstrap-ink-XN72OM2A.js} +23 -10
- package/dist/{chunk-RA3SCIG6.js → chunk-LIWHVHDE.js} +2 -2
- package/dist/{chunk-FLLNU6BN.js → chunk-QKF3PKYX.js} +2 -23
- package/dist/{chunk-E25RUTXB.js → chunk-QTHCHB7S.js} +100 -19
- package/dist/cli.js +4 -4
- package/dist/{config-F7TY5ZFA.js → config-64N7KBZ7.js} +3 -1
- package/dist/{daemon-A3NSDSPZ.js → daemon-FHPB5HDQ.js} +3 -3
- package/dist/server-W3JHUDAN.js +9 -0
- package/dist/web/assets/{breakdown-C3Zqnewe.js → breakdown-UyMKAeuQ.js} +1 -1
- package/dist/web/assets/{index-BkdjevbO.js → index-sJqh08RC.js} +67 -67
- package/dist/web/assets/{timeline-C2vHjZJ3.js → timeline-pvwrpASn.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/server-P7T4ZMC6.js +0 -9
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ The dashboard is a prebuilt static bundle shipped in the package — no build st
|
|
|
129
129
|
| scroll / `↑` `↓` / `[` `]` | (Dashboard) move between pages when paginated |
|
|
130
130
|
| `a` `A` | Cycle account focus forward / back |
|
|
131
131
|
| `0`–`9` | Jump to an account focus slot |
|
|
132
|
+
| `p` | Toggle privacy mode (configurable in settings) |
|
|
132
133
|
| `w` `W` | Toggle the web dashboard (opens in your browser) |
|
|
133
134
|
| `s` | Open settings |
|
|
134
135
|
| `q` | Quit |
|
|
@@ -137,7 +138,7 @@ The dashboard is a prebuilt static bundle shipped in the package — no build st
|
|
|
137
138
|
|
|
138
139
|
| Key | Action |
|
|
139
140
|
|-----|--------|
|
|
140
|
-
| `
|
|
141
|
+
| `P` | Cycle provider back |
|
|
141
142
|
| `/` | Search (Esc clears) |
|
|
142
143
|
| `o` | Cycle sort |
|
|
143
144
|
| `d` `w` `m` | Daily / Weekly / Monthly *(Claude/Codex)* |
|
|
@@ -169,6 +170,8 @@ Press `s` to open.
|
|
|
169
170
|
- **Refresh interval** — dashboard poll rate (default: 2s)
|
|
170
171
|
- **Billing poll** — rate-limit / spend API poll rate (default: 5m, min 1m to avoid rate limiting)
|
|
171
172
|
- **Clear screen** — clears the terminal on launch (like `watch`)
|
|
173
|
+
- **Privacy mode** — hides email addresses by default
|
|
174
|
+
- **Privacy key** — one-key dashboard toggle for privacy mode (default: `p`)
|
|
172
175
|
- **Timezone** — IANA timezone, or `System`
|
|
173
176
|
- **Dashboard layout** — `grid` (all providers at once) or `single` (one at a time)
|
|
174
177
|
- **Default focus** — start on `all`, or remember your `last` focused account
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
systemTimezone,
|
|
20
20
|
time,
|
|
21
21
|
tokens
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QKF3PKYX.js";
|
|
23
23
|
import {
|
|
24
24
|
COLOR_PALETTE,
|
|
25
25
|
DEFAULTS,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
sanitizeTyped,
|
|
35
35
|
saveConfigSync,
|
|
36
36
|
snapshotCacheFile
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-QTHCHB7S.js";
|
|
38
38
|
import {
|
|
39
39
|
glyphs
|
|
40
40
|
} from "./chunk-RF4GGQGM.js";
|
|
@@ -564,7 +564,7 @@ import { Box as Box4, Text as Text4 } from "ink";
|
|
|
564
564
|
import { memo as memo3 } from "react";
|
|
565
565
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
566
566
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
567
|
-
var GENERAL_ROWS =
|
|
567
|
+
var GENERAL_ROWS = 8;
|
|
568
568
|
var SETTINGS_TABS = ["general", "providers", "accounts"];
|
|
569
569
|
var SETTINGS_TAB_LABELS = {
|
|
570
570
|
general: "General",
|
|
@@ -627,16 +627,17 @@ var SettingsView = memo3(function SettingsView2({
|
|
|
627
627
|
] }),
|
|
628
628
|
/* @__PURE__ */ jsx3(Row, { cursor, idx: 2, label: "Clear screen", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: config.clearScreen ? "green" : "red", children: config.clearScreen ? "on" : "off" }) }),
|
|
629
629
|
/* @__PURE__ */ jsx3(Row, { cursor, idx: 3, label: "Privacy mode", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: config.privacyMode ? "green" : "red", children: config.privacyMode ? "on" : "off" }) }),
|
|
630
|
-
/* @__PURE__ */ jsx3(Row, { cursor, idx: 4, label: "
|
|
630
|
+
/* @__PURE__ */ jsx3(Row, { cursor, idx: 4, label: "Privacy key", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: "yellow", children: config.privacyToggleKey === " " ? "space" : config.privacyToggleKey }) }),
|
|
631
|
+
/* @__PURE__ */ jsx3(Row, { cursor, idx: 5, label: "Timezone", children: editingTz ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
631
632
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[" }),
|
|
632
633
|
/* @__PURE__ */ jsx3(CaretText, { value: tzEdit ?? "", caret: tzCaret, color: "cyan" }),
|
|
633
634
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "]" })
|
|
634
635
|
] }) : /* @__PURE__ */ jsx3(Text3, { bold: true, color: "yellow", children: tzDisplay }) }),
|
|
635
|
-
cursor ===
|
|
636
|
+
cursor === 5 && tzError && /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
|
|
636
637
|
" ",
|
|
637
638
|
tzError
|
|
638
639
|
] }),
|
|
639
|
-
/* @__PURE__ */ jsxs3(Row, { cursor, idx:
|
|
640
|
+
/* @__PURE__ */ jsxs3(Row, { cursor, idx: 6, label: "Dashboard", children: [
|
|
640
641
|
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
641
642
|
glyphs().caretL,
|
|
642
643
|
" "
|
|
@@ -647,7 +648,7 @@ var SettingsView = memo3(function SettingsView2({
|
|
|
647
648
|
glyphs().caretR
|
|
648
649
|
] })
|
|
649
650
|
] }),
|
|
650
|
-
/* @__PURE__ */ jsxs3(Row, { cursor, idx:
|
|
651
|
+
/* @__PURE__ */ jsxs3(Row, { cursor, idx: 7, label: "Default focus", children: [
|
|
651
652
|
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
652
653
|
glyphs().caretL,
|
|
653
654
|
" "
|
|
@@ -2480,6 +2481,14 @@ function handleKey(input, key, ctx) {
|
|
|
2480
2481
|
return;
|
|
2481
2482
|
}
|
|
2482
2483
|
if (settingsCursor === 4) {
|
|
2484
|
+
if (isPrintable(input, key)) {
|
|
2485
|
+
const clean = sanitizeTyped(input);
|
|
2486
|
+
if (clean.length === 1) updateConfig((c) => ({ ...c, privacyToggleKey: clean }));
|
|
2487
|
+
}
|
|
2488
|
+
if (key.backspace || key.delete) updateConfig((c) => ({ ...c, privacyToggleKey: "p" }));
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
if (settingsCursor === 5) {
|
|
2483
2492
|
if (key.return) {
|
|
2484
2493
|
const init = cfg.timezone ?? "";
|
|
2485
2494
|
setTzEdit(init);
|
|
@@ -2489,11 +2498,11 @@ function handleKey(input, key, ctx) {
|
|
|
2489
2498
|
if (key.leftArrow || key.rightArrow) updateConfig((c) => ({ ...c, timezone: c.timezone === null ? systemTimezone() : null }));
|
|
2490
2499
|
return;
|
|
2491
2500
|
}
|
|
2492
|
-
if (settingsCursor ===
|
|
2501
|
+
if (settingsCursor === 6 && (key.leftArrow || key.rightArrow || key.return)) {
|
|
2493
2502
|
updateConfig((c) => ({ ...c, dashboardLayout: c.dashboardLayout === "grid" ? "single" : "grid" }));
|
|
2494
2503
|
return;
|
|
2495
2504
|
}
|
|
2496
|
-
if (settingsCursor ===
|
|
2505
|
+
if (settingsCursor === 7 && (key.leftArrow || key.rightArrow || key.return)) {
|
|
2497
2506
|
updateConfig((c) => ({ ...c, defaultFocus: c.defaultFocus === "all" ? "last" : "all" }));
|
|
2498
2507
|
return;
|
|
2499
2508
|
}
|
|
@@ -2531,6 +2540,10 @@ function handleKey(input, key, ctx) {
|
|
|
2531
2540
|
}
|
|
2532
2541
|
return;
|
|
2533
2542
|
}
|
|
2543
|
+
if (input === cfg.privacyToggleKey) {
|
|
2544
|
+
updateConfig((c) => ({ ...c, privacyMode: !c.privacyMode }));
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2534
2547
|
if (input === "s") {
|
|
2535
2548
|
setSettingsTab("general");
|
|
2536
2549
|
setShowSettings(true);
|
|
@@ -3413,7 +3426,7 @@ function App({ interval: cliInterval, initialConfig, baseUrl = null, wsToken = n
|
|
|
3413
3426
|
if (webStartingRef.current) return;
|
|
3414
3427
|
webStartingRef.current = true;
|
|
3415
3428
|
try {
|
|
3416
|
-
const { startWebServer } = await import("./server-
|
|
3429
|
+
const { startWebServer } = await import("./server-W3JHUDAN.js");
|
|
3417
3430
|
const ctrl = await startWebServer({ config: cfg, log: false });
|
|
3418
3431
|
webRef.current = ctrl;
|
|
3419
3432
|
openUrl(ctrl.url);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fetchPeak,
|
|
11
11
|
namedHex,
|
|
12
12
|
resolveTimezone
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QKF3PKYX.js";
|
|
14
14
|
import {
|
|
15
15
|
cacheDir,
|
|
16
16
|
expandHome,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
normalizeConfig,
|
|
19
19
|
saveConfig,
|
|
20
20
|
snapshotCacheFile
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-QTHCHB7S.js";
|
|
22
22
|
|
|
23
23
|
// src/web/server.ts
|
|
24
24
|
import { createServer } from "http";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
expandHome,
|
|
7
7
|
isValidTimezone,
|
|
8
8
|
slugify
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QTHCHB7S.js";
|
|
10
10
|
|
|
11
11
|
// src/providers/usage-core.ts
|
|
12
12
|
import { readFile, writeFile, rename, mkdir, readdir, unlink } from "fs/promises";
|
|
@@ -3877,29 +3877,8 @@ var RefreshScopeSchema = Schema.Literals([
|
|
|
3877
3877
|
"billing",
|
|
3878
3878
|
"peak"
|
|
3879
3879
|
]);
|
|
3880
|
-
var ProviderIdSchema = Schema.Literals(PROVIDER_IDS);
|
|
3881
|
-
var AccountSchema = Schema.Struct({
|
|
3882
|
-
id: Schema.String,
|
|
3883
|
-
providerId: ProviderIdSchema,
|
|
3884
|
-
name: Schema.String,
|
|
3885
|
-
homeDir: Schema.String,
|
|
3886
|
-
color: Schema.optionalKey(Schema.String)
|
|
3887
|
-
});
|
|
3888
3880
|
var jsonSafePassthrough = () => Schema.Unknown;
|
|
3889
|
-
var ConfigSchema =
|
|
3890
|
-
interval: Schema.Number,
|
|
3891
|
-
billingInterval: Schema.Number,
|
|
3892
|
-
clearScreen: Schema.Boolean,
|
|
3893
|
-
timezone: Schema.NullOr(Schema.String),
|
|
3894
|
-
accounts: Schema.mutable(Schema.Array(AccountSchema)),
|
|
3895
|
-
activeAccountId: Schema.NullOr(Schema.String),
|
|
3896
|
-
disabledProviders: Schema.mutable(Schema.Array(ProviderIdSchema)),
|
|
3897
|
-
onboarded: Schema.Boolean,
|
|
3898
|
-
dashboardLayout: Schema.Literals(["grid", "single"]),
|
|
3899
|
-
defaultFocus: Schema.Literals(["all", "last"]),
|
|
3900
|
-
ascii: Schema.Literals(["auto", "on", "off"]),
|
|
3901
|
-
knownProviders: Schema.mutable(Schema.Array(ProviderIdSchema))
|
|
3902
|
-
});
|
|
3881
|
+
var ConfigSchema = jsonSafePassthrough();
|
|
3903
3882
|
var ConfigResultSchema = jsonSafePassthrough();
|
|
3904
3883
|
var FsEntrySchema = Schema.Struct({
|
|
3905
3884
|
name: Schema.String,
|
|
@@ -15,6 +15,7 @@ var DEFAULTS = {
|
|
|
15
15
|
billingInterval: 5,
|
|
16
16
|
clearScreen: true,
|
|
17
17
|
privacyMode: true,
|
|
18
|
+
privacyToggleKey: "p",
|
|
18
19
|
timezone: null,
|
|
19
20
|
accounts: [],
|
|
20
21
|
activeAccountId: null,
|
|
@@ -129,25 +130,97 @@ function isValidTimezone(tz) {
|
|
|
129
130
|
return false;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
function isRecord(value) {
|
|
134
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
135
|
+
}
|
|
136
|
+
function validProvider(value) {
|
|
137
|
+
return PROVIDER_IDS.includes(value);
|
|
138
|
+
}
|
|
139
|
+
function sameJson(a, b) {
|
|
140
|
+
try {
|
|
141
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function repairConfig(input) {
|
|
147
|
+
const reasons = [];
|
|
148
|
+
const parsed = isRecord(input) ? input : {};
|
|
149
|
+
if (parsed !== input) reasons.push("config root was not an object");
|
|
150
|
+
const rawAccounts = Array.isArray(parsed.accounts) ? parsed.accounts : [];
|
|
151
|
+
if (!Array.isArray(parsed.accounts) && parsed.accounts !== void 0) reasons.push("accounts was not an array");
|
|
152
|
+
const accounts = [];
|
|
153
|
+
const accountIds = /* @__PURE__ */ new Set();
|
|
154
|
+
rawAccounts.forEach((raw, index) => {
|
|
155
|
+
if (!isRecord(raw)) {
|
|
156
|
+
reasons.push(`accounts[${index}] was not an object`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const providerId = raw.providerId ?? "claude";
|
|
160
|
+
if (!validProvider(providerId)) {
|
|
161
|
+
reasons.push(`accounts[${index}].providerId was invalid`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const id = typeof raw.id === "string" && raw.id.trim() ? raw.id.trim() : "";
|
|
165
|
+
const name = typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : "";
|
|
166
|
+
if (!id || !name) {
|
|
167
|
+
reasons.push(`accounts[${index}] was missing id or name`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (accountIds.has(id)) {
|
|
171
|
+
reasons.push(`accounts[${index}].id was duplicated`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
accountIds.add(id);
|
|
175
|
+
accounts.push({
|
|
176
|
+
id,
|
|
177
|
+
providerId,
|
|
178
|
+
name,
|
|
179
|
+
homeDir: typeof raw.homeDir === "string" && raw.homeDir.trim() ? raw.homeDir : "~",
|
|
180
|
+
...typeof raw.color === "string" && raw.color.trim() ? { color: raw.color } : {}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
const disabledProviders = (Array.isArray(parsed.disabledProviders) ? parsed.disabledProviders : []).filter(validProvider);
|
|
184
|
+
if (parsed.disabledProviders !== void 0 && !Array.isArray(parsed.disabledProviders)) {
|
|
185
|
+
reasons.push("disabledProviders was not an array");
|
|
186
|
+
}
|
|
187
|
+
const knownProviders = Array.isArray(parsed.knownProviders) ? parsed.knownProviders.filter(validProvider) : parsed.onboarded === true ? [...LEGACY_KNOWN] : [];
|
|
188
|
+
if (parsed.knownProviders !== void 0 && !Array.isArray(parsed.knownProviders)) {
|
|
189
|
+
reasons.push("knownProviders was not an array");
|
|
190
|
+
}
|
|
191
|
+
const activeAccountId = typeof parsed.activeAccountId === "string" && (accountIds.has(parsed.activeAccountId) || PROVIDER_IDS.includes(parsed.activeAccountId)) ? parsed.activeAccountId : null;
|
|
192
|
+
if (parsed.activeAccountId !== void 0 && parsed.activeAccountId !== null && activeAccountId === null) {
|
|
193
|
+
reasons.push("activeAccountId did not match a known account/provider");
|
|
194
|
+
}
|
|
195
|
+
const timezone = typeof parsed.timezone === "string" && parsed.timezone.trim() && isValidTimezone(parsed.timezone.trim()) ? parsed.timezone.trim() : null;
|
|
196
|
+
if (parsed.timezone !== void 0 && parsed.timezone !== null && timezone === null) {
|
|
197
|
+
reasons.push("timezone was invalid");
|
|
198
|
+
}
|
|
199
|
+
const config = {
|
|
200
|
+
...DEFAULTS,
|
|
201
|
+
interval: clampNum(parsed.interval, DEFAULTS.interval, 1),
|
|
202
|
+
billingInterval: clampNum(parsed.billingInterval, DEFAULTS.billingInterval, 1),
|
|
203
|
+
clearScreen: typeof parsed.clearScreen === "boolean" ? parsed.clearScreen : DEFAULTS.clearScreen,
|
|
204
|
+
privacyMode: typeof parsed.privacyMode === "boolean" ? parsed.privacyMode : DEFAULTS.privacyMode,
|
|
205
|
+
privacyToggleKey: typeof parsed.privacyToggleKey === "string" && parsed.privacyToggleKey.length === 1 ? parsed.privacyToggleKey : DEFAULTS.privacyToggleKey,
|
|
206
|
+
timezone,
|
|
207
|
+
accounts,
|
|
208
|
+
activeAccountId,
|
|
209
|
+
disabledProviders,
|
|
210
|
+
onboarded: parsed.onboarded === true,
|
|
211
|
+
dashboardLayout: parsed.dashboardLayout === "single" ? "single" : "grid",
|
|
212
|
+
defaultFocus: parsed.defaultFocus === "last" ? "last" : "all",
|
|
213
|
+
ascii: parsed.ascii === "on" ? "on" : parsed.ascii === "off" ? "off" : "auto",
|
|
214
|
+
knownProviders
|
|
215
|
+
};
|
|
216
|
+
for (const key of Object.keys(DEFAULTS)) {
|
|
217
|
+
if (!(key in parsed)) reasons.push(`missing ${key}`);
|
|
218
|
+
}
|
|
219
|
+
return { config, repaired: reasons.length > 0 || !sameJson(parsed, config), reasons };
|
|
220
|
+
}
|
|
132
221
|
function normalizeConfig(parsed) {
|
|
133
222
|
try {
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
...DEFAULTS,
|
|
137
|
-
interval: clampNum(parsed.interval, DEFAULTS.interval, 1),
|
|
138
|
-
billingInterval: clampNum(parsed.billingInterval, DEFAULTS.billingInterval, 1),
|
|
139
|
-
clearScreen: typeof parsed.clearScreen === "boolean" ? parsed.clearScreen : DEFAULTS.clearScreen,
|
|
140
|
-
privacyMode: typeof parsed.privacyMode === "boolean" ? parsed.privacyMode : DEFAULTS.privacyMode,
|
|
141
|
-
timezone: typeof parsed.timezone === "string" && parsed.timezone.trim() && isValidTimezone(parsed.timezone.trim()) ? parsed.timezone.trim() : null,
|
|
142
|
-
accounts,
|
|
143
|
-
activeAccountId: typeof parsed.activeAccountId === "string" ? parsed.activeAccountId : null,
|
|
144
|
-
disabledProviders: (Array.isArray(parsed.disabledProviders) ? parsed.disabledProviders : []).filter((p) => PROVIDER_IDS.includes(p)),
|
|
145
|
-
onboarded: parsed.onboarded === true,
|
|
146
|
-
dashboardLayout: parsed.dashboardLayout === "single" ? "single" : "grid",
|
|
147
|
-
defaultFocus: parsed.defaultFocus === "last" ? "last" : "all",
|
|
148
|
-
ascii: parsed.ascii === "on" ? "on" : parsed.ascii === "off" ? "off" : "auto",
|
|
149
|
-
knownProviders: Array.isArray(parsed.knownProviders) ? parsed.knownProviders.filter((p) => PROVIDER_IDS.includes(p)) : parsed.onboarded === true ? [...LEGACY_KNOWN] : []
|
|
150
|
-
};
|
|
223
|
+
return repairConfig(parsed).config;
|
|
151
224
|
} catch {
|
|
152
225
|
return { ...DEFAULTS };
|
|
153
226
|
}
|
|
@@ -220,11 +293,18 @@ async function loadConfig() {
|
|
|
220
293
|
}
|
|
221
294
|
return { ...DEFAULTS };
|
|
222
295
|
}
|
|
223
|
-
|
|
296
|
+
const repaired = repairConfig(parsed);
|
|
297
|
+
if (repaired.repaired) {
|
|
298
|
+
try {
|
|
299
|
+
await saveConfig(repaired.config);
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return repaired.config;
|
|
224
304
|
}
|
|
225
305
|
var saveQueue = Promise.resolve();
|
|
226
306
|
function configJson(config) {
|
|
227
|
-
return JSON.stringify(config, null, 2) + "\n";
|
|
307
|
+
return JSON.stringify(normalizeConfig(config), null, 2) + "\n";
|
|
228
308
|
}
|
|
229
309
|
function saveConfig(config) {
|
|
230
310
|
saveQueue = saveQueue.then(async () => {
|
|
@@ -271,6 +351,7 @@ export {
|
|
|
271
351
|
getTrackedAccountRows,
|
|
272
352
|
clampNum,
|
|
273
353
|
isValidTimezone,
|
|
354
|
+
repairConfig,
|
|
274
355
|
normalizeConfig,
|
|
275
356
|
slugify,
|
|
276
357
|
generateAccountId,
|
package/dist/cli.js
CHANGED
|
@@ -14,12 +14,12 @@ process.emitWarning = ((warning, ...rest) => {
|
|
|
14
14
|
var args = process.argv.slice(2);
|
|
15
15
|
var subcommand = args[0]?.toLowerCase();
|
|
16
16
|
if (subcommand === "__daemon") {
|
|
17
|
-
const { runDaemon } = await import("./daemon-
|
|
17
|
+
const { runDaemon } = await import("./daemon-FHPB5HDQ.js");
|
|
18
18
|
await runDaemon(args.slice(1), { foreground: false });
|
|
19
19
|
process.exit(typeof process.exitCode === "number" ? process.exitCode : 0);
|
|
20
20
|
}
|
|
21
21
|
if (subcommand === "serve" || subcommand === "web") {
|
|
22
|
-
const { runDaemon } = await import("./daemon-
|
|
22
|
+
const { runDaemon } = await import("./daemon-FHPB5HDQ.js");
|
|
23
23
|
await runDaemon(args.slice(1), { foreground: true });
|
|
24
24
|
process.exit(typeof process.exitCode === "number" ? process.exitCode : 0);
|
|
25
25
|
}
|
|
@@ -54,7 +54,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
54
54
|
process.exit(0);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
var { loadConfig } = await import("./config-
|
|
57
|
+
var { loadConfig } = await import("./config-64N7KBZ7.js");
|
|
58
58
|
var { resolveGlyphs, setGlyphs } = await import("./glyphs-NKCSZLGO.js");
|
|
59
59
|
var { attachOrSpawn } = await import("./daemon-handle-HLSKLMWU.js");
|
|
60
60
|
var config = await loadConfig();
|
|
@@ -68,5 +68,5 @@ setGlyphs(resolveGlyphs({
|
|
|
68
68
|
}));
|
|
69
69
|
var daemon = await attachOrSpawn();
|
|
70
70
|
var mode = daemon.kind === "spawned" ? "connected" : "degraded";
|
|
71
|
-
var { bootstrapInk } = await import("./bootstrap-ink-
|
|
71
|
+
var { bootstrapInk } = await import("./bootstrap-ink-XN72OM2A.js");
|
|
72
72
|
await bootstrapInk({ interval, config, daemon, mode });
|
|
@@ -18,12 +18,13 @@ import {
|
|
|
18
18
|
normalizeConfig,
|
|
19
19
|
pickAccentColor,
|
|
20
20
|
redactEmail,
|
|
21
|
+
repairConfig,
|
|
21
22
|
sanitizeTyped,
|
|
22
23
|
saveConfig,
|
|
23
24
|
saveConfigSync,
|
|
24
25
|
slugify,
|
|
25
26
|
snapshotCacheFile
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-QTHCHB7S.js";
|
|
27
28
|
export {
|
|
28
29
|
ACCENT_COLORS,
|
|
29
30
|
COLOR_PALETTE,
|
|
@@ -43,6 +44,7 @@ export {
|
|
|
43
44
|
normalizeConfig,
|
|
44
45
|
pickAccentColor,
|
|
45
46
|
redactEmail,
|
|
47
|
+
repairConfig,
|
|
46
48
|
sanitizeTyped,
|
|
47
49
|
saveConfig,
|
|
48
50
|
saveConfigSync,
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
appVersion,
|
|
4
4
|
startWebServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LIWHVHDE.js";
|
|
6
6
|
import {
|
|
7
7
|
flushDisk
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QKF3PKYX.js";
|
|
9
9
|
import {
|
|
10
10
|
cacheDir,
|
|
11
11
|
loadConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QTHCHB7S.js";
|
|
13
13
|
|
|
14
14
|
// src/web/open.ts
|
|
15
15
|
import { spawn } from "child_process";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as I,k as h,l as k,n as Qe,o as xt,p as Ye,q as Je,t as At,v as C,w as Oe,x as S,y as _,z as et,B as Pe,D as tt,r as J,F as kt,H as Ot,I as z,J as F,K as Pt,M as jt,N as _t,O as De,Q as wt,U as M,V as je,W as Tt,Z as St,_ as ae,$ as Et,a0 as _e,a1 as Rt,a2 as re,a3 as Be,g as nt,X as we,Y as Te,a4 as Se,f as It,a5 as Nt,u as Ee,a6 as rt,j as u,P as fe,E as pe,C as Re,R as Ie,a as it,G as at,d as ot,c as se,a7 as ee,T as st,h as G,a8 as W,a9 as ct,aa as Lt,ab as ie,s as Ne}from"./index-
|
|
1
|
+
import{i as I,k as h,l as k,n as Qe,o as xt,p as Ye,q as Je,t as At,v as C,w as Oe,x as S,y as _,z as et,B as Pe,D as tt,r as J,F as kt,H as Ot,I as z,J as F,K as Pt,M as jt,N as _t,O as De,Q as wt,U as M,V as je,W as Tt,Z as St,_ as ae,$ as Et,a0 as _e,a1 as Rt,a2 as re,a3 as Be,g as nt,X as we,Y as Te,a4 as Se,f as It,a5 as Nt,u as Ee,a6 as rt,j as u,P as fe,E as pe,C as Re,R as Ie,a as it,G as at,d as ot,c as se,a7 as ee,T as st,h as G,a8 as W,a9 as ct,aa as Lt,ab as ie,s as Ne}from"./index-sJqh08RC.js";var $t=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},V.apply(this,arguments)}function Ct(n,e){if(n==null)return{};var r=Dt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Dt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function Ke(n){return Mt(n)||Ft(n)||Kt(n)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kt(n,e){if(n){if(typeof n=="string")return be(n,e);var r=Object.prototype.toString.call(n).slice(8,-1);if(r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set")return Array.from(n);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return be(n,e)}}function Ft(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Mt(n){if(Array.isArray(n))return be(n)}function be(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=n[r];return t}var Fe=function(e){return e&&e.x===+e.x&&e.y===+e.y},Vt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(t){Fe(t)?r[r.length-1].push(t):r[r.length-1].length>0&&r.push([])}),Fe(e[0])&&r[r.length-1].push(e[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Q=function(e,r){var t=Vt(e);r&&(t=[t.reduce(function(a,o){return[].concat(Ke(a),Ke(o))},[])]);var i=t.map(function(a){return a.reduce(function(o,c,f){return"".concat(o).concat(f===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return t.length===1?"".concat(i,"Z"):i},qt=function(e,r,t){var i=Q(e,t);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Q(r.reverse(),t).slice(1))},zt=function(e){var r=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=Ct(e,$t);if(!r||!r.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=qt(r,i,a);return h.createElement("g",{className:c},h.createElement("path",V({},k(o,!0),{fill:s.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:s})),f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(r,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(r,a);return h.createElement("path",V({},k(o,!0),{fill:p.slice(-1)==="Z"?o.fill:"none",className:c,d:p}))},ye,Me;function Wt(){if(Me)return ye;Me=1;var n=Qe(),e=xt(),r=Ye();function t(i,a){return i&&i.length?n(i,r(a,2),e):void 0}return ye=t,ye}var Gt=Wt();const Ht=Je(Gt);var ge,Ve;function Zt(){if(Ve)return ge;Ve=1;var n=Qe(),e=Ye(),r=At();function t(i,a){return i&&i.length?n(i,e(a,2),r):void 0}return ge=t,ge}var Ut=Zt();const Xt=Je(Ut);var Qt=["cx","cy","angle","ticks","axisLine"],Yt=["ticks","tick","angle","tickFormatter","stroke"];function H(n){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(n)}function Y(){return Y=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},Y.apply(this,arguments)}function qe(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function L(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(r),!0).forEach(function(t){de(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function ze(n,e){if(n==null)return{};var r=Jt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Jt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function en(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function We(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ut(t.key),t)}}function tn(n,e,r){return e&&We(n.prototype,e),r&&We(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function nn(n,e,r){return e=ce(e),rn(n,lt()?Reflect.construct(e,r||[],ce(n).constructor):e.apply(n,r))}function rn(n,e){if(e&&(H(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return an(n)}function an(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function lt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!n})()}function ce(n){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ce(n)}function on(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&xe(n,e)}function xe(n,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(n,e)}function de(n,e,r){return e=ut(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function ut(n){var e=sn(n,"string");return H(e)=="symbol"?e:e+""}function sn(n,e){if(H(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(H(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var me=(function(n){function e(){return en(this,e),nn(this,e,arguments)}return on(e,n),tn(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return S(c,f,i,o)}},{key:"getTickTextAnchor",value:function(){var t=this.props.orientation,i;switch(t){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=Ht(c,function(p){return p.coordinate||0}),s=Xt(c,function(p){return p.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:s.coordinate||0,outerRadius:f.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=t.axisLine,s=ze(t,Qt),p=c.reduce(function(m,l){return[Math.min(m[0],l.coordinate),Math.max(m[1],l.coordinate)]},[1/0,-1/0]),d=S(i,a,p[0],o),v=S(i,a,p[1],o),A=L(L(L({},k(s,!1)),{},{fill:"none"},k(f,!1)),{},{x1:d.x,y1:d.y,x2:v.x,y2:v.y});return h.createElement("line",Y({className:"recharts-polar-radius-axis-line"},A))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.angle,f=i.tickFormatter,s=i.stroke,p=ze(i,Yt),d=this.getTickTextAnchor(),v=k(p,!1),A=k(o,!1),m=a.map(function(l,g){var b=t.getTickValueCoord(l),x=L(L(L(L({textAnchor:d,transform:"rotate(".concat(90-c,", ").concat(b.x,", ").concat(b.y,")")},v),{},{stroke:"none",fill:s},A),{},{index:g},b),{},{payload:l});return h.createElement(_,Y({className:I("recharts-polar-radius-axis-tick",et(o)),key:"tick-".concat(l.coordinate)},Pe(t.props,l,g)),e.renderTickItem(o,x,f?f(l.value,g):l.value))});return h.createElement(_,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.axisLine,o=t.tick;return!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),tt.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Oe,Y({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(J.PureComponent);de(me,"displayName","PolarRadiusAxis");de(me,"axisType","radiusAxis");de(me,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function Z(n){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(n)}function D(){return D=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},D.apply(this,arguments)}function Ge(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function $(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(r),!0).forEach(function(t){ve(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ge(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function cn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function He(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,pt(t.key),t)}}function ln(n,e,r){return e&&He(n.prototype,e),r&&He(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function un(n,e,r){return e=le(e),fn(n,ft()?Reflect.construct(e,r||[],le(n).constructor):e.apply(n,r))}function fn(n,e){if(e&&(Z(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pn(n)}function pn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ft(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!n})()}function le(n){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},le(n)}function dn(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Ae(n,e)}function Ae(n,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Ae(n,e)}function ve(n,e,r){return e=pt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function pt(n){var e=mn(n,"string");return Z(e)=="symbol"?e:e+""}function mn(n,e){if(Z(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(Z(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var vn=Math.PI/180,Ze=1e-5,he=(function(n){function e(){return cn(this,e),un(this,e,arguments)}return dn(e,n),ln(e,[{key:"getTickLineCoord",value:function(t){var i=this.props,a=i.cx,o=i.cy,c=i.radius,f=i.orientation,s=i.tickSize,p=s||8,d=S(a,o,c,t.coordinate),v=S(a,o,c+(f==="inner"?-1:1)*p,t.coordinate);return{x1:d.x,y1:d.y,x2:v.x,y2:v.y}}},{key:"getTickTextAnchor",value:function(t){var i=this.props.orientation,a=Math.cos(-t.coordinate*vn),o;return a>Ze?o=i==="outer"?"start":"end":a<-Ze?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.radius,c=t.axisLine,f=t.axisLineType,s=$($({},k(this.props,!1)),{},{fill:"none"},k(c,!1));if(f==="circle")return h.createElement(kt,D({className:"recharts-polar-angle-axis-line"},s,{cx:i,cy:a,r:o}));var p=this.props.ticks,d=p.map(function(v){return S(i,a,o,v.coordinate)});return h.createElement(zt,D({className:"recharts-polar-angle-axis-line"},s,{points:d}))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.tickLine,f=i.tickFormatter,s=i.stroke,p=k(this.props,!1),d=k(o,!1),v=$($({},p),{},{fill:"none"},k(c,!1)),A=a.map(function(m,l){var g=t.getTickLineCoord(m),b=t.getTickTextAnchor(m),x=$($($({textAnchor:b},p),{},{stroke:"none",fill:s},d),{},{index:l,payload:m,x:g.x2,y:g.y2});return h.createElement(_,D({className:I("recharts-polar-angle-axis-tick",et(o)),key:"tick-".concat(m.coordinate)},Pe(t.props,m,l)),c&&h.createElement("line",D({className:"recharts-polar-angle-axis-tick-line"},v,g)),o&&e.renderTickItem(o,x,f?f(m.value,l):m.value))});return h.createElement(_,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.radius,o=t.axisLine;return a<=0||!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Oe,D({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(J.PureComponent);ve(he,"displayName","PolarAngleAxis");ve(he,"axisType","angleAxis");ve(he,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var oe;function U(n){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(n)}function q(){return q=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},q.apply(this,arguments)}function Ue(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function y(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ue(Object(r),!0).forEach(function(t){P(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function hn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,mt(t.key),t)}}function yn(n,e,r){return e&&Xe(n.prototype,e),r&&Xe(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function gn(n,e,r){return e=ue(e),bn(n,dt()?Reflect.construct(e,r||[],ue(n).constructor):e.apply(n,r))}function bn(n,e){if(e&&(U(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xn(n)}function xn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function dt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!n})()}function ue(n){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(n)}function An(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&ke(n,e)}function ke(n,e){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},ke(n,e)}function P(n,e,r){return e=mt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function mt(n){var e=kn(n,"string");return U(e)=="symbol"?e:e+""}function kn(n,e){if(U(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var E=(function(n){function e(r){var t;return hn(this,e),t=gn(this,e,[r]),P(t,"pieRef",null),P(t,"sectorRefs",[]),P(t,"id",Tt("recharts-pie-")),P(t,"handleAnimationEnd",function(){var i=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),C(i)&&i()}),P(t,"handleAnimationStart",function(){var i=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),C(i)&&i()}),t.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},t}return An(e,n),yn(e,[{key:"isActiveIndex",value:function(t){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(t)!==-1:t===i}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,c=a.labelLine,f=a.dataKey,s=a.valueKey,p=k(this.props,!1),d=k(o,!1),v=k(c,!1),A=o&&o.offsetRadius||20,m=t.map(function(l,g){var b=(l.startAngle+l.endAngle)/2,x=S(l.cx,l.cy,l.outerRadius+A,b),j=y(y(y(y({},p),l),{},{stroke:"none"},d),{},{index:g,textAnchor:e.getTextAnchor(x.x,l.cx)},x),B=y(y(y(y({},p),l),{},{fill:"none",stroke:l.fill},v),{},{index:g,points:[S(l.cx,l.cy,l.outerRadius,b),x]}),w=f;return z(f)&&z(s)?w="value":z(f)&&(w=s),h.createElement(_,{key:"label-".concat(l.startAngle,"-").concat(l.endAngle,"-").concat(l.midAngle,"-").concat(g)},c&&e.renderLabelLineItem(c,B,"line"),e.renderLabelItem(o,j,F(l,w)))});return h.createElement(_,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var i=this,a=this.props,o=a.activeShape,c=a.blendStroke,f=a.inactiveShape;return t.map(function(s,p){if((s==null?void 0:s.startAngle)===0&&(s==null?void 0:s.endAngle)===0&&t.length!==1)return null;var d=i.isActiveIndex(p),v=f&&i.hasActiveIndex()?f:null,A=d?o:v,m=y(y({},s),{},{stroke:c?s.fill:s.stroke,tabIndex:-1});return h.createElement(_,q({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},Pe(i.props,s,p),{key:"sector-".concat(s==null?void 0:s.startAngle,"-").concat(s==null?void 0:s.endAngle,"-").concat(s.midAngle,"-").concat(p)}),h.createElement(Pt,q({option:A,isActive:d,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,i=this.props,a=i.sectors,o=i.isAnimationActive,c=i.animationBegin,f=i.animationDuration,s=i.animationEasing,p=i.animationId,d=this.state,v=d.prevSectors,A=d.prevIsAnimationActive;return h.createElement(jt,{begin:c,duration:f,isActive:o,easing:s,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var l=m.t,g=[],b=a&&a[0],x=b.startAngle;return a.forEach(function(j,B){var w=v&&v[B],N=B>0?_t(j,"paddingAngle",0):0;if(w){var X=De(w.endAngle-w.startAngle,j.endAngle-j.startAngle),O=y(y({},j),{},{startAngle:x+N,endAngle:x+X(l)+N});g.push(O),x=O.endAngle}else{var K=j.endAngle,T=j.startAngle,te=De(0,K-T),ne=te(l),R=y(y({},j),{},{startAngle:x+N,endAngle:x+ne+N});g.push(R),x=R.endAngle}}),h.createElement(_,null,t.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(t){var i=this;t.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var c=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[c].focus(),i.setState({sectorToFocus:c});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,i=t.sectors,a=t.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!wt(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,i=this.props,a=i.hide,o=i.sectors,c=i.className,f=i.label,s=i.cx,p=i.cy,d=i.innerRadius,v=i.outerRadius,A=i.isAnimationActive,m=this.state.isAnimationFinished;if(a||!o||!o.length||!M(s)||!M(p)||!M(d)||!M(v))return null;var l=I("recharts-pie",c);return h.createElement(_,{tabIndex:this.props.rootTabIndex,className:l,ref:function(b){t.pieRef=b}},this.renderSectors(),f&&this.renderLabels(o),tt.renderCallByParent(this.props,null,!1),(!A||m)&&je.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,i){return i.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==i.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:t.sectors!==i.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,i){return t>i?"start":t<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);if(C(t))return t(i);var o=I("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return h.createElement(Ot,q({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);var o=a;if(C(t)&&(o=t(i),h.isValidElement(o)))return o;var c=I("recharts-pie-label-text",typeof t!="boolean"&&!C(t)?t.className:"");return h.createElement(Oe,q({},i,{alignmentBaseline:"middle",className:c}),o)}}])})(J.PureComponent);oe=E;P(E,"displayName","Pie");P(E,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!St.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});P(E,"parseDeltaAngle",function(n,e){var r=ae(e-n),t=Math.min(Math.abs(e-n),360);return r*t});P(E,"getRealPieData",function(n){var e=n.data,r=n.children,t=k(n,!1),i=Et(r,_e);return e&&e.length?e.map(function(a,o){return y(y(y({payload:a},t),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return y(y({},t),a.props)}):[]});P(E,"parseCoordinateOfPie",function(n,e){var r=e.top,t=e.left,i=e.width,a=e.height,o=Rt(i,a),c=t+re(n.cx,i,i/2),f=r+re(n.cy,a,a/2),s=re(n.innerRadius,o,0),p=re(n.outerRadius,o,o*.8),d=n.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,innerRadius:s,outerRadius:p,maxRadius:d}});P(E,"getComposedData",function(n){var e=n.item,r=n.offset,t=e.type.defaultProps!==void 0?y(y({},e.type.defaultProps),e.props):e.props,i=oe.getRealPieData(t);if(!i||!i.length)return null;var a=t.cornerRadius,o=t.startAngle,c=t.endAngle,f=t.paddingAngle,s=t.dataKey,p=t.nameKey,d=t.valueKey,v=t.tooltipType,A=Math.abs(t.minAngle),m=oe.parseCoordinateOfPie(t,r),l=oe.parseDeltaAngle(o,c),g=Math.abs(l),b=s;z(s)&&z(d)?(Be(!1,`Use "dataKey" to specify the value of pie,
|
|
3
3
|
the props "valueKey" will be deprecated in 1.1.0`),b="value"):z(s)&&(Be(!1,`Use "dataKey" to specify the value of pie,
|
|
4
4
|
the props "valueKey" will be deprecated in 1.1.0`),b=d);var x=i.filter(function(O){return F(O,b,0)!==0}).length,j=(g>=360?x:x-1)*f,B=g-x*A-j,w=i.reduce(function(O,K){var T=F(K,b,0);return O+(M(T)?T:0)},0),N;if(w>0){var X;N=i.map(function(O,K){var T=F(O,b,0),te=F(O,p,K),ne=(M(T)?T:0)/w,R;K?R=X.endAngle+ae(l)*f*(T!==0?1:0):R=o;var Le=R+ae(l)*((T!==0?A:0)+ne*B),$e=(R+Le)/2,Ce=(m.innerRadius+m.outerRadius)/2,gt=[{name:te,value:T,payload:O,dataKey:b,type:v}],bt=S(m.cx,m.cy,Ce,$e);return X=y(y(y({percent:ne,cornerRadius:a,name:te,tooltipPayload:gt,midAngle:$e,middleRadius:Ce,tooltipPosition:bt},O),m),{},{value:F(O,b),startAngle:R,endAngle:Le,payload:O,paddingAngle:ae(l)*f}),X})}return y(y({},m),{},{sectors:N,data:i})});var vt=nt({chartName:"BarChart",GraphicalChild:Se,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:we},{axisType:"yAxis",AxisComp:Te}],formatAxisMap:It}),On=nt({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:he},{axisType:"radiusAxis",AxisComp:me}],formatAxisMap:Nt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const ht={fill:"var(--color-bg-2)"},yt={fill:"var(--color-fg-dim)",fontSize:10,fontFamily:"var(--font-mono)"},Pn=Ne("cost",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),jn=Ne("tokens",W,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),_n=Ne("saved",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)});function Tn({derived:n,height:e=280,limit:r=10,metric:t="cost",periodLabel:i}){const a=Ee(),o=rt("(min-width: 768px)"),c=o?124:92,f=o?60:44,s=t==="tokens",p=[...n.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,r);return u.jsx(fe,{title:s?"tokens by model":"cost by model",titleTag:i,captureName:s?"tokens-by-model":"cost-by-model",children:p.length===0?u.jsx(pe,{children:"no models in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:p,layout:"vertical",margin:{top:4,right:f,left:4,bottom:0},children:[u.jsx(it,{...at,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:s?W:ot}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(st,{content:s?jn:Pn,cursor:ht}),u.jsxs(Se,{dataKey:s?"tokens":"cost",radius:[0,3,3,0],isAnimationActive:a,animationDuration:350,children:[p.map(d=>u.jsx(_e,{fill:d.color},d.model)),u.jsx(je,{dataKey:s?"tokens":"cost",position:"right",offset:6,...yt,formatter:d=>s?W(d):G(d)})]})]})})})})}function Sn({derived:n,height:e=240,limit:r=12,periodLabel:t}){const i=Ee(),a=rt("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...n.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,r);return u.jsx(fe,{title:"cache savings by model",titleTag:t,captureName:"cache-savings-by-model",children:f.length===0?u.jsx(pe,{children:"no cache savings in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:f,layout:"vertical",margin:{top:4,right:c,left:4,bottom:0},children:[u.jsx(it,{...at,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:ot}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(st,{content:_n,cursor:ht}),u.jsx(Se,{dataKey:"cacheSavings",radius:[0,3,3,0],fill:"var(--color-positive)",isAnimationActive:i,animationDuration:350,children:u.jsx(je,{dataKey:"cacheSavings",position:"right",offset:6,...yt,formatter:s=>G(s)})})]})})})})}function En({derived:n,height:e=280,periodLabel:r}){const t=Ee(),i=n.byProvider,a=n.totals.cost,[o,c]=J.useState(null),[f,s]=J.useState(null),p=f?i.findIndex(m=>m.id===f):-1,d=o??(p>=0?p:null),v=d!=null?i[d]:null,A=v&&a>0?v.cost/a:0;return u.jsx(fe,{title:"provider split",titleTag:r,captureName:"provider-split",children:i.length===0?u.jsx(pe,{children:"no spend in period"}):u.jsxs("div",{className:"relative",onMouseLeave:()=>c(null),children:[u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsx(On,{children:u.jsx(E,{data:i,dataKey:"cost",nameKey:"name",innerRadius:"60%",outerRadius:"88%",paddingAngle:i.length>1?2:0,stroke:"var(--color-bg-1)",strokeWidth:2,isAnimationActive:t,animationDuration:350,style:{cursor:"pointer"},onMouseEnter:(m,l)=>c(l),onClick:(m,l)=>s(g=>{var b,x;return g===((b=i[l])==null?void 0:b.id)?null:((x=i[l])==null?void 0:x.id)??null}),children:i.map((m,l)=>u.jsx(_e,{fill:m.color,"aria-label":`${m.name}: ${G(m.cost)}`,fillOpacity:d==null||d===l?1:.32,style:{transition:"fill-opacity 150ms ease"}},m.id))})})})}),u.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"tnum text-xl",style:{color:v?v.color:"var(--color-fg-bright)"},children:G(v?v.cost:a)}),u.jsxs("div",{className:"font-display text-[10px] uppercase tracking-wide text-fg-faint",children:[v?`${v.name} · ${ct(A,A>0&&A<.01?1:0)}`:"total",v&&o==null&&p>=0&&u.jsx("span",{className:"text-accent",children:" · pinned"})]})]})]})})}function Rn({derived:n,periodLabel:e}){const r=n.tokenComposition,t=Lt(r),i=[{key:"cacheRead",label:"cache read",value:r.cacheRead,color:ie.cacheRead},{key:"input",label:"input",value:r.input,color:ie.input},{key:"output",label:"output",value:r.output,color:ie.output},{key:"cacheCreate",label:"cache write",value:r.cacheCreate,color:ie.cacheCreate}];return u.jsx(fe,{title:"token composition",titleTag:e,captureName:"token-composition",right:u.jsx("span",{className:"tnum text-xs text-fg-dim",children:W(t)}),children:t===0?u.jsx(pe,{children:"no tokens in period"}):u.jsxs("div",{className:"flex flex-col gap-4 pt-1",children:[u.jsx("div",{className:"flex h-3 w-full overflow-hidden rounded-full bg-bg-3",children:i.map(a=>a.value>0&&u.jsx("div",{style:{width:`${a.value/t*100}%`,minWidth:"2px",background:a.color},title:`${a.label}: ${W(a.value)}`},a.key))}),u.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5",children:i.map(a=>{const o=t>0?a.value/t:0;return u.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[u.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim",children:[u.jsx("span",{className:"inline-block size-2 rounded-[2px]",style:{background:a.color}}),a.label]}),u.jsxs("span",{className:"text-fg",children:[u.jsx("span",{className:"tnum text-fg-bright",children:W(a.value)}),u.jsx("span",{className:"ml-1.5 text-fg-faint",children:ct(o,o>0&&o<.01?1:0)})]})]},a.key)})})]})})}export{Sn as CacheByModel,Tn as CostByModel,En as ProviderDonut,Rn as TokenComposition};
|