tokmon 0.22.1 → 0.22.3
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/dist/{bootstrap-ink-CCESIGED.js → bootstrap-ink-KFQR6QK3.js} +19 -19
- package/dist/{chunk-RA3SCIG6.js → chunk-3PT52HWA.js} +2 -2
- package/dist/{chunk-FLLNU6BN.js → chunk-LXHXKELJ.js} +2 -23
- package/dist/{chunk-E25RUTXB.js → chunk-OV35PDO6.js} +98 -19
- package/dist/cli.js +4 -4
- package/dist/{config-F7TY5ZFA.js → config-QBY7K5V5.js} +3 -1
- package/dist/{daemon-A3NSDSPZ.js → daemon-JQFS7EMA.js} +3 -3
- package/dist/server-RTH46XRR.js +9 -0
- package/dist/web/assets/{breakdown-C3Zqnewe.js → breakdown-BOiyWsmh.js} +1 -1
- package/dist/web/assets/{index-BkdjevbO.js → index-DqO2pHzm.js} +67 -67
- package/dist/web/assets/{timeline-C2vHjZJ3.js → timeline-Bf6UMuLO.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/server-P7T4ZMC6.js +0 -9
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
systemTimezone,
|
|
20
20
|
time,
|
|
21
21
|
tokens
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LXHXKELJ.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-OV35PDO6.js";
|
|
38
38
|
import {
|
|
39
39
|
glyphs
|
|
40
40
|
} from "./chunk-RF4GGQGM.js";
|
|
@@ -324,7 +324,7 @@ function computeDashLayout(groups, stats, cols, budget, focusId, layoutPref) {
|
|
|
324
324
|
}
|
|
325
325
|
return chooseLayout(content, budget, groups.length, single, cols, heights);
|
|
326
326
|
}
|
|
327
|
-
var DashboardView = memo2(function DashboardView2({ groups, stats, cols, budget, focusId, layout, page = 0, privacyMode
|
|
327
|
+
var DashboardView = memo2(function DashboardView2({ groups, stats, cols, budget, focusId, layout, page = 0, privacyMode = false }) {
|
|
328
328
|
if (groups.length === 0) {
|
|
329
329
|
return /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
330
330
|
"No providers enabled ",
|
|
@@ -339,7 +339,7 @@ var DashboardView = memo2(function DashboardView2({ groups, stats, cols, budget,
|
|
|
339
339
|
const pg = pageCount > 1 ? (page % pageCount + pageCount) % pageCount : 0;
|
|
340
340
|
const visible = pageCount > 1 ? groups.slice(pg * cardsPerPage, pg * cardsPerPage + cardsPerPage) : groups;
|
|
341
341
|
return /* @__PURE__ */ jsxs2(Box2, { height: budget, flexDirection: "column", overflow: "hidden", children: [
|
|
342
|
-
/* @__PURE__ */ jsx2(Box2, { width: content, flexWrap: "wrap", columnGap: GAP, rowGap: 1, alignItems: "flex-start", children: visible.map((g) => /* @__PURE__ */ jsx2(Box2, { flexShrink: 0, children: /* @__PURE__ */ jsx2(ProviderCard, { provider: g.provider, accounts: g.accounts, stats, width: cardW, variant, privacyMode
|
|
342
|
+
/* @__PURE__ */ jsx2(Box2, { width: content, flexWrap: "wrap", columnGap: GAP, rowGap: 1, alignItems: "flex-start", children: visible.map((g) => /* @__PURE__ */ jsx2(Box2, { flexShrink: 0, children: /* @__PURE__ */ jsx2(ProviderCard, { provider: g.provider, accounts: g.accounts, stats, width: cardW, variant, privacyMode }) }, g.provider)) }),
|
|
343
343
|
pageCount > 1 && /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
344
344
|
" ",
|
|
345
345
|
glyphs().middot,
|
|
@@ -355,7 +355,7 @@ var DashboardView = memo2(function DashboardView2({ groups, stats, cols, budget,
|
|
|
355
355
|
] })
|
|
356
356
|
] });
|
|
357
357
|
});
|
|
358
|
-
function ProviderCard({ provider, accounts, stats, width, variant }) {
|
|
358
|
+
function ProviderCard({ provider, accounts, stats, width, variant, privacyMode = false }) {
|
|
359
359
|
const meta = PROVIDERS[provider];
|
|
360
360
|
const items = accounts.map((a) => ({ account: a, s: stats.get(a.id) }));
|
|
361
361
|
const dashboards = items.map((i) => i.s?.dashboard).filter((d) => !!d);
|
|
@@ -408,13 +408,13 @@ function ProviderCard({ provider, accounts, stats, width, variant }) {
|
|
|
408
408
|
] })
|
|
409
409
|
] });
|
|
410
410
|
}
|
|
411
|
-
function CompactBilling({ items, privacyMode
|
|
411
|
+
function CompactBilling({ items, privacyMode }) {
|
|
412
412
|
const billing = items.map((i) => i.s?.billing).find(Boolean);
|
|
413
413
|
if (!billing) return /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
414
414
|
"Fetching",
|
|
415
415
|
glyphs().ellipsis
|
|
416
416
|
] });
|
|
417
|
-
if (billing.error) return /* @__PURE__ */ jsx2(Text2, { color: "red", children:
|
|
417
|
+
if (billing.error) return /* @__PURE__ */ jsx2(Text2, { color: "red", children: privacyMode ? redactEmail(billing.error) : billing.error });
|
|
418
418
|
const m = billing.metrics.find((x) => x.primary) ?? billing.metrics[0];
|
|
419
419
|
if (!m) return /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "No data" });
|
|
420
420
|
return /* @__PURE__ */ jsx2(Text2, { bold: true, color: "yellow", children: metricValueText(m) });
|
|
@@ -459,12 +459,12 @@ function KpiLine({ agg }) {
|
|
|
459
459
|
] })
|
|
460
460
|
] });
|
|
461
461
|
}
|
|
462
|
-
function accountTitle(account, billing,
|
|
462
|
+
function accountTitle(account, billing, privacyMode = false) {
|
|
463
463
|
const email = billing?.email;
|
|
464
464
|
const title = email && !account.name.includes("@") ? `${account.name} ${email}` : account.name;
|
|
465
|
-
return
|
|
465
|
+
return privacyMode ? redactEmail(title) : title;
|
|
466
466
|
}
|
|
467
|
-
function LimitsBlock({ items, inner, privacyMode
|
|
467
|
+
function LimitsBlock({ items, inner, privacyMode }) {
|
|
468
468
|
const showName = items.length > 1;
|
|
469
469
|
const labels = items.flatMap((i) => i.s?.billing?.metrics ?? []).map((m) => m.label.length);
|
|
470
470
|
const labelW = Math.min(Math.max(7, ...labels) + 1, 14);
|
|
@@ -477,12 +477,12 @@ function LimitsBlock({ items, inner, privacyMode: privacyMode2 }) {
|
|
|
477
477
|
glyphs().dot,
|
|
478
478
|
" "
|
|
479
479
|
] }),
|
|
480
|
-
/* @__PURE__ */ jsx2(Text2, { bold: true, children: truncateName(accountTitle(account, billing,
|
|
480
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: truncateName(accountTitle(account, billing, privacyMode), Math.max(22, inner - 2)) })
|
|
481
481
|
] }),
|
|
482
482
|
!billing ? /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
483
483
|
"Fetching",
|
|
484
484
|
glyphs().ellipsis
|
|
485
|
-
] }) : billing.error ? /* @__PURE__ */ jsx2(Text2, { color: "red", wrap: "truncate-end", children:
|
|
485
|
+
] }) : billing.error ? /* @__PURE__ */ jsx2(Text2, { color: "red", wrap: "truncate-end", children: privacyMode ? redactEmail(billing.error) : billing.error }) : billing.metrics.length === 0 ? /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "No data" }) : billing.metrics.map((m, i) => /* @__PURE__ */ jsx2(MetricRow, { m, color: account.color, barW, labelW }, `${m.label}${i}`))
|
|
486
486
|
] }, account.id);
|
|
487
487
|
}) });
|
|
488
488
|
}
|
|
@@ -1384,18 +1384,18 @@ function groupTodayCost(items) {
|
|
|
1384
1384
|
return sum + (d?.today.cost ?? 0);
|
|
1385
1385
|
}, 0);
|
|
1386
1386
|
}
|
|
1387
|
-
function headlineFor(group, items,
|
|
1387
|
+
function headlineFor(group, items, privacyMode = false) {
|
|
1388
1388
|
const meta = PROVIDERS[group.provider];
|
|
1389
1389
|
if (meta.hasUsage) return `${currency(groupTodayCost(items))} today`;
|
|
1390
1390
|
const billing = items.map((s) => s?.billing).find(Boolean);
|
|
1391
1391
|
if (!billing) return "no data";
|
|
1392
|
-
if (billing.error) return
|
|
1392
|
+
if (billing.error) return privacyMode ? redactEmail(billing.error) : billing.error;
|
|
1393
1393
|
const m = billing.metrics[0];
|
|
1394
1394
|
if (m) return metricValueText(m);
|
|
1395
1395
|
return billing.plan ?? "no data";
|
|
1396
1396
|
}
|
|
1397
1397
|
var STAGGER_FRAMES = 2;
|
|
1398
|
-
function LoadingView({ groups, stats, cols, rows, readyInput, privacyMode
|
|
1398
|
+
function LoadingView({ groups, stats, cols, rows, readyInput, privacyMode = false }) {
|
|
1399
1399
|
const resolveReady = readyInput ?? ((id) => statsReadyInput(stats.get(id)));
|
|
1400
1400
|
const sp = glyphs().spinner;
|
|
1401
1401
|
const [frame, setFrame] = useState2(0);
|
|
@@ -1463,7 +1463,7 @@ function LoadingView({ groups, stats, cols, rows, readyInput, privacyMode: priva
|
|
|
1463
1463
|
sp[frame % sp.length],
|
|
1464
1464
|
" "
|
|
1465
1465
|
] }),
|
|
1466
|
-
errored ? /* @__PURE__ */ jsx6(Text6, { color: "red", children: headlineFor(g, items,
|
|
1466
|
+
errored ? /* @__PURE__ */ jsx6(Text6, { color: "red", children: headlineFor(g, items, privacyMode) }) : ready ? /* @__PURE__ */ jsx6(Text6, { children: headlineFor(g, items, privacyMode) }) : /* @__PURE__ */ jsxs6(Text6, { dimColor: true, children: [
|
|
1467
1467
|
"loading",
|
|
1468
1468
|
glyphs().ellipsis
|
|
1469
1469
|
] })
|
|
@@ -1492,8 +1492,8 @@ function LoadingView({ groups, stats, cols, rows, readyInput, privacyMode: priva
|
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
1494
1494
|
// src/ui/app-layout.logic.ts
|
|
1495
|
-
function deriveSlots(accounts,
|
|
1496
|
-
const label = (name) =>
|
|
1495
|
+
function deriveSlots(accounts, privacyMode = false) {
|
|
1496
|
+
const label = (name) => privacyMode ? redactEmail(name) : name;
|
|
1497
1497
|
return accounts.length > 1 ? [{ id: null, name: "All", color: "whiteBright" }, ...accounts.map((a) => ({ id: a.id, name: label(a.name), color: a.color }))] : accounts.map((a) => ({ id: a.id, name: label(a.name), color: a.color }));
|
|
1498
1498
|
}
|
|
1499
1499
|
function findActiveSlot(slots, activeAccountId) {
|
|
@@ -3413,7 +3413,7 @@ function App({ interval: cliInterval, initialConfig, baseUrl = null, wsToken = n
|
|
|
3413
3413
|
if (webStartingRef.current) return;
|
|
3414
3414
|
webStartingRef.current = true;
|
|
3415
3415
|
try {
|
|
3416
|
-
const { startWebServer } = await import("./server-
|
|
3416
|
+
const { startWebServer } = await import("./server-RTH46XRR.js");
|
|
3417
3417
|
const ctrl = await startWebServer({ config: cfg, log: false });
|
|
3418
3418
|
webRef.current = ctrl;
|
|
3419
3419
|
openUrl(ctrl.url);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fetchPeak,
|
|
11
11
|
namedHex,
|
|
12
12
|
resolveTimezone
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LXHXKELJ.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-OV35PDO6.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-OV35PDO6.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,
|
|
@@ -129,25 +129,96 @@ function isValidTimezone(tz) {
|
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
function isRecord(value) {
|
|
133
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
134
|
+
}
|
|
135
|
+
function validProvider(value) {
|
|
136
|
+
return PROVIDER_IDS.includes(value);
|
|
137
|
+
}
|
|
138
|
+
function sameJson(a, b) {
|
|
139
|
+
try {
|
|
140
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
141
|
+
} catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function repairConfig(input) {
|
|
146
|
+
const reasons = [];
|
|
147
|
+
const parsed = isRecord(input) ? input : {};
|
|
148
|
+
if (parsed !== input) reasons.push("config root was not an object");
|
|
149
|
+
const rawAccounts = Array.isArray(parsed.accounts) ? parsed.accounts : [];
|
|
150
|
+
if (!Array.isArray(parsed.accounts) && parsed.accounts !== void 0) reasons.push("accounts was not an array");
|
|
151
|
+
const accounts = [];
|
|
152
|
+
const accountIds = /* @__PURE__ */ new Set();
|
|
153
|
+
rawAccounts.forEach((raw, index) => {
|
|
154
|
+
if (!isRecord(raw)) {
|
|
155
|
+
reasons.push(`accounts[${index}] was not an object`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const providerId = raw.providerId ?? "claude";
|
|
159
|
+
if (!validProvider(providerId)) {
|
|
160
|
+
reasons.push(`accounts[${index}].providerId was invalid`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const id = typeof raw.id === "string" && raw.id.trim() ? raw.id.trim() : "";
|
|
164
|
+
const name = typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : "";
|
|
165
|
+
if (!id || !name) {
|
|
166
|
+
reasons.push(`accounts[${index}] was missing id or name`);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (accountIds.has(id)) {
|
|
170
|
+
reasons.push(`accounts[${index}].id was duplicated`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
accountIds.add(id);
|
|
174
|
+
accounts.push({
|
|
175
|
+
id,
|
|
176
|
+
providerId,
|
|
177
|
+
name,
|
|
178
|
+
homeDir: typeof raw.homeDir === "string" && raw.homeDir.trim() ? raw.homeDir : "~",
|
|
179
|
+
...typeof raw.color === "string" && raw.color.trim() ? { color: raw.color } : {}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
const disabledProviders = (Array.isArray(parsed.disabledProviders) ? parsed.disabledProviders : []).filter(validProvider);
|
|
183
|
+
if (parsed.disabledProviders !== void 0 && !Array.isArray(parsed.disabledProviders)) {
|
|
184
|
+
reasons.push("disabledProviders was not an array");
|
|
185
|
+
}
|
|
186
|
+
const knownProviders = Array.isArray(parsed.knownProviders) ? parsed.knownProviders.filter(validProvider) : parsed.onboarded === true ? [...LEGACY_KNOWN] : [];
|
|
187
|
+
if (parsed.knownProviders !== void 0 && !Array.isArray(parsed.knownProviders)) {
|
|
188
|
+
reasons.push("knownProviders was not an array");
|
|
189
|
+
}
|
|
190
|
+
const activeAccountId = typeof parsed.activeAccountId === "string" && (accountIds.has(parsed.activeAccountId) || PROVIDER_IDS.includes(parsed.activeAccountId)) ? parsed.activeAccountId : null;
|
|
191
|
+
if (parsed.activeAccountId !== void 0 && parsed.activeAccountId !== null && activeAccountId === null) {
|
|
192
|
+
reasons.push("activeAccountId did not match a known account/provider");
|
|
193
|
+
}
|
|
194
|
+
const timezone = typeof parsed.timezone === "string" && parsed.timezone.trim() && isValidTimezone(parsed.timezone.trim()) ? parsed.timezone.trim() : null;
|
|
195
|
+
if (parsed.timezone !== void 0 && parsed.timezone !== null && timezone === null) {
|
|
196
|
+
reasons.push("timezone was invalid");
|
|
197
|
+
}
|
|
198
|
+
const config = {
|
|
199
|
+
...DEFAULTS,
|
|
200
|
+
interval: clampNum(parsed.interval, DEFAULTS.interval, 1),
|
|
201
|
+
billingInterval: clampNum(parsed.billingInterval, DEFAULTS.billingInterval, 1),
|
|
202
|
+
clearScreen: typeof parsed.clearScreen === "boolean" ? parsed.clearScreen : DEFAULTS.clearScreen,
|
|
203
|
+
privacyMode: typeof parsed.privacyMode === "boolean" ? parsed.privacyMode : DEFAULTS.privacyMode,
|
|
204
|
+
timezone,
|
|
205
|
+
accounts,
|
|
206
|
+
activeAccountId,
|
|
207
|
+
disabledProviders,
|
|
208
|
+
onboarded: parsed.onboarded === true,
|
|
209
|
+
dashboardLayout: parsed.dashboardLayout === "single" ? "single" : "grid",
|
|
210
|
+
defaultFocus: parsed.defaultFocus === "last" ? "last" : "all",
|
|
211
|
+
ascii: parsed.ascii === "on" ? "on" : parsed.ascii === "off" ? "off" : "auto",
|
|
212
|
+
knownProviders
|
|
213
|
+
};
|
|
214
|
+
for (const key of Object.keys(DEFAULTS)) {
|
|
215
|
+
if (!(key in parsed)) reasons.push(`missing ${key}`);
|
|
216
|
+
}
|
|
217
|
+
return { config, repaired: reasons.length > 0 || !sameJson(parsed, config), reasons };
|
|
218
|
+
}
|
|
132
219
|
function normalizeConfig(parsed) {
|
|
133
220
|
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
|
-
};
|
|
221
|
+
return repairConfig(parsed).config;
|
|
151
222
|
} catch {
|
|
152
223
|
return { ...DEFAULTS };
|
|
153
224
|
}
|
|
@@ -220,11 +291,18 @@ async function loadConfig() {
|
|
|
220
291
|
}
|
|
221
292
|
return { ...DEFAULTS };
|
|
222
293
|
}
|
|
223
|
-
|
|
294
|
+
const repaired = repairConfig(parsed);
|
|
295
|
+
if (repaired.repaired) {
|
|
296
|
+
try {
|
|
297
|
+
await saveConfig(repaired.config);
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return repaired.config;
|
|
224
302
|
}
|
|
225
303
|
var saveQueue = Promise.resolve();
|
|
226
304
|
function configJson(config) {
|
|
227
|
-
return JSON.stringify(config, null, 2) + "\n";
|
|
305
|
+
return JSON.stringify(normalizeConfig(config), null, 2) + "\n";
|
|
228
306
|
}
|
|
229
307
|
function saveConfig(config) {
|
|
230
308
|
saveQueue = saveQueue.then(async () => {
|
|
@@ -271,6 +349,7 @@ export {
|
|
|
271
349
|
getTrackedAccountRows,
|
|
272
350
|
clampNum,
|
|
273
351
|
isValidTimezone,
|
|
352
|
+
repairConfig,
|
|
274
353
|
normalizeConfig,
|
|
275
354
|
slugify,
|
|
276
355
|
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-JQFS7EMA.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-JQFS7EMA.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-QBY7K5V5.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-KFQR6QK3.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-OV35PDO6.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-3PT52HWA.js";
|
|
6
6
|
import {
|
|
7
7
|
flushDisk
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LXHXKELJ.js";
|
|
9
9
|
import {
|
|
10
10
|
cacheDir,
|
|
11
11
|
loadConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OV35PDO6.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-DqO2pHzm.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};
|