tokmon 0.28.0 → 0.28.2
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 +1 -1
- package/dist/{bootstrap-ink-5LQMSU4B.js → bootstrap-ink-IMT3S5HU.js} +120 -9
- package/dist/{chunk-KCY53RUE.js → chunk-44ZSQEOS.js} +2 -2
- package/dist/{chunk-JK3U54G7.js → chunk-6ZEW2M6P.js} +167 -39
- package/dist/{chunk-E2YXYU73.js → chunk-HP5UZCXP.js} +29 -0
- package/dist/{chunk-QM5E5RJZ.js → chunk-J3JW3RFP.js} +10 -7
- package/dist/{chunk-IWKSA64G.js → chunk-LCAHTRGP.js} +15 -281
- package/dist/{chunk-AMD4PXDG.js → chunk-LKYOWBD4.js} +15 -15
- package/dist/{chunk-QOA6KOJQ.js → chunk-M7XMV36F.js} +1 -1
- package/dist/chunk-WUK3MQUB.js +249 -0
- package/dist/{cli-command-HXKWB6IP.js → cli-command-DCENRCO3.js} +6 -6
- package/dist/cli.js +6 -6
- package/dist/{config-2PXUENQL.js → config-HXFJTNLM.js} +5 -1
- package/dist/{daemon-JCQF645I.js → daemon-6Y4O7NXS.js} +36 -14
- package/dist/daemon-handle-GVCYVDPO.js +10 -0
- package/dist/server-GXXOWUVZ.js +11 -0
- package/dist/web/assets/{Area-DgGVYaNT.js → Area-CMXvOw33.js} +1 -1
- package/dist/web/assets/{analytics-D5EvgF4d.js → analytics-DqdZXOJL.js} +2 -2
- package/dist/web/assets/{breakdown-CGdJkAHx.js → breakdown-kOSSJ3mI.js} +1 -1
- package/dist/web/assets/{chart-D4KHj2-J.js → chart-cZoLgpmG.js} +1 -1
- package/dist/web/assets/{explore-B2QnGzfO.js → explore-vcsM8K9I.js} +1 -1
- package/dist/web/assets/index-BErCXT7f.css +1 -0
- package/dist/web/assets/index-DH3dOnbg.js +83 -0
- package/dist/web/assets/{models-D7w7JJCX.js → models-B5ikm83_.js} +2 -2
- package/dist/web/assets/{overview-BPz0j397.js → overview-DD1kP8CP.js} +2 -2
- package/dist/web/assets/{panel-Da3rkvLu.js → panel-DTQBwExW.js} +1 -1
- package/dist/web/assets/{primitives-B8eGD8S_.js → primitives-C36qJlA2.js} +1 -1
- package/dist/web/assets/settings-sheet-_i2zTQjf.js +1 -0
- package/dist/web/assets/{share-sheet-BXrrMoLk.js → share-sheet-BLHmrFbm.js} +2 -2
- package/dist/web/assets/{timeline-CiGI4EmA.js → timeline-B4uG-Emo.js} +1 -1
- package/dist/web/assets/{use-dialog-trap-Dhs8W7s1.js → use-dialog-trap-bfaXEMz9.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-SMPY52EV.js +0 -125
- package/dist/daemon-handle-2GVZT55B.js +0 -10
- package/dist/server-BJOXAGRI.js +0 -11
- package/dist/web/assets/index-C0txIEHK.js +0 -83
- package/dist/web/assets/index-NnKaHxPO.css +0 -1
- package/dist/web/assets/settings-sheet-D6tnWqmt.js +0 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
PROVIDER_IDS
|
|
4
|
+
} from "./chunk-HP5UZCXP.js";
|
|
5
|
+
|
|
6
|
+
// src/rpc/contract.ts
|
|
7
|
+
import { Schema } from "effect";
|
|
8
|
+
import * as Rpc from "effect/unstable/rpc/Rpc";
|
|
9
|
+
import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
|
|
10
|
+
var TOKMON_WS_PATH = "/ws";
|
|
11
|
+
var TOKMON_PROTOCOL_VERSION = 3;
|
|
12
|
+
var TOKMON_CAPABILITIES = ["config-cas", "config-revision", "allowed-hosts"];
|
|
13
|
+
var TOKMON_WS_METHODS = {
|
|
14
|
+
getConfig: "tokmon.getConfig",
|
|
15
|
+
setConfig: "tokmon.setConfig",
|
|
16
|
+
refresh: "tokmon.refresh",
|
|
17
|
+
browseFs: "tokmon.browseFs",
|
|
18
|
+
snapshot: "tokmon.snapshot",
|
|
19
|
+
config: "tokmon.config"
|
|
20
|
+
};
|
|
21
|
+
var RefreshScopeSchema = Schema.Literals([
|
|
22
|
+
"all",
|
|
23
|
+
"summary",
|
|
24
|
+
"table",
|
|
25
|
+
"billing",
|
|
26
|
+
"peak"
|
|
27
|
+
]);
|
|
28
|
+
var ProviderIdSchema = Schema.Literals(PROVIDER_IDS);
|
|
29
|
+
var NonNegativeIntegerSchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
30
|
+
var PositiveFiniteSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(1));
|
|
31
|
+
var AccountSchema = Schema.Struct({
|
|
32
|
+
id: Schema.String,
|
|
33
|
+
providerId: ProviderIdSchema,
|
|
34
|
+
name: Schema.String,
|
|
35
|
+
homeDir: Schema.String,
|
|
36
|
+
color: Schema.optionalKey(Schema.String)
|
|
37
|
+
});
|
|
38
|
+
var ConfigSchema = Schema.Struct({
|
|
39
|
+
revision: NonNegativeIntegerSchema,
|
|
40
|
+
interval: PositiveFiniteSchema,
|
|
41
|
+
billingInterval: PositiveFiniteSchema,
|
|
42
|
+
clearScreen: Schema.Boolean,
|
|
43
|
+
privacyMode: Schema.Boolean,
|
|
44
|
+
privacyToggleKey: Schema.String,
|
|
45
|
+
timezone: Schema.NullOr(Schema.String),
|
|
46
|
+
accounts: Schema.Array(AccountSchema),
|
|
47
|
+
activeAccountId: Schema.NullOr(Schema.String),
|
|
48
|
+
disabledProviders: Schema.Array(ProviderIdSchema),
|
|
49
|
+
onboarded: Schema.Boolean,
|
|
50
|
+
dashboardLayout: Schema.Literals(["grid", "single"]),
|
|
51
|
+
defaultFocus: Schema.Literals(["all", "last"]),
|
|
52
|
+
ascii: Schema.Literals(["auto", "on", "off"]),
|
|
53
|
+
allowNetworkAccess: Schema.Boolean,
|
|
54
|
+
allowedHosts: Schema.Array(Schema.String),
|
|
55
|
+
resetDisplay: Schema.Literals(["relative", "absolute"]),
|
|
56
|
+
knownProviders: Schema.Array(ProviderIdSchema)
|
|
57
|
+
});
|
|
58
|
+
var ProtocolInfoSchema = Schema.Struct({
|
|
59
|
+
version: Schema.Literal(TOKMON_PROTOCOL_VERSION),
|
|
60
|
+
// Capabilities are additive within a protocol version. Older clients must
|
|
61
|
+
// preserve forward compatibility when a newer daemon advertises one they do
|
|
62
|
+
// not understand yet.
|
|
63
|
+
capabilities: Schema.Array(Schema.String)
|
|
64
|
+
});
|
|
65
|
+
var ConfigStateSchema = Schema.Struct({
|
|
66
|
+
protocol: ProtocolInfoSchema,
|
|
67
|
+
config: ConfigSchema
|
|
68
|
+
});
|
|
69
|
+
var ConfigUpdateRequestSchema = Schema.Struct({
|
|
70
|
+
expectedRevision: NonNegativeIntegerSchema,
|
|
71
|
+
config: ConfigSchema
|
|
72
|
+
});
|
|
73
|
+
var ConfigUpdateConflictSchema = Schema.Struct({
|
|
74
|
+
kind: Schema.Literal("conflict"),
|
|
75
|
+
state: ConfigStateSchema
|
|
76
|
+
});
|
|
77
|
+
var ConfigPersistenceFailureSchema = Schema.Struct({
|
|
78
|
+
kind: Schema.Literal("persistence"),
|
|
79
|
+
message: Schema.String
|
|
80
|
+
});
|
|
81
|
+
var FsEntrySchema = Schema.Struct({
|
|
82
|
+
name: Schema.String,
|
|
83
|
+
path: Schema.String,
|
|
84
|
+
dir: Schema.Boolean
|
|
85
|
+
});
|
|
86
|
+
var FsListingSchema = Schema.Struct({
|
|
87
|
+
path: Schema.String,
|
|
88
|
+
parent: Schema.NullOr(Schema.String),
|
|
89
|
+
entries: Schema.Array(FsEntrySchema)
|
|
90
|
+
});
|
|
91
|
+
var UsageSummarySchema = Schema.Struct({
|
|
92
|
+
cost: Schema.Finite,
|
|
93
|
+
tokens: Schema.Finite,
|
|
94
|
+
input: Schema.Finite,
|
|
95
|
+
cacheRead: Schema.Finite,
|
|
96
|
+
cacheSavings: Schema.Finite
|
|
97
|
+
});
|
|
98
|
+
var ModelDetailSchema = Schema.Struct({
|
|
99
|
+
name: Schema.String,
|
|
100
|
+
input: Schema.Finite,
|
|
101
|
+
output: Schema.Finite,
|
|
102
|
+
cacheCreate: Schema.Finite,
|
|
103
|
+
cacheRead: Schema.Finite,
|
|
104
|
+
cacheSavings: Schema.Finite,
|
|
105
|
+
cost: Schema.Finite,
|
|
106
|
+
count: Schema.Finite
|
|
107
|
+
});
|
|
108
|
+
var TableRowSchema = Schema.Struct({
|
|
109
|
+
label: Schema.String,
|
|
110
|
+
models: Schema.Array(Schema.String),
|
|
111
|
+
input: Schema.Finite,
|
|
112
|
+
output: Schema.Finite,
|
|
113
|
+
cacheCreate: Schema.Finite,
|
|
114
|
+
cacheRead: Schema.Finite,
|
|
115
|
+
cacheSavings: Schema.Finite,
|
|
116
|
+
total: Schema.Finite,
|
|
117
|
+
cost: Schema.Finite,
|
|
118
|
+
count: Schema.Finite,
|
|
119
|
+
breakdown: Schema.Array(ModelDetailSchema)
|
|
120
|
+
});
|
|
121
|
+
var DashboardDataSchema = Schema.Struct({
|
|
122
|
+
today: UsageSummarySchema,
|
|
123
|
+
week: UsageSummarySchema,
|
|
124
|
+
month: UsageSummarySchema,
|
|
125
|
+
burnRate: Schema.Finite,
|
|
126
|
+
series: Schema.Array(Schema.Finite)
|
|
127
|
+
});
|
|
128
|
+
var TableDataSchema = Schema.Struct({
|
|
129
|
+
daily: Schema.Array(TableRowSchema),
|
|
130
|
+
weekly: Schema.Array(TableRowSchema),
|
|
131
|
+
monthly: Schema.Array(TableRowSchema)
|
|
132
|
+
});
|
|
133
|
+
var MetricFormatSchema = Schema.Union([
|
|
134
|
+
Schema.Struct({ kind: Schema.Literal("percent") }),
|
|
135
|
+
Schema.Struct({ kind: Schema.Literal("dollars"), currency: Schema.optionalKey(Schema.String) }),
|
|
136
|
+
Schema.Struct({ kind: Schema.Literal("count"), suffix: Schema.optionalKey(Schema.String) })
|
|
137
|
+
]);
|
|
138
|
+
var MetricSchema = Schema.Struct({
|
|
139
|
+
label: Schema.String,
|
|
140
|
+
used: Schema.Finite,
|
|
141
|
+
limit: Schema.NullOr(Schema.Finite),
|
|
142
|
+
format: MetricFormatSchema,
|
|
143
|
+
resetsAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
144
|
+
primary: Schema.optionalKey(Schema.Boolean)
|
|
145
|
+
});
|
|
146
|
+
var BillingResultSchema = Schema.Struct({
|
|
147
|
+
plan: Schema.NullOr(Schema.String),
|
|
148
|
+
metrics: Schema.Array(MetricSchema),
|
|
149
|
+
error: Schema.NullOr(Schema.String),
|
|
150
|
+
email: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
151
|
+
displayName: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
152
|
+
activity: Schema.optionalKey(Schema.NullOr(Schema.Struct({
|
|
153
|
+
series: Schema.Array(Schema.Finite),
|
|
154
|
+
summary: Schema.String
|
|
155
|
+
}))),
|
|
156
|
+
modelSpend: Schema.optionalKey(Schema.NullOr(Schema.Array(Schema.Struct({
|
|
157
|
+
name: Schema.String,
|
|
158
|
+
usd: Schema.Finite,
|
|
159
|
+
requests: Schema.Finite
|
|
160
|
+
})))),
|
|
161
|
+
asOfMs: Schema.optionalKey(Schema.Finite)
|
|
162
|
+
});
|
|
163
|
+
var WebAccountSchema = Schema.Struct({
|
|
164
|
+
id: Schema.String,
|
|
165
|
+
providerId: ProviderIdSchema,
|
|
166
|
+
name: Schema.String,
|
|
167
|
+
color: Schema.String,
|
|
168
|
+
homeDir: Schema.NullOr(Schema.String),
|
|
169
|
+
hasUsage: Schema.Boolean,
|
|
170
|
+
hasBilling: Schema.Boolean,
|
|
171
|
+
email: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
172
|
+
displayName: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
173
|
+
plan: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
174
|
+
dashboard: Schema.NullOr(DashboardDataSchema),
|
|
175
|
+
table: Schema.NullOr(TableDataSchema),
|
|
176
|
+
billing: Schema.NullOr(BillingResultSchema),
|
|
177
|
+
summaryState: Schema.Literals(["pending", "ready", "error"]),
|
|
178
|
+
billingState: Schema.Literals(["pending", "ready", "error"]),
|
|
179
|
+
tableState: Schema.Literals(["pending", "ready", "error"]),
|
|
180
|
+
summaryUpdatedAt: Schema.optionalKey(Schema.NullOr(NonNegativeIntegerSchema)),
|
|
181
|
+
billingUpdatedAt: Schema.optionalKey(Schema.NullOr(NonNegativeIntegerSchema)),
|
|
182
|
+
tableUpdatedAt: Schema.optionalKey(Schema.NullOr(NonNegativeIntegerSchema))
|
|
183
|
+
});
|
|
184
|
+
var WebSnapshotSchema = Schema.Struct({
|
|
185
|
+
version: Schema.String,
|
|
186
|
+
generatedAt: NonNegativeIntegerSchema,
|
|
187
|
+
tz: Schema.String,
|
|
188
|
+
intervalMs: PositiveFiniteSchema,
|
|
189
|
+
billingIntervalMs: Schema.optionalKey(PositiveFiniteSchema),
|
|
190
|
+
providers: Schema.Array(Schema.Struct({
|
|
191
|
+
id: ProviderIdSchema,
|
|
192
|
+
name: Schema.String,
|
|
193
|
+
color: Schema.String
|
|
194
|
+
})),
|
|
195
|
+
accounts: Schema.Array(WebAccountSchema),
|
|
196
|
+
seeded: Schema.Boolean,
|
|
197
|
+
peak: Schema.NullOr(Schema.Struct({
|
|
198
|
+
state: Schema.Literals(["peak", "off-peak", "weekend"]),
|
|
199
|
+
label: Schema.String,
|
|
200
|
+
// The upstream clock is only normalized to a finite number; do not make
|
|
201
|
+
// the wire contract narrower than the producer's declared type.
|
|
202
|
+
minutesUntilChange: Schema.NullOr(Schema.Finite),
|
|
203
|
+
changesAt: Schema.optionalKey(Schema.NullOr(Schema.String))
|
|
204
|
+
}))
|
|
205
|
+
});
|
|
206
|
+
var EmptyPayloadSchema = Schema.Struct({});
|
|
207
|
+
var GetConfigRpc = Rpc.make(TOKMON_WS_METHODS.getConfig, {
|
|
208
|
+
payload: EmptyPayloadSchema,
|
|
209
|
+
success: ConfigStateSchema
|
|
210
|
+
});
|
|
211
|
+
var SetConfigRpc = Rpc.make(TOKMON_WS_METHODS.setConfig, {
|
|
212
|
+
payload: ConfigUpdateRequestSchema,
|
|
213
|
+
success: ConfigStateSchema,
|
|
214
|
+
error: Schema.Union([ConfigUpdateConflictSchema, ConfigPersistenceFailureSchema])
|
|
215
|
+
});
|
|
216
|
+
var RefreshRpc = Rpc.make(TOKMON_WS_METHODS.refresh, {
|
|
217
|
+
payload: Schema.Struct({ scope: RefreshScopeSchema }),
|
|
218
|
+
success: Schema.Void
|
|
219
|
+
});
|
|
220
|
+
var BrowseFsRpc = Rpc.make(TOKMON_WS_METHODS.browseFs, {
|
|
221
|
+
payload: Schema.Struct({ path: Schema.String }),
|
|
222
|
+
success: FsListingSchema
|
|
223
|
+
});
|
|
224
|
+
var SnapshotRpc = Rpc.make(TOKMON_WS_METHODS.snapshot, {
|
|
225
|
+
payload: EmptyPayloadSchema,
|
|
226
|
+
success: WebSnapshotSchema,
|
|
227
|
+
stream: true
|
|
228
|
+
});
|
|
229
|
+
var ConfigRpc = Rpc.make(TOKMON_WS_METHODS.config, {
|
|
230
|
+
payload: EmptyPayloadSchema,
|
|
231
|
+
success: ConfigStateSchema,
|
|
232
|
+
stream: true
|
|
233
|
+
});
|
|
234
|
+
var TokmonRpcGroup = RpcGroup.make(
|
|
235
|
+
GetConfigRpc,
|
|
236
|
+
SetConfigRpc,
|
|
237
|
+
RefreshRpc,
|
|
238
|
+
BrowseFsRpc,
|
|
239
|
+
SnapshotRpc,
|
|
240
|
+
ConfigRpc
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
TOKMON_WS_PATH,
|
|
245
|
+
TOKMON_PROTOCOL_VERSION,
|
|
246
|
+
TOKMON_CAPABILITIES,
|
|
247
|
+
TOKMON_WS_METHODS,
|
|
248
|
+
TokmonRpcGroup
|
|
249
|
+
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
attachOrSpawn
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-SMPY52EV.js";
|
|
4
|
+
} from "./chunk-LKYOWBD4.js";
|
|
5
|
+
import "./chunk-J3JW3RFP.js";
|
|
7
6
|
import {
|
|
8
7
|
createDaemonRpcClient
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-M7XMV36F.js";
|
|
10
9
|
import {
|
|
11
10
|
PROVIDERS,
|
|
12
11
|
antigravityStateDb,
|
|
@@ -26,11 +25,12 @@ import {
|
|
|
26
25
|
startOfMonth,
|
|
27
26
|
startOfWeek,
|
|
28
27
|
withTimeout
|
|
29
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-LCAHTRGP.js";
|
|
29
|
+
import "./chunk-WUK3MQUB.js";
|
|
30
30
|
import {
|
|
31
31
|
PROVIDER_IDS,
|
|
32
32
|
configLocation
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-HP5UZCXP.js";
|
|
34
34
|
|
|
35
35
|
// src/provider-locations.ts
|
|
36
36
|
import { access } from "fs/promises";
|
package/dist/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ function validateServeArgs(serveArgs) {
|
|
|
41
41
|
}
|
|
42
42
|
async function main() {
|
|
43
43
|
if (subcommand && ["usage", "models", "query", "providers", "snapshot", "config"].includes(subcommand)) {
|
|
44
|
-
const { runQueryCommand } = await import("./cli-command-
|
|
44
|
+
const { runQueryCommand } = await import("./cli-command-DCENRCO3.js");
|
|
45
45
|
try {
|
|
46
46
|
const output = await runQueryCommand(
|
|
47
47
|
subcommand,
|
|
@@ -60,14 +60,14 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (subcommand === "__daemon") {
|
|
63
|
-
const { runDaemon } = await import("./daemon-
|
|
63
|
+
const { runDaemon } = await import("./daemon-6Y4O7NXS.js");
|
|
64
64
|
await runDaemon(args.slice(1), { foreground: false });
|
|
65
65
|
process.exitCode ??= 0;
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (subcommand === "serve" || subcommand === "web") {
|
|
69
69
|
validateServeArgs(args.slice(1));
|
|
70
|
-
const { runDaemon } = await import("./daemon-
|
|
70
|
+
const { runDaemon } = await import("./daemon-6Y4O7NXS.js");
|
|
71
71
|
await runDaemon(args.slice(1), { foreground: true });
|
|
72
72
|
process.exitCode ??= 0;
|
|
73
73
|
return;
|
|
@@ -115,9 +115,9 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
const { loadConfig } = await import("./config-
|
|
118
|
+
const { loadConfig } = await import("./config-HXFJTNLM.js");
|
|
119
119
|
const { resolveGlyphs, setGlyphs } = await import("./glyphs-NKCSZLGO.js");
|
|
120
|
-
const { attachOrSpawn } = await import("./daemon-handle-
|
|
120
|
+
const { attachOrSpawn } = await import("./daemon-handle-GVCYVDPO.js");
|
|
121
121
|
const config = await loadConfig();
|
|
122
122
|
setGlyphs(resolveGlyphs({
|
|
123
123
|
flag: asciiFlag,
|
|
@@ -128,7 +128,7 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
128
128
|
}));
|
|
129
129
|
const daemon = await attachOrSpawn();
|
|
130
130
|
const mode = daemon.kind === "spawned" ? "connected" : "degraded";
|
|
131
|
-
const { bootstrapInk } = await import("./bootstrap-ink-
|
|
131
|
+
const { bootstrapInk } = await import("./bootstrap-ink-IMT3S5HU.js");
|
|
132
132
|
await bootstrapInk({ interval, config, daemon, mode });
|
|
133
133
|
}
|
|
134
134
|
void main().catch((error) => {
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
generateAccountId,
|
|
16
16
|
getTrackedAccountRows,
|
|
17
17
|
loadConfig,
|
|
18
|
+
normalizeAllowedHost,
|
|
19
|
+
normalizeAllowedHosts,
|
|
18
20
|
normalizeConfig,
|
|
19
21
|
pickAccentColor,
|
|
20
22
|
redactEmail,
|
|
@@ -24,7 +26,7 @@ import {
|
|
|
24
26
|
saveConfigSync,
|
|
25
27
|
slugify,
|
|
26
28
|
snapshotCacheFile
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-HP5UZCXP.js";
|
|
28
30
|
export {
|
|
29
31
|
ACCENT_COLORS,
|
|
30
32
|
COLOR_PALETTE,
|
|
@@ -41,6 +43,8 @@ export {
|
|
|
41
43
|
generateAccountId,
|
|
42
44
|
getTrackedAccountRows,
|
|
43
45
|
loadConfig,
|
|
46
|
+
normalizeAllowedHost,
|
|
47
|
+
normalizeAllowedHosts,
|
|
44
48
|
normalizeConfig,
|
|
45
49
|
pickAccentColor,
|
|
46
50
|
redactEmail,
|
|
@@ -8,20 +8,22 @@ import {
|
|
|
8
8
|
unlinkLock,
|
|
9
9
|
verifyLock,
|
|
10
10
|
writeLock
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-J3JW3RFP.js";
|
|
12
12
|
import {
|
|
13
|
+
appVersion,
|
|
13
14
|
startWebServer
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import
|
|
16
|
-
appVersion
|
|
17
|
-
} from "./chunk-SMPY52EV.js";
|
|
18
|
-
import "./chunk-KCY53RUE.js";
|
|
15
|
+
} from "./chunk-6ZEW2M6P.js";
|
|
16
|
+
import "./chunk-44ZSQEOS.js";
|
|
19
17
|
import {
|
|
20
18
|
flushDisk
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-LCAHTRGP.js";
|
|
20
|
+
import {
|
|
21
|
+
TOKMON_CAPABILITIES,
|
|
22
|
+
TOKMON_PROTOCOL_VERSION
|
|
23
|
+
} from "./chunk-WUK3MQUB.js";
|
|
22
24
|
import {
|
|
23
25
|
loadConfig
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HP5UZCXP.js";
|
|
25
27
|
|
|
26
28
|
// src/web/daemon.ts
|
|
27
29
|
import { randomBytes } from "crypto";
|
|
@@ -75,7 +77,16 @@ Options:
|
|
|
75
77
|
-h, --help Show this help
|
|
76
78
|
`;
|
|
77
79
|
function handshake(lock) {
|
|
78
|
-
process.stdout.write(JSON.stringify({
|
|
80
|
+
process.stdout.write(JSON.stringify({
|
|
81
|
+
ready: 1,
|
|
82
|
+
url: lock.url,
|
|
83
|
+
port: lock.port,
|
|
84
|
+
wsToken: lock.wsToken,
|
|
85
|
+
version: lock.version,
|
|
86
|
+
protocolVersion: lock.protocolVersion,
|
|
87
|
+
capabilities: lock.capabilities,
|
|
88
|
+
ownerKind: lock.ownerKind
|
|
89
|
+
}) + "\n");
|
|
79
90
|
}
|
|
80
91
|
function describeExisting(lock, open) {
|
|
81
92
|
process.stdout.write(`
|
|
@@ -96,16 +107,16 @@ async function runDaemon(args, opts) {
|
|
|
96
107
|
const version = appVersion();
|
|
97
108
|
let current = readLock();
|
|
98
109
|
if (!current && reclaimAbandonedLock()) current = readLock();
|
|
99
|
-
const live = await verifyLock(current,
|
|
110
|
+
const live = await verifyLock(current, TOKMON_PROTOCOL_VERSION);
|
|
100
111
|
if (live) {
|
|
101
112
|
if (opts.foreground) describeExisting(live, open);
|
|
102
113
|
else handshake(live);
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
105
|
-
if (current?.state === "starting" && current.
|
|
116
|
+
if (current?.state === "starting" && current.protocolVersion === TOKMON_PROTOCOL_VERSION && isAlive(current.pid)) {
|
|
106
117
|
for (let attempt = 0; attempt < 60; attempt++) {
|
|
107
118
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
108
|
-
const winner = await verifyLock(readLock(),
|
|
119
|
+
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
109
120
|
if (winner) {
|
|
110
121
|
if (opts.foreground) describeExisting(winner, open);
|
|
111
122
|
else handshake(winner);
|
|
@@ -130,6 +141,9 @@ async function runDaemon(args, opts) {
|
|
|
130
141
|
url: "",
|
|
131
142
|
wsToken: token,
|
|
132
143
|
version,
|
|
144
|
+
protocolVersion: TOKMON_PROTOCOL_VERSION,
|
|
145
|
+
capabilities: [...TOKMON_CAPABILITIES],
|
|
146
|
+
ownerKind: "cli",
|
|
133
147
|
startedAt: Date.now(),
|
|
134
148
|
ownerId,
|
|
135
149
|
state: "starting"
|
|
@@ -137,7 +151,7 @@ async function runDaemon(args, opts) {
|
|
|
137
151
|
if (!acquireLock(reservation)) {
|
|
138
152
|
for (let attempt = 0; attempt < 60; attempt++) {
|
|
139
153
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
140
|
-
const winner = await verifyLock(readLock(),
|
|
154
|
+
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
141
155
|
if (winner) {
|
|
142
156
|
if (opts.foreground) describeExisting(winner, open);
|
|
143
157
|
else handshake(winner);
|
|
@@ -153,7 +167,15 @@ async function runDaemon(args, opts) {
|
|
|
153
167
|
let controller = null;
|
|
154
168
|
try {
|
|
155
169
|
const config = await loadConfig();
|
|
156
|
-
controller = await startWebServer({
|
|
170
|
+
controller = await startWebServer({
|
|
171
|
+
config,
|
|
172
|
+
port,
|
|
173
|
+
log: opts.foreground,
|
|
174
|
+
wsToken: token,
|
|
175
|
+
ownerKind: reservation.ownerKind,
|
|
176
|
+
protocolVersion: reservation.protocolVersion,
|
|
177
|
+
capabilities: reservation.capabilities
|
|
178
|
+
});
|
|
157
179
|
const ready = {
|
|
158
180
|
...reservation,
|
|
159
181
|
port: controller.port,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as v,r as ht}from"./index-
|
|
1
|
+
import{R as v,r as ht}from"./index-DH3dOnbg.js";import{j as J,c as Q,D as vt,J as jt,W as kt,L as F,d as I,q as G,w as dt,y as N,z as nt,t as U,$ as yt,E as mt,v as Z,F as bt,H as gt,_ as tt,a0 as q,B as V,a1 as Lt}from"./chart-cZoLgpmG.js";var $t=["type","layout","connectNulls","ref"],Nt=["key"];function K(t){"@babel/helpers - typeof";return K=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},K(t)}function lt(t,r){if(t==null)return{};var n=It(t,r),e,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)e=o[a],!(r.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}function It(t,r){if(t==null)return{};var n={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(r.indexOf(e)>=0)continue;n[e]=t[e]}return n}function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},Y.apply(this,arguments)}function ut(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function j(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ut(Object(n),!0).forEach(function(e){$(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ut(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function z(t){return Ct(t)||Tt(t)||Rt(t)||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 Rt(t,r){if(t){if(typeof t=="string")return at(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return at(t,r)}}function Tt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ct(t){if(Array.isArray(t))return at(t)}function at(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function Wt(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function ct(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,xt(e.key),e)}}function Ft(t,r,n){return r&&ct(t.prototype,r),n&&ct(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Mt(t,r,n){return r=et(r),zt(t,At()?Reflect.construct(r,n||[],et(t).constructor):r.apply(t,n))}function zt(t,r){if(r&&(K(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Vt(t)}function Vt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function At(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(At=function(){return!!t})()}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},et(t)}function Kt(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&it(t,r)}function it(t,r){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,a){return e.__proto__=a,e},it(t,r)}function $(t,r,n){return r=xt(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function xt(t){var r=Ht(t,"string");return K(r)=="symbol"?r:r+""}function Ht(t,r){if(K(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var e=n.call(t,r);if(K(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var st=(function(t){function r(){var n;Wt(this,r);for(var e=arguments.length,a=new Array(e),o=0;o<e;o++)a[o]=arguments[o];return n=Mt(this,r,[].concat(a)),$(n,"state",{isAnimationFinished:!0,totalLength:0}),$(n,"generateSimpleStrokeDasharray",function(i,s){return"".concat(s,"px ").concat(i-s,"px")}),$(n,"getStrokeDasharray",function(i,s,l){var u=l.reduce(function(x,A){return x+A});if(!u)return n.generateSimpleStrokeDasharray(s,i);for(var f=Math.floor(i/u),c=i%u,p=s-i,d=[],h=0,y=0;h<l.length;y+=l[h],++h)if(y+l[h]>c){d=[].concat(z(l.slice(0,h)),[c-y]);break}var b=d.length%2===0?[0,p]:[p];return[].concat(z(r.repeat(l,f)),z(d),b).map(function(x){return"".concat(x,"px")}).join(", ")}),$(n,"id",bt("recharts-line-")),$(n,"pathRef",function(i){n.mainCurve=i}),$(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),$(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Kt(r,t),Ft(r,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();this.setState({totalLength:e})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();e!==this.state.totalLength&&this.setState({totalLength:e})}}},{key:"getTotalLength",value:function(){var e=this.mainCurve;try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(e,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,s=o.xAxis,l=o.yAxis,u=o.layout,f=o.children,c=jt(f,kt);if(!c)return null;var p=function(y,b){return{x:y.x,y:y.y,value:y.value,errorVal:Z(y.payload,b)}},d={clipPath:e?"url(#clipPath-".concat(a,")"):null};return v.createElement(F,d,c.map(function(h){return v.cloneElement(h,{key:"bar-".concat(h.props.dataKey),data:i,xAxis:s,yAxis:l,layout:u,dataPointFormatter:p})}))}},{key:"renderDots",value:function(e,a,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var s=this.props,l=s.dot,u=s.points,f=s.dataKey,c=I(this.props,!1),p=I(l,!0),d=u.map(function(y,b){var x=j(j(j({key:"dot-".concat(b),r:3},c),p),{},{index:b,cx:y.x,cy:y.y,value:y.value,dataKey:f,payload:y.payload,points:u});return r.renderDotItem(l,x)}),h={clipPath:e?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return v.createElement(F,Y({className:"recharts-line-dots",key:"dots"},h),d)}},{key:"renderCurveStatically",value:function(e,a,o,i){var s=this.props,l=s.type,u=s.layout,f=s.connectNulls;s.ref;var c=lt(s,$t),p=j(j(j({},I(c,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:e},i),{},{type:l,layout:u,connectNulls:f});return v.createElement(G,Y({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(e,a){var o=this,i=this.props,s=i.points,l=i.strokeDasharray,u=i.isAnimationActive,f=i.animationBegin,c=i.animationDuration,p=i.animationEasing,d=i.animationId,h=i.animateNewValues,y=i.width,b=i.height,x=this.state,A=x.prevPoints,_=x.totalLength;return v.createElement(dt,{begin:f,duration:c,isActive:u,easing:p,from:{t:0},to:{t:1},key:"line-".concat(d),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(g){var m=g.t;if(A){var P=A.length/s.length,w=s.map(function(O,R){var T=Math.floor(R*P);if(A[T]){var C=A[T],L=N(C.x,O.x),_t=N(C.y,O.y);return j(j({},O),{},{x:L(m),y:_t(m)})}if(h){var Et=N(y*2,O.x),Dt=N(b/2,O.y);return j(j({},O),{},{x:Et(m),y:Dt(m)})}return j(j({},O),{},{x:O.x,y:O.y})});return o.renderCurveStatically(w,e,a)}var S=N(0,_),k=S(m),E;if(l){var D="".concat(l).split(/[,\s]+/gim).map(function(O){return parseFloat(O)});E=o.getStrokeDasharray(k,_,D)}else E=o.generateSimpleStrokeDasharray(_,k);return o.renderCurveStatically(s,e,a,{strokeDasharray:E})})}},{key:"renderCurve",value:function(e,a){var o=this.props,i=o.points,s=o.isAnimationActive,l=this.state,u=l.prevPoints,f=l.totalLength;return s&&i&&i.length&&(!u&&f>0||!nt(u,i))?this.renderCurveWithAnimation(e,a):this.renderCurveStatically(i,e,a)}},{key:"render",value:function(){var e,a=this.props,o=a.hide,i=a.dot,s=a.points,l=a.className,u=a.xAxis,f=a.yAxis,c=a.top,p=a.left,d=a.width,h=a.height,y=a.isAnimationActive,b=a.id;if(o||!s||!s.length)return null;var x=this.state.isAnimationFinished,A=s.length===1,_=Q("recharts-line",l),g=u&&u.allowDataOverflow,m=f&&f.allowDataOverflow,P=g||m,w=U(b)?this.id:b,S=(e=I(i,!1))!==null&&e!==void 0?e:{r:3,strokeWidth:2},k=S.r,E=k===void 0?3:k,D=S.strokeWidth,O=D===void 0?2:D,R=yt(i)?i:{},T=R.clipDot,C=T===void 0?!0:T,L=E*2+O;return v.createElement(F,{className:_},g||m?v.createElement("defs",null,v.createElement("clipPath",{id:"clipPath-".concat(w)},v.createElement("rect",{x:g?p:p-d/2,y:m?c:c-h/2,width:g?d:d*2,height:m?h:h*2})),!C&&v.createElement("clipPath",{id:"clipPath-dots-".concat(w)},v.createElement("rect",{x:p-L/2,y:c-L/2,width:d+L,height:h+L}))):null,!A&&this.renderCurve(P,w),this.renderErrorBar(P,w),(A||i)&&this.renderDots(P,C,w),(!y||x)&&mt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(e,a){return e.animationId!==a.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,prevPoints:a.curPoints}:e.points!==a.curPoints?{curPoints:e.points}:null}},{key:"repeat",value:function(e,a){for(var o=e.length%2!==0?[].concat(z(e),[0]):e,i=[],s=0;s<a;++s)i=[].concat(z(i),z(o));return i}},{key:"renderDotItem",value:function(e,a){var o;if(v.isValidElement(e))o=v.cloneElement(e,a);else if(J(e))o=e(a);else{var i=a.key,s=lt(a,Nt),l=Q("recharts-line-dot",typeof e!="boolean"?e.className:"");o=v.createElement(vt,Y({key:i},s,{className:l}))}return o}}])})(ht.PureComponent);$(st,"displayName","Line");$(st,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!gt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(st,"getComposedData",function(t){var r=t.props,n=t.xAxis,e=t.yAxis,a=t.xAxisTicks,o=t.yAxisTicks,i=t.dataKey,s=t.bandSize,l=t.displayedData,u=t.offset,f=r.layout,c=l.map(function(p,d){var h=Z(p,i);return f==="horizontal"?{x:tt({axis:n,ticks:a,bandSize:s,entry:p,index:d}),y:U(h)?null:e.scale(h),value:h,payload:p}:{x:U(h)?null:n.scale(h),y:tt({axis:e,ticks:o,bandSize:s,entry:p,index:d}),value:h,payload:p}});return j({points:c,layout:f},u)});var Xt=["layout","type","stroke","connectNulls","isRange","ref"],Yt=["key"],Pt;function H(t){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},H(t)}function Ot(t,r){if(t==null)return{};var n=Ut(t,r),e,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)e=o[a],!(r.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}function Ut(t,r){if(t==null)return{};var n={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(r.indexOf(e)>=0)continue;n[e]=t[e]}return n}function M(){return M=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},M.apply(this,arguments)}function ft(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function W(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ft(Object(n),!0).forEach(function(e){B(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ft(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function qt(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function pt(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,St(e.key),e)}}function Gt(t,r,n){return r&&pt(t.prototype,r),n&&pt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Jt(t,r,n){return r=rt(r),Qt(t,wt()?Reflect.construct(r,n||[],rt(t).constructor):r.apply(t,n))}function Qt(t,r){if(r&&(H(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zt(t)}function Zt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(wt=function(){return!!t})()}function rt(t){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},rt(t)}function te(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ot(t,r)}function ot(t,r){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,a){return e.__proto__=a,e},ot(t,r)}function B(t,r,n){return r=St(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function St(t){var r=ee(t,"string");return H(r)=="symbol"?r:r+""}function ee(t,r){if(H(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var e=n.call(t,r);if(H(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var X=(function(t){function r(){var n;qt(this,r);for(var e=arguments.length,a=new Array(e),o=0;o<e;o++)a[o]=arguments[o];return n=Jt(this,r,[].concat(a)),B(n,"state",{isAnimationFinished:!0}),B(n,"id",bt("recharts-area-")),B(n,"handleAnimationEnd",function(){var i=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),J(i)&&i()}),B(n,"handleAnimationStart",function(){var i=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),J(i)&&i()}),n}return te(r,t),Gt(r,[{key:"renderDots",value:function(e,a,o){var i=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(i&&!s)return null;var l=this.props,u=l.dot,f=l.points,c=l.dataKey,p=I(this.props,!1),d=I(u,!0),h=f.map(function(b,x){var A=W(W(W({key:"dot-".concat(x),r:3},p),d),{},{index:x,cx:b.x,cy:b.y,dataKey:c,value:b.value,payload:b.payload,points:f});return r.renderDotItem(u,A)}),y={clipPath:e?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return v.createElement(F,M({className:"recharts-area-dots"},y),h)}},{key:"renderHorizontalRect",value:function(e){var a=this.props,o=a.baseLine,i=a.points,s=a.strokeWidth,l=i[0].x,u=i[i.length-1].x,f=e*Math.abs(l-u),c=q(i.map(function(p){return p.y||0}));return V(o)&&typeof o=="number"?c=Math.max(o,c):o&&Array.isArray(o)&&o.length&&(c=Math.max(q(o.map(function(p){return p.y||0})),c)),V(c)?v.createElement("rect",{x:l<u?l:l-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(e){var a=this.props,o=a.baseLine,i=a.points,s=a.strokeWidth,l=i[0].y,u=i[i.length-1].y,f=e*Math.abs(l-u),c=q(i.map(function(p){return p.x||0}));return V(o)&&typeof o=="number"?c=Math.max(o,c):o&&Array.isArray(o)&&o.length&&(c=Math.max(q(o.map(function(p){return p.x||0})),c)),V(c)?v.createElement("rect",{x:0,y:l<u?l:l-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(e){var a=this.props.layout;return a==="vertical"?this.renderVerticalRect(e):this.renderHorizontalRect(e)}},{key:"renderAreaStatically",value:function(e,a,o,i){var s=this.props,l=s.layout,u=s.type,f=s.stroke,c=s.connectNulls,p=s.isRange;s.ref;var d=Ot(s,Xt);return v.createElement(F,{clipPath:o?"url(#clipPath-".concat(i,")"):null},v.createElement(G,M({},I(d,!0),{points:e,connectNulls:c,type:u,baseLine:a,layout:l,stroke:"none",className:"recharts-area-area"})),f!=="none"&&v.createElement(G,M({},I(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:c,fill:"none",points:e})),f!=="none"&&p&&v.createElement(G,M({},I(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:c,fill:"none",points:a})))}},{key:"renderAreaWithAnimation",value:function(e,a){var o=this,i=this.props,s=i.points,l=i.baseLine,u=i.isAnimationActive,f=i.animationBegin,c=i.animationDuration,p=i.animationEasing,d=i.animationId,h=this.state,y=h.prevPoints,b=h.prevBaseLine;return v.createElement(dt,{begin:f,duration:c,isActive:u,easing:p,from:{t:0},to:{t:1},key:"area-".concat(d),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(x){var A=x.t;if(y){var _=y.length/s.length,g=s.map(function(S,k){var E=Math.floor(k*_);if(y[E]){var D=y[E],O=N(D.x,S.x),R=N(D.y,S.y);return W(W({},S),{},{x:O(A),y:R(A)})}return S}),m;if(V(l)&&typeof l=="number"){var P=N(b,l);m=P(A)}else if(U(l)||Lt(l)){var w=N(b,0);m=w(A)}else m=l.map(function(S,k){var E=Math.floor(k*_);if(b[E]){var D=b[E],O=N(D.x,S.x),R=N(D.y,S.y);return W(W({},S),{},{x:O(A),y:R(A)})}return S});return o.renderAreaStatically(g,m,e,a)}return v.createElement(F,null,v.createElement("defs",null,v.createElement("clipPath",{id:"animationClipPath-".concat(a)},o.renderClipRect(A))),v.createElement(F,{clipPath:"url(#animationClipPath-".concat(a,")")},o.renderAreaStatically(s,l,e,a)))})}},{key:"renderArea",value:function(e,a){var o=this.props,i=o.points,s=o.baseLine,l=o.isAnimationActive,u=this.state,f=u.prevPoints,c=u.prevBaseLine,p=u.totalLength;return l&&i&&i.length&&(!f&&p>0||!nt(f,i)||!nt(c,s))?this.renderAreaWithAnimation(e,a):this.renderAreaStatically(i,s,e,a)}},{key:"render",value:function(){var e,a=this.props,o=a.hide,i=a.dot,s=a.points,l=a.className,u=a.top,f=a.left,c=a.xAxis,p=a.yAxis,d=a.width,h=a.height,y=a.isAnimationActive,b=a.id;if(o||!s||!s.length)return null;var x=this.state.isAnimationFinished,A=s.length===1,_=Q("recharts-area",l),g=c&&c.allowDataOverflow,m=p&&p.allowDataOverflow,P=g||m,w=U(b)?this.id:b,S=(e=I(i,!1))!==null&&e!==void 0?e:{r:3,strokeWidth:2},k=S.r,E=k===void 0?3:k,D=S.strokeWidth,O=D===void 0?2:D,R=yt(i)?i:{},T=R.clipDot,C=T===void 0?!0:T,L=E*2+O;return v.createElement(F,{className:_},g||m?v.createElement("defs",null,v.createElement("clipPath",{id:"clipPath-".concat(w)},v.createElement("rect",{x:g?f:f-d/2,y:m?u:u-h/2,width:g?d:d*2,height:m?h:h*2})),!C&&v.createElement("clipPath",{id:"clipPath-dots-".concat(w)},v.createElement("rect",{x:f-L/2,y:u-L/2,width:d+L,height:h+L}))):null,A?null:this.renderArea(P,w),(i||A)&&this.renderDots(P,C,w),(!y||x)&&mt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(e,a){return e.animationId!==a.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:a.curPoints,prevBaseLine:a.curBaseLine}:e.points!==a.curPoints||e.baseLine!==a.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null}}])})(ht.PureComponent);Pt=X;B(X,"displayName","Area");B(X,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!gt.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});B(X,"getBaseValue",function(t,r,n,e){var a=t.layout,o=t.baseValue,i=r.props.baseValue,s=i??o;if(V(s)&&typeof s=="number")return s;var l=a==="horizontal"?e:n,u=l.scale.domain();if(l.type==="number"){var f=Math.max(u[0],u[1]),c=Math.min(u[0],u[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(u[0],u[1]),0)}return s==="dataMin"?u[0]:s==="dataMax"?u[1]:u[0]});B(X,"getComposedData",function(t){var r=t.props,n=t.item,e=t.xAxis,a=t.yAxis,o=t.xAxisTicks,i=t.yAxisTicks,s=t.bandSize,l=t.dataKey,u=t.stackedData,f=t.dataStartIndex,c=t.displayedData,p=t.offset,d=r.layout,h=u&&u.length,y=Pt.getBaseValue(r,n,e,a),b=d==="horizontal",x=!1,A=c.map(function(g,m){var P;h?P=u[f+m]:(P=Z(g,l),Array.isArray(P)?x=!0:P=[y,P]);var w=P[1]==null||h&&Z(g,l)==null;return b?{x:tt({axis:e,ticks:o,bandSize:s,entry:g,index:m}),y:w?null:a.scale(P[1]),value:P,payload:g}:{x:w?null:e.scale(P[1]),y:tt({axis:a,ticks:i,bandSize:s,entry:g,index:m}),value:P,payload:g}}),_;return h||x?_=A.map(function(g){var m=Array.isArray(g.value)?g.value[0]:null;return b?{x:g.x,y:m!=null&&g.y!=null?a.scale(m):null}:{x:m!=null?e.scale(m):null,y:g.y}}):_=b?a.scale(y):e.scale(y),W({points:A,baseLine:_,layout:d,isRange:x},p)});B(X,"renderDotItem",function(t,r){var n;if(v.isValidElement(t))n=v.cloneElement(t,r);else if(J(t))n=t(r);else{var e=Q("recharts-area-dot",typeof t!="boolean"?t.className:""),a=r.key,o=Ot(r,Yt);n=v.createElement(vt,M({},o,{key:a,className:e}))}return n});export{X as A,st as L};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-
|
|
2
|
-
import{h as D,i as j,k as A,D as k,M as z,r as x,j as e,e as T,f as C,a as E,b as I,m as $,s as B,_ as M}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-kOSSJ3mI.js","./index-DH3dOnbg.js","./index-BErCXT7f.css","./chart-cZoLgpmG.js","./panel-DTQBwExW.js","./primitives-C36qJlA2.js","./timeline-B4uG-Emo.js","./Area-CMXvOw33.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{h as D,i as j,k as A,D as k,M as z,r as x,j as e,e as T,f as C,a as E,b as I,m as $,s as B,_ as M}from"./index-DH3dOnbg.js";import{P as F}from"./panel-DTQBwExW.js";import{a as w}from"./primitives-C36qJlA2.js";const R=[0,.32,.55,.78,1],S=t=>t===0?"var(--color-bg-2)":`color-mix(in oklab, var(--color-cost) ${R[t]*100}%, var(--color-bg-2))`,L=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function O(t,n){const i=t,c=i.filter(l=>n(l)>0);if(c.length===0)return null;const h=i.reduce((l,a)=>l+n(a),0),d=c.reduce((l,a)=>n(a)>n(l)?a:l),p=new Array(7).fill(0);for(const l of i)p[D(j(l.date))]+=n(l);const m=p.indexOf(Math.max(...p)),f=new Set(c.map(l=>l.date));let v=0;for(let l=j(c[c.length-1].date);f.has(A(l));l-=k)v++;return{active:c.length,total:h,top:d,avg:h/c.length,busiest:m,streak:v,costed:t.some(l=>l.cost>0)}}function V(t,n,i){const c=new Map(t.map(s=>[s.date,i(s)]));if(t.length===0)return null;const h=t[t.length-1].date,d=t[0].date;let p=j(h),m=j(d);(p-m)/(k*7)>n&&(m=p-n*7*k),m-=D(m)*k;const f=Math.max(...t.map(i),0),v=s=>{if(s<=0||f<=0)return 0;const r=s/f;return r>.66?4:r>.4?3:r>.15?2:1},l=[];let a=new Array(7).fill(null);const u=[];let b=-1,N=0;for(let s=m;s<=p;s+=k){const r=A(s),o=D(s);o===0&&a.some(Boolean)&&(l.push(a),a=new Array(7).fill(null),N++);const g=new Date(s).getUTCMonth();g!==b&&o===0&&(u.push({col:N,text:z[g]}),b=g);const y=s>=j(d);a[o]=y?{date:r,cost:c.get(r)??0,level:v(c.get(r)??0)}:null}return a.some(Boolean)&&l.push(a),{weeks:l,monthLabels:u}}function H({derived:t,maxWeeks:n=26,periodLabel:i}){const[c,h]=x.useState(null),[d,p]=x.useState(null),m=c??d,f=x.useMemo(()=>new Map(t.calendar.map(s=>[s.date,s])),[t.calendar]),v=x.useMemo(()=>t.calendar.some(s=>s.cost>0),[t.calendar]),l=s=>v?s.cost:s.tokens,a=x.useMemo(()=>O(t.calendar,l),[t,v]),u=x.useMemo(()=>V(t.calendar,n,l),[t,n]),b=u?`repeat(${u.weeks.length}, minmax(0,1fr))`:void 0,N=u?u.weeks.length*25:void 0;return e.jsx(e.Fragment,{children:e.jsx(F,{title:"daily spend",titleTag:i,captureName:"calendar",children:!u||!a?e.jsx("div",{className:"py-6 text-center text-xs text-fg-faint",children:"no usage yet"}):e.jsxs("div",{className:"grid gap-x-8 gap-y-5 pt-1 md:grid-cols-[minmax(0,1fr)_210px] md:items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("div",{className:"pl-6",children:e.jsx("div",{className:"grid gap-[3px] text-[9px] text-fg-faint",style:{gridTemplateColumns:b,maxWidth:N},children:u.weeks.map((s,r)=>{const o=u.monthLabels.find(g=>g.col===r);return e.jsx("div",{className:"truncate",children:(o==null?void 0:o.text)??""},r)})})}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"flex w-5 shrink-0 flex-col gap-[3px] text-[9px] text-fg-faint",children:["M","","W","","F","",""].map((s,r)=>e.jsx("div",{className:"flex flex-1 items-center",children:s},r))}),e.jsx("div",{className:"grid min-w-0 flex-1 gap-[3px]",style:{gridTemplateColumns:b,maxWidth:N},onMouseLeave:()=>h(null),children:u.weeks.map((s,r)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:s.map((o,g)=>o===null?e.jsx("div",{className:"aspect-square"},g):e.jsx("button",{type:"button","aria-label":`${T(o.date)} — click to pin`,"aria-pressed":(d==null?void 0:d.date)===o.date,className:`aspect-square block rounded-[3px] p-0 transition duration-150 hover:scale-[1.18] hover:ring-1 hover:ring-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent ${(d==null?void 0:d.date)===o.date?"ring-1 ring-fg-bright":""}`,style:{background:S(o.level)},onMouseEnter:()=>h(f.get(o.date)??null),onFocus:()=>h(f.get(o.date)??null),onClick:()=>p(y=>(y==null?void 0:y.date)===o.date?null:f.get(o.date)??null)},g))},r))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pl-6 pt-1 text-[9px] text-fg-faint",children:["less",[0,1,2,3,4].map(s=>e.jsx("span",{className:"size-[11px] rounded-[2px]",style:{background:S(s)}},s)),"more"]})]}),e.jsxs("div",{className:"relative border-line-faint md:border-l md:pl-6",children:[e.jsxs("div",{className:`grid grid-cols-2 gap-x-6 gap-y-4 transition-opacity duration-200 md:grid-cols-1 ${m?"opacity-0":"opacity-100"}`,children:[e.jsx(w,{label:"busiest day",value:a.costed?C(a.top.cost):E(a.top.tokens),sub:T(a.top.date),valueClass:"text-cost"}),e.jsx(w,{label:"daily average",value:a.costed?C(a.avg):E(a.avg),sub:`across ${a.active} active days`}),e.jsx(w,{label:"top weekday",value:L[a.busiest],valueClass:"text-fg-bright"}),e.jsx(w,{label:"latest streak",value:`${a.streak}d`,sub:a.streak>0?"in a row":"idle today",valueClass:"text-positive"})]}),m&&e.jsx("div",{className:"dialog-fade absolute inset-0 md:pl-6",children:e.jsx(W,{day:m,pinned:!c&&m===d})})]})]})})})}function W({day:t,pinned:n=!1}){return e.jsxs("div",{className:"font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 border-b border-line-faint pb-2",children:[e.jsxs("span",{className:"text-fg-dim",children:[L[D(j(t.date))]," · ",T(t.date),n&&e.jsx("span",{className:"ml-1.5 text-[9px] uppercase tracking-wide text-accent",children:"pinned"})]}),e.jsx("span",{className:"tnum text-cost",children:t.cost>0?C(t.cost):"—"})]}),t.cost>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"calls"}),e.jsx("div",{className:"tnum text-fg",children:I(t.calls)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"tokens"}),e.jsx("div",{className:"tnum text-fg",children:E(t.tokens)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"saved"}),e.jsx("div",{className:"tnum text-positive",children:C(t.cacheSavings)})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 border-t border-line-faint pt-2",children:[t.models.slice(0,5).map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{background:$(i.name)}}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-dim",children:B(i.name)}),e.jsx("span",{className:"tnum w-16 shrink-0 text-right text-fg",children:C(i.cost)})]},i.name)),t.models.length>5&&e.jsxs("div",{className:"pt-0.5 text-fg-faint",children:["+",t.models.length-5," more"]})]})]}):e.jsx("div",{className:"pt-2 text-fg-faint",children:"no spend this day"})]})}const Y=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.CostByModel}))),q=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.ProviderDonut}))),P=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.TokenComposition}))),G=x.lazy(()=>M(()=>import("./timeline-B4uG-Emo.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CacheSavings}))),K=x.lazy(()=>M(()=>import("./timeline-B4uG-Emo.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CumulativeSpend})));function _({children:t}){return e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"min-h-64",role:"status","aria-label":"Loading chart"}),children:t})}function X({derived:t,scopeLabel:n}){const i=t.byProvider.length>1;return e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx(H,{derived:t,periodLabel:n})}),e.jsx(_,{children:e.jsx(Y,{derived:t,periodLabel:n})}),e.jsx(_,{children:i?e.jsx(q,{derived:t,periodLabel:n}):e.jsx(P,{derived:t,periodLabel:n})}),i?e.jsx(_,{children:e.jsx(P,{derived:t,periodLabel:n})}):null,e.jsx("div",{className:i?void 0:"md:col-span-2",children:e.jsx(_,{children:e.jsx(G,{derived:t,periodLabel:n})})}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(_,{children:e.jsx(K,{derived:t,height:300,periodLabel:n})})})]})}export{X as AnalyticsTab};
|