@cortexkit/opencode-antigravity-auth 3.0.19 → 3.0.21
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 +3 -1
- package/dist/cli.js +277 -150
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +43 -23
- package/dist/index.js +331 -204
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +43 -23
- package/dist/server.js +344 -217
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/src/common-auth-embedded/claustrum/custody.js +45 -6
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +75 -6
- package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/dist/src/common-auth-embedded/source-output.json +73 -53
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +2 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/server.d.ts +4 -4
- package/dist/src/server.js +4 -4
- package/dist/src/tui/quota-layout.d.ts +4 -58
- package/dist/src/tui/quota-layout.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.js +4 -90
- package/dist/src/tui/quota-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts +4 -35
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +91 -171
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +3 -3
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +27 -13
- package/dist/tui-ga-build-map.json +28 -13
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/types/src/server.d.ts +4 -4
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/src/common-auth-embedded/claustrum/custody.js +45 -6
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/src/common-auth-embedded/claustrum/hub.js +75 -6
- package/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/src/common-auth-embedded/opencode2/install.js +144 -17
- package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/common-auth-embedded/source-output.json +73 -53
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +666 -0
- package/src/tui-compiled/tui/quota-layout.js +5 -330
- package/src/tui-compiled/tui/sidebar-frame.js +241 -503
- package/src/tui-compiled/tui.js +3 -3
- package/src/tui-ga-compiled/host-ga.js +2 -3
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -503
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +666 -0
- package/src/tui-ga-raw/host-ga.tsx +2 -3
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +209 -419
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +630 -0
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/tui-raw/tui/quota-layout.tsx +10 -301
- package/src/tui-raw/tui/sidebar-frame.tsx +209 -419
- package/src/tui-raw/tui.tsx +3 -3
- package/src/tui.tsx +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
-
import { createTextNode as _$createTextNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
1
|
import { use as _$use } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
3
|
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
4
|
import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
5
|
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
@@ -9,29 +8,13 @@ import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid"
|
|
|
9
8
|
import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
10
9
|
/** @jsxImportSource @opentui/solid */
|
|
11
10
|
|
|
12
|
-
/**
|
|
13
|
-
* The Antigravity sidebar frame, shared by the OpenCode 1 sidebar (`tui.tsx`)
|
|
14
|
-
* and the OpenCode 2 sidebar (`ga/tui/host-ga.tsx`): the bordered, padded
|
|
15
|
-
* panel, the clickable `▼`/`▶` header badge with the plugin version (or a
|
|
16
|
-
* `LIMITED` badge) at the right, one line per account when collapsed, and the
|
|
17
|
-
* `Quota`, `Routing` and `Health` sections when expanded.
|
|
18
|
-
*
|
|
19
|
-
* Each renderer reads its own data source (the sidebar file, or the
|
|
20
|
-
* location's `state` answer), maps its own host theme onto `FrameTheme` and
|
|
21
|
-
* owns its own collapse state; everything drawn is decided here, so a change
|
|
22
|
-
* of shape is made once for both hosts.
|
|
23
|
-
*
|
|
24
|
-
* This module stays inside both TUI import graphs: besides Solid and
|
|
25
|
-
* OpenTUI it imports only the pure quota and sidebar-projection helpers and
|
|
26
|
-
* the shared layouts. No sidebar file, preferences file, RPC, account
|
|
27
|
-
* store, OAuth, token or host SDK module, no Node built-in, and nothing
|
|
28
|
-
* that writes to the terminal.
|
|
29
|
-
*/
|
|
11
|
+
/** Plugin-owned projection and Routing/Health sections for the shared quota frame. */
|
|
30
12
|
|
|
31
13
|
import { createMemo, createSignal, For, Show } from "opentui:runtime-module:solid-js";
|
|
32
|
-
import {
|
|
14
|
+
import { isQuotaStale, NO_QUOTA_READING } from "../common-auth-embedded/quota/index.js";
|
|
15
|
+
import { SidebarFrame, SidebarSection, SidebarTextRow } from "../common-auth-embedded/quota-sidebar/index.js";
|
|
33
16
|
import { formatResetIn, formatWait } from "../sidebar-projection.js";
|
|
34
|
-
import {
|
|
17
|
+
import { accountWindows, DEFAULT_QUOTA_APPEARANCE, GROUP_NAMES, QUOTA_ORDER, quotaTone } from "./quota-layout.js";
|
|
35
18
|
import { routeLineFits } from "./route-layout.js";
|
|
36
19
|
|
|
37
20
|
// --- Theme -----------------------------------------------------------------
|
|
@@ -45,36 +28,6 @@ import { routeLineFits } from "./route-layout.js";
|
|
|
45
28
|
* sibling token or to the host's default color, never to a fixed color.
|
|
46
29
|
*/
|
|
47
30
|
|
|
48
|
-
// Every tone falls through to a sibling token, so a sparse custom theme still
|
|
49
|
-
// renders readably.
|
|
50
|
-
export function toneColor(theme, tone) {
|
|
51
|
-
switch (tone) {
|
|
52
|
-
case 'ok':
|
|
53
|
-
return theme.success ?? theme.accent;
|
|
54
|
-
case 'warn':
|
|
55
|
-
return theme.warning ?? theme.accent;
|
|
56
|
-
case 'err':
|
|
57
|
-
return theme.error ?? theme.accent;
|
|
58
|
-
case 'muted':
|
|
59
|
-
return theme.textMuted ?? theme.text;
|
|
60
|
-
case 'accent':
|
|
61
|
-
return theme.accent ?? theme.text;
|
|
62
|
-
default:
|
|
63
|
-
return theme.text;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// The shared quota layout reads its colors through this palette. Muted text
|
|
68
|
-
// and the account label read `textMuted` and `text` straight from the theme,
|
|
69
|
-
// without the `toneColor` fallback chain.
|
|
70
|
-
export function themePalette(theme) {
|
|
71
|
-
return {
|
|
72
|
-
text: () => theme().text,
|
|
73
|
-
muted: () => theme().textMuted,
|
|
74
|
-
tone: tone => toneColor(theme(), tone)
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
31
|
// --- Frame inputs ----------------------------------------------------------
|
|
79
32
|
|
|
80
33
|
/** The account fields the frame reads: the quota layout's plus the state. */
|
|
@@ -105,126 +58,6 @@ export const DEFAULT_FRAME_SETTINGS = {
|
|
|
105
58
|
appearance: DEFAULT_QUOTA_APPEARANCE
|
|
106
59
|
};
|
|
107
60
|
|
|
108
|
-
// --- Rows ------------------------------------------------------------------
|
|
109
|
-
|
|
110
|
-
// Section header: bold title, themed text color, top margin for vertical
|
|
111
|
-
// breathing room between sections.
|
|
112
|
-
export function SectionHeader(props) {
|
|
113
|
-
return (() => {
|
|
114
|
-
var _el$ = _$createElement("box"),
|
|
115
|
-
_el$2 = _$createElement("text"),
|
|
116
|
-
_el$3 = _$createElement("b");
|
|
117
|
-
_$insertNode(_el$, _el$2);
|
|
118
|
-
_$setProp(_el$, "width", '100%');
|
|
119
|
-
_$setProp(_el$, "marginTop", 1);
|
|
120
|
-
_$insertNode(_el$2, _el$3);
|
|
121
|
-
_$insert(_el$3, () => props.title);
|
|
122
|
-
_$effect(_$p => _$setProp(_el$2, "fg", toneColor(props.theme(), 'text'), _$p));
|
|
123
|
-
return _el$;
|
|
124
|
-
})();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Muted label left, value (optionally tone-tinted, bold) right, for the
|
|
128
|
-
// routing and health rows.
|
|
129
|
-
export function StatRow(props) {
|
|
130
|
-
return (() => {
|
|
131
|
-
var _el$4 = _$createElement("box"),
|
|
132
|
-
_el$5 = _$createElement("text"),
|
|
133
|
-
_el$6 = _$createElement("text"),
|
|
134
|
-
_el$7 = _$createElement("b");
|
|
135
|
-
_$insertNode(_el$4, _el$5);
|
|
136
|
-
_$insertNode(_el$4, _el$6);
|
|
137
|
-
_$setProp(_el$4, "width", '100%');
|
|
138
|
-
_$setProp(_el$4, "flexDirection", 'row');
|
|
139
|
-
_$setProp(_el$4, "justifyContent", 'space-between');
|
|
140
|
-
_$insert(_el$5, () => props.label);
|
|
141
|
-
_$insertNode(_el$6, _el$7);
|
|
142
|
-
_$insert(_el$7, () => props.value);
|
|
143
|
-
_$effect(_p$ => {
|
|
144
|
-
var _v$ = props.theme().textMuted,
|
|
145
|
-
_v$2 = toneColor(props.theme(), props.tone ?? 'text');
|
|
146
|
-
_v$ !== _p$.e && (_p$.e = _$setProp(_el$5, "fg", _v$, _p$.e));
|
|
147
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$6, "fg", _v$2, _p$.t));
|
|
148
|
-
return _p$;
|
|
149
|
-
}, {
|
|
150
|
-
e: undefined,
|
|
151
|
-
t: undefined
|
|
152
|
-
});
|
|
153
|
-
return _el$4;
|
|
154
|
-
})();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Muted label left, caller-supplied value right. The collapsed view renders
|
|
158
|
-
// one row for every visible account. The caller sizes both sides to the
|
|
159
|
-
// measured width, so neither side may wrap.
|
|
160
|
-
function CollapsedRow(props) {
|
|
161
|
-
return (() => {
|
|
162
|
-
var _el$8 = _$createElement("box"),
|
|
163
|
-
_el$9 = _$createElement("text");
|
|
164
|
-
_$insertNode(_el$8, _el$9);
|
|
165
|
-
_$setProp(_el$8, "width", '100%');
|
|
166
|
-
_$setProp(_el$8, "flexDirection", 'row');
|
|
167
|
-
_$setProp(_el$8, "justifyContent", 'space-between');
|
|
168
|
-
_$setProp(_el$9, "flexShrink", 0);
|
|
169
|
-
_$setProp(_el$9, "wrapMode", 'none');
|
|
170
|
-
_$insert(_el$9, () => props.label);
|
|
171
|
-
_$insert(_el$8, () => props.children, null);
|
|
172
|
-
_$effect(_$p => _$setProp(_el$9, "fg", props.theme().textMuted, _$p));
|
|
173
|
-
return _el$8;
|
|
174
|
-
})();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// One account in the Quota section: the shared quota block, with the status
|
|
178
|
-
// word computed from the account state. Status word priorities (first match
|
|
179
|
-
// wins):
|
|
180
|
-
// - `off` when the account is disabled
|
|
181
|
-
// - `cooling <wait>` when cooldownUntil is still in the future
|
|
182
|
-
// - `active` when current === true
|
|
183
|
-
// - `idle` for the fallback (current === false) case
|
|
184
|
-
function AccountBlock(props) {
|
|
185
|
-
const cooldownMs = () => {
|
|
186
|
-
const cd = props.account.cooldownUntil;
|
|
187
|
-
if (typeof cd !== 'number') return 0;
|
|
188
|
-
return Math.max(0, cd - props.now());
|
|
189
|
-
};
|
|
190
|
-
const statusWord = () => {
|
|
191
|
-
if (!props.account.enabled) return 'off';
|
|
192
|
-
if (cooldownMs() > 0) return `cooling ${formatWait(cooldownMs())}`;
|
|
193
|
-
return props.account.current ? 'active' : 'idle';
|
|
194
|
-
};
|
|
195
|
-
const statusTone = () => {
|
|
196
|
-
if (!props.account.enabled) return 'muted';
|
|
197
|
-
if (cooldownMs() > 0) return 'warn';
|
|
198
|
-
return props.account.current ? 'ok' : 'muted';
|
|
199
|
-
};
|
|
200
|
-
return _$createComponent(QuotaAccountBlock, {
|
|
201
|
-
get palette() {
|
|
202
|
-
return themePalette(props.theme);
|
|
203
|
-
},
|
|
204
|
-
get appearance() {
|
|
205
|
-
return props.appearance;
|
|
206
|
-
},
|
|
207
|
-
get account() {
|
|
208
|
-
return props.account;
|
|
209
|
-
},
|
|
210
|
-
get status() {
|
|
211
|
-
return statusWord();
|
|
212
|
-
},
|
|
213
|
-
get statusTone() {
|
|
214
|
-
return statusTone();
|
|
215
|
-
},
|
|
216
|
-
get now() {
|
|
217
|
-
return props.now;
|
|
218
|
-
},
|
|
219
|
-
get width() {
|
|
220
|
-
return props.width;
|
|
221
|
-
},
|
|
222
|
-
get marginTop() {
|
|
223
|
-
return props.marginTop;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
61
|
// Stored quota values are percentages and epoch-millisecond reset times.
|
|
229
62
|
// Adapt them to the shared projection so common-auth, not the renderer,
|
|
230
63
|
// decides how the narrow line reads.
|
|
@@ -268,390 +101,295 @@ export function sidebarQuotaProjection(account, now) {
|
|
|
268
101
|
};
|
|
269
102
|
}
|
|
270
103
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
now: currentTime
|
|
291
|
-
});
|
|
292
|
-
const dot = unavailable() ? ' ⊘' : ' ●';
|
|
293
|
-
const width = props.width();
|
|
294
|
-
// Keep a complete shared line or omit it; a partial quota can make an
|
|
295
|
-
// account look as if it has less remaining.
|
|
296
|
-
const showQuota = text.length <= width;
|
|
297
|
-
const showDot = dot.length <= width && (!showQuota || text.length + dot.length <= width);
|
|
298
|
-
const rightWidth = (showQuota ? text.length : 0) + (showDot ? dot.length : 0);
|
|
299
|
-
const labelWidth = Math.max(0, width - rightWidth - 1);
|
|
300
|
-
return {
|
|
301
|
-
dot,
|
|
302
|
-
label: fitLabel(account.label, labelWidth),
|
|
303
|
-
showDot,
|
|
304
|
-
showQuota,
|
|
305
|
-
stale,
|
|
306
|
-
text,
|
|
307
|
-
tone
|
|
308
|
-
};
|
|
104
|
+
/** Preserve provider status and projection policy; the library owns all quota layout. */
|
|
105
|
+
function accountView(account, now, appearance) {
|
|
106
|
+
const cooldown = Math.max(0, (account.cooldownUntil ?? 0) - now);
|
|
107
|
+
const status = !account.enabled ? {
|
|
108
|
+
text: 'off',
|
|
109
|
+
tone: 'textMuted'
|
|
110
|
+
} : cooldown > 0 ? {
|
|
111
|
+
text: `cooling ${formatWait(cooldown)}`,
|
|
112
|
+
tone: 'warning'
|
|
113
|
+
} : account.current ? {
|
|
114
|
+
text: 'active',
|
|
115
|
+
tone: 'success'
|
|
116
|
+
} : {
|
|
117
|
+
text: 'idle',
|
|
118
|
+
tone: 'textMuted'
|
|
119
|
+
};
|
|
120
|
+
const quota = sidebarQuotaProjection(account, now);
|
|
121
|
+
const stale = isQuotaStale(quota, {
|
|
122
|
+
now
|
|
309
123
|
});
|
|
310
|
-
const
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
124
|
+
const remaining = quota?.limits.length ? Math.min(...quota.limits.map(limit => limit.remainingPercent ?? 100)) : undefined;
|
|
125
|
+
const quotaColor = remaining === undefined ? 'textMuted' : quotaTone(100 - remaining, appearance);
|
|
126
|
+
const blocked = !account.enabled || cooldown > 0;
|
|
127
|
+
const windows = accountWindows(account, now).filter(({
|
|
128
|
+
reading,
|
|
129
|
+
text
|
|
130
|
+
}) => typeof reading.checkedAt === 'number' && Number.isFinite(reading.checkedAt) && reading.checkedAt >= 0 && text.remaining !== null);
|
|
131
|
+
return {
|
|
132
|
+
id: account.id,
|
|
133
|
+
label: account.label,
|
|
134
|
+
status,
|
|
135
|
+
blocked,
|
|
136
|
+
indicatorTone: stale ? 'textMuted' : blocked ? 'error' : quotaColor,
|
|
137
|
+
quota,
|
|
138
|
+
collapsed: {
|
|
139
|
+
quotaTone: quotaColor,
|
|
140
|
+
muted: stale || status.text !== 'active'
|
|
316
141
|
},
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}), null);
|
|
336
|
-
_$insert(_el$0, _$createComponent(Show, {
|
|
337
|
-
get when() {
|
|
338
|
-
return line().showDot;
|
|
339
|
-
},
|
|
340
|
-
get children() {
|
|
341
|
-
var _el$11 = _$createElement("text");
|
|
342
|
-
_$setProp(_el$11, "flexShrink", 0);
|
|
343
|
-
_$setProp(_el$11, "wrapMode", 'none');
|
|
344
|
-
_$insert(_el$11, () => line().dot);
|
|
345
|
-
_$effect(_$p => _$setProp(_el$11, "fg", dotColor(), _$p));
|
|
346
|
-
return _el$11;
|
|
142
|
+
emptyQuotaText: {
|
|
143
|
+
expanded: NO_QUOTA_READING,
|
|
144
|
+
collapsed: NO_QUOTA_READING
|
|
145
|
+
},
|
|
146
|
+
groups: QUOTA_ORDER.flatMap(key => {
|
|
147
|
+
const rows = windows.filter(window => window.key === key).map(({
|
|
148
|
+
reading,
|
|
149
|
+
text
|
|
150
|
+
}) => ({
|
|
151
|
+
part: {
|
|
152
|
+
kind: 'window',
|
|
153
|
+
name: text.name,
|
|
154
|
+
short: text.name,
|
|
155
|
+
figure: text.figure,
|
|
156
|
+
remainingPercent: text.remaining ?? undefined,
|
|
157
|
+
resetIn: text.reset || undefined,
|
|
158
|
+
checkedAt: reading.checkedAt ?? now,
|
|
159
|
+
resetSinceReading: text.resetSinceReading
|
|
347
160
|
}
|
|
348
|
-
})
|
|
349
|
-
return
|
|
350
|
-
|
|
351
|
-
|
|
161
|
+
}));
|
|
162
|
+
return rows.length ? [{
|
|
163
|
+
title: GROUP_NAMES[key],
|
|
164
|
+
rows
|
|
165
|
+
}] : [];
|
|
166
|
+
})
|
|
167
|
+
};
|
|
352
168
|
}
|
|
353
169
|
|
|
354
170
|
// --- Frame -----------------------------------------------------------------
|
|
355
171
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
172
|
+
function StatRow(props) {
|
|
173
|
+
return (() => {
|
|
174
|
+
var _el$ = _$createElement("box"),
|
|
175
|
+
_el$2 = _$createElement("text"),
|
|
176
|
+
_el$3 = _$createElement("text"),
|
|
177
|
+
_el$4 = _$createElement("b");
|
|
178
|
+
_$insertNode(_el$, _el$2);
|
|
179
|
+
_$insertNode(_el$, _el$3);
|
|
180
|
+
_$setProp(_el$, "width", '100%');
|
|
181
|
+
_$setProp(_el$, "flexDirection", 'row');
|
|
182
|
+
_$setProp(_el$, "justifyContent", 'space-between');
|
|
183
|
+
_$insert(_el$2, () => props.label);
|
|
184
|
+
_$insertNode(_el$3, _el$4);
|
|
185
|
+
_$insert(_el$4, () => props.value);
|
|
186
|
+
_$effect(_p$ => {
|
|
187
|
+
var _v$ = props.theme().textMuted,
|
|
188
|
+
_v$2 = props.theme()[props.tone ?? 'text'];
|
|
189
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$2, "fg", _v$, _p$.e));
|
|
190
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$3, "fg", _v$2, _p$.t));
|
|
191
|
+
return _p$;
|
|
192
|
+
}, {
|
|
193
|
+
e: undefined,
|
|
194
|
+
t: undefined
|
|
195
|
+
});
|
|
196
|
+
return _el$;
|
|
197
|
+
})();
|
|
198
|
+
}
|
|
199
|
+
export function AntigravitySidebar(props) {
|
|
362
200
|
const prefs = props.settings;
|
|
363
|
-
const collapsed = props.collapsed;
|
|
364
201
|
const now = props.now;
|
|
365
202
|
const hasData = () => props.accounts().length > 0;
|
|
366
203
|
const backoffActive = () => {
|
|
367
204
|
const until = props.quotaBackoffUntil();
|
|
368
205
|
return typeof until === 'number' && until > now();
|
|
369
206
|
};
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
207
|
+
const visibleAccounts = createMemo(() => props.accounts().filter(account => prefs().sections.fallbackAccounts || account.current).map(account => accountView(account, now(), prefs().appearance)));
|
|
208
|
+
const theme = () => {
|
|
209
|
+
const source = props.theme();
|
|
210
|
+
return {
|
|
211
|
+
...source,
|
|
212
|
+
textMuted: source.textMuted ?? source.text,
|
|
213
|
+
accent: source.accent ?? source.text,
|
|
214
|
+
success: source.success ?? source.accent ?? source.text,
|
|
215
|
+
warning: source.warning ?? source.accent ?? source.text,
|
|
216
|
+
error: source.error ?? source.accent ?? source.text
|
|
217
|
+
};
|
|
379
218
|
};
|
|
380
219
|
|
|
381
|
-
//
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const routeLines = route => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter(line => line !== '');
|
|
385
|
-
|
|
386
|
-
// The width available to content: the header row spans the panel inside
|
|
387
|
-
// its border and padding. Layout reports it during a render pass, so the
|
|
388
|
-
// signal is updated afterwards rather than rebuilding rows mid-pass.
|
|
389
|
-
const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH);
|
|
390
|
-
let headerRow;
|
|
220
|
+
// Routing keeps whole parts on separate lines when the single stat row is too wide.
|
|
221
|
+
const [contentWidth, setContentWidth] = createSignal(28);
|
|
222
|
+
let sections;
|
|
391
223
|
const measureContentWidth = () => {
|
|
392
|
-
const width =
|
|
393
|
-
if (
|
|
394
|
-
queueMicrotask(() => {
|
|
395
|
-
if (width !== contentWidth()) setContentWidth(width);
|
|
396
|
-
});
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
// Header badge: ▼/▶ {label}, with the version at the right when nothing is
|
|
400
|
-
// degraded and a `LIMITED` badge in its place when something is.
|
|
401
|
-
const headerLabel = () => {
|
|
402
|
-
const name = prefs().header.label;
|
|
403
|
-
return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
|
|
224
|
+
const width = sections?.width;
|
|
225
|
+
if (width && width !== contentWidth()) queueMicrotask(() => setContentWidth(width));
|
|
404
226
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
},
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
_$
|
|
436
|
-
_$setProp(_el$14, "paddingRight", 1);
|
|
437
|
-
_$insertNode(_el$15, _el$16);
|
|
438
|
-
_$insert(_el$16, headerLabel);
|
|
439
|
-
_$insert(_el$13, _$createComponent(Show, {
|
|
440
|
-
get when() {
|
|
441
|
-
return degraded();
|
|
442
|
-
},
|
|
443
|
-
get fallback() {
|
|
444
|
-
return _$createComponent(Show, {
|
|
445
|
-
get when() {
|
|
446
|
-
return _$memo(() => !!prefs().header.showVersion)() && props.version !== '';
|
|
447
|
-
},
|
|
448
|
-
get children() {
|
|
449
|
-
var _el$21 = _$createElement("text");
|
|
450
|
-
_$insert(_el$21, () => `v${props.version}`);
|
|
451
|
-
_$effect(_$p => _$setProp(_el$21, "fg", theme().textMuted, _$p));
|
|
452
|
-
return _el$21;
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
},
|
|
456
|
-
get children() {
|
|
457
|
-
var _el$17 = _$createElement("box"),
|
|
458
|
-
_el$18 = _$createElement("text"),
|
|
459
|
-
_el$19 = _$createElement("b");
|
|
460
|
-
_$insertNode(_el$17, _el$18);
|
|
461
|
-
_$setProp(_el$17, "paddingLeft", 1);
|
|
462
|
-
_$setProp(_el$17, "paddingRight", 1);
|
|
463
|
-
_$insertNode(_el$18, _el$19);
|
|
464
|
-
_$insertNode(_el$19, _$createTextNode(`LIMITED`));
|
|
465
|
-
_$effect(_p$ => {
|
|
466
|
-
var _v$3 = theme().warning,
|
|
467
|
-
_v$4 = theme().background;
|
|
468
|
-
_v$3 !== _p$.e && (_p$.e = _$setProp(_el$17, "backgroundColor", _v$3, _p$.e));
|
|
469
|
-
_v$4 !== _p$.t && (_p$.t = _$setProp(_el$18, "fg", _v$4, _p$.t));
|
|
470
|
-
return _p$;
|
|
471
|
-
}, {
|
|
472
|
-
e: undefined,
|
|
473
|
-
t: undefined
|
|
474
|
-
});
|
|
475
|
-
return _el$17;
|
|
476
|
-
}
|
|
477
|
-
}), null);
|
|
478
|
-
_$insert(_el$12, _$createComponent(Show, {
|
|
479
|
-
get when() {
|
|
480
|
-
return _$memo(() => !!collapsed())() && hasData();
|
|
481
|
-
},
|
|
482
|
-
get children() {
|
|
483
|
-
return _$createComponent(For, {
|
|
484
|
-
get each() {
|
|
485
|
-
return visibleAccounts();
|
|
486
|
-
},
|
|
487
|
-
children: account => _$createComponent(CollapsedAccount, {
|
|
488
|
-
theme: theme,
|
|
489
|
-
appearance: () => prefs().appearance,
|
|
490
|
-
account: account,
|
|
491
|
-
now: now,
|
|
492
|
-
width: contentWidth
|
|
493
|
-
})
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
}), null);
|
|
497
|
-
_$insert(_el$12, _$createComponent(Show, {
|
|
227
|
+
const routeValue = route => `${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`;
|
|
228
|
+
const routeLines = route => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter(Boolean);
|
|
229
|
+
return _$createComponent(SidebarFrame, {
|
|
230
|
+
get header() {
|
|
231
|
+
return {
|
|
232
|
+
badge: prefs().header.label,
|
|
233
|
+
version: prefs().header.showVersion && props.version ? `v${props.version}` : undefined
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
get theme() {
|
|
237
|
+
return theme();
|
|
238
|
+
},
|
|
239
|
+
get appearance() {
|
|
240
|
+
return prefs().appearance;
|
|
241
|
+
},
|
|
242
|
+
get accounts() {
|
|
243
|
+
return visibleAccounts();
|
|
244
|
+
},
|
|
245
|
+
get showQuota() {
|
|
246
|
+
return prefs().sections.quota;
|
|
247
|
+
},
|
|
248
|
+
get now() {
|
|
249
|
+
return now();
|
|
250
|
+
},
|
|
251
|
+
get collapsed() {
|
|
252
|
+
return props.collapsed();
|
|
253
|
+
},
|
|
254
|
+
get onToggle() {
|
|
255
|
+
return props.onToggleCollapsed;
|
|
256
|
+
},
|
|
257
|
+
sections: () => _$createComponent(Show, {
|
|
498
258
|
get when() {
|
|
499
|
-
return !collapsed() || !hasData();
|
|
259
|
+
return !props.collapsed() || !hasData();
|
|
500
260
|
},
|
|
501
261
|
get children() {
|
|
502
|
-
|
|
262
|
+
var _el$5 = _$createElement("box");
|
|
263
|
+
_$use(element => {
|
|
264
|
+
sections = element;
|
|
265
|
+
}, _el$5);
|
|
266
|
+
_$setProp(_el$5, "width", '100%');
|
|
267
|
+
_$setProp(_el$5, "flexDirection", 'column');
|
|
268
|
+
_$setProp(_el$5, "onSizeChange", measureContentWidth);
|
|
269
|
+
_$insert(_el$5, _$createComponent(Show, {
|
|
503
270
|
get when() {
|
|
504
271
|
return hasData();
|
|
505
272
|
},
|
|
506
273
|
get fallback() {
|
|
507
274
|
return (() => {
|
|
508
|
-
var _el$
|
|
509
|
-
|
|
510
|
-
_$
|
|
511
|
-
_$
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return _el$
|
|
275
|
+
var _el$6 = _$createElement("box");
|
|
276
|
+
_$setProp(_el$6, "marginTop", 1);
|
|
277
|
+
_$setProp(_el$6, "width", '100%');
|
|
278
|
+
_$insert(_el$6, _$createComponent(SidebarTextRow, {
|
|
279
|
+
text: "Waiting for quota\u2026",
|
|
280
|
+
wrapMode: "none"
|
|
281
|
+
}));
|
|
282
|
+
return _el$6;
|
|
516
283
|
})();
|
|
517
284
|
},
|
|
518
285
|
get children() {
|
|
519
286
|
return [_$createComponent(Show, {
|
|
520
287
|
get when() {
|
|
521
|
-
return prefs().sections.quota;
|
|
288
|
+
return _$memo(() => !!prefs().sections.quota)() && visibleAccounts().length === 0;
|
|
522
289
|
},
|
|
523
290
|
get children() {
|
|
524
|
-
return
|
|
525
|
-
theme: theme,
|
|
291
|
+
return _$createComponent(SidebarSection, {
|
|
526
292
|
title: "Quota"
|
|
527
|
-
})
|
|
528
|
-
get each() {
|
|
529
|
-
return visibleAccounts();
|
|
530
|
-
},
|
|
531
|
-
children: (account, index) => _$createComponent(AccountBlock, {
|
|
532
|
-
theme: theme,
|
|
533
|
-
get appearance() {
|
|
534
|
-
return prefs().appearance;
|
|
535
|
-
},
|
|
536
|
-
account: account,
|
|
537
|
-
now: now,
|
|
538
|
-
width: contentWidth,
|
|
539
|
-
get marginTop() {
|
|
540
|
-
return index() === 0 ? 0 : 1;
|
|
541
|
-
}
|
|
542
|
-
})
|
|
543
|
-
})];
|
|
293
|
+
});
|
|
544
294
|
}
|
|
545
295
|
}), _$createComponent(Show, {
|
|
546
296
|
get when() {
|
|
547
297
|
return prefs().sections.routing;
|
|
548
298
|
},
|
|
549
299
|
get children() {
|
|
550
|
-
return
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
children: route => _$createComponent(Show, {
|
|
567
|
-
get when() {
|
|
568
|
-
return routeLineFits('Route', routeValue(route()), contentWidth());
|
|
569
|
-
},
|
|
570
|
-
get fallback() {
|
|
571
|
-
return _$createComponent(For, {
|
|
572
|
-
get each() {
|
|
573
|
-
return routeLines(route());
|
|
300
|
+
return _$createComponent(SidebarSection, {
|
|
301
|
+
title: "Routing",
|
|
302
|
+
get children() {
|
|
303
|
+
return _$createComponent(Show, {
|
|
304
|
+
get when() {
|
|
305
|
+
return props.route();
|
|
306
|
+
},
|
|
307
|
+
get fallback() {
|
|
308
|
+
return _$createComponent(SidebarTextRow, {
|
|
309
|
+
text: "No request yet",
|
|
310
|
+
wrapMode: "none"
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
children: route => _$createComponent(Show, {
|
|
314
|
+
get when() {
|
|
315
|
+
return routeLineFits('Route', routeValue(route()), contentWidth());
|
|
574
316
|
},
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
get value() {
|
|
591
|
-
return routeValue(route());
|
|
317
|
+
get fallback() {
|
|
318
|
+
return _$createComponent(For, {
|
|
319
|
+
get each() {
|
|
320
|
+
return routeLines(route());
|
|
321
|
+
},
|
|
322
|
+
children: line => (() => {
|
|
323
|
+
var _el$7 = _$createElement("text"),
|
|
324
|
+
_el$8 = _$createElement("b");
|
|
325
|
+
_$insertNode(_el$7, _el$8);
|
|
326
|
+
_$setProp(_el$7, "wrapMode", 'none');
|
|
327
|
+
_$insert(_el$8, line);
|
|
328
|
+
_$effect(_$p => _$setProp(_el$7, "fg", theme().accent, _$p));
|
|
329
|
+
return _el$7;
|
|
330
|
+
})()
|
|
331
|
+
});
|
|
592
332
|
},
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
333
|
+
get children() {
|
|
334
|
+
return _$createComponent(StatRow, {
|
|
335
|
+
theme: theme,
|
|
336
|
+
label: "Route",
|
|
337
|
+
get value() {
|
|
338
|
+
return routeValue(route());
|
|
339
|
+
},
|
|
340
|
+
tone: "accent"
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
});
|
|
598
347
|
}
|
|
599
348
|
}), _$createComponent(Show, {
|
|
600
349
|
get when() {
|
|
601
|
-
return _$memo(() => !!
|
|
350
|
+
return _$memo(() => !!(backoffActive() || !!props.lastError()))() && prefs().sections.health;
|
|
602
351
|
},
|
|
603
352
|
get children() {
|
|
604
|
-
return
|
|
605
|
-
|
|
606
|
-
title: "Health"
|
|
607
|
-
}), _$createComponent(Show, {
|
|
608
|
-
get when() {
|
|
609
|
-
return backoffActive();
|
|
610
|
-
},
|
|
353
|
+
return _$createComponent(SidebarSection, {
|
|
354
|
+
title: "Health",
|
|
611
355
|
get children() {
|
|
612
|
-
return _$createComponent(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
get value() {
|
|
616
|
-
return `backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`;
|
|
356
|
+
return [_$createComponent(Show, {
|
|
357
|
+
get when() {
|
|
358
|
+
return backoffActive();
|
|
617
359
|
},
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
get
|
|
630
|
-
return lastError()
|
|
360
|
+
get children() {
|
|
361
|
+
return _$createComponent(StatRow, {
|
|
362
|
+
theme: theme,
|
|
363
|
+
label: "Quota API",
|
|
364
|
+
get value() {
|
|
365
|
+
return `backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`;
|
|
366
|
+
},
|
|
367
|
+
tone: "warning"
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}), _$createComponent(Show, {
|
|
371
|
+
get when() {
|
|
372
|
+
return props.lastError();
|
|
631
373
|
},
|
|
632
|
-
|
|
633
|
-
|
|
374
|
+
get children() {
|
|
375
|
+
return _$createComponent(StatRow, {
|
|
376
|
+
theme: theme,
|
|
377
|
+
label: "Last error",
|
|
378
|
+
get value() {
|
|
379
|
+
return props.lastError() ?? '';
|
|
380
|
+
},
|
|
381
|
+
tone: "error"
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
})];
|
|
634
385
|
}
|
|
635
|
-
})
|
|
386
|
+
});
|
|
636
387
|
}
|
|
637
388
|
})];
|
|
638
389
|
}
|
|
639
|
-
});
|
|
390
|
+
}));
|
|
391
|
+
return _el$5;
|
|
640
392
|
}
|
|
641
|
-
})
|
|
642
|
-
|
|
643
|
-
var _v$5 = theme().borderActive,
|
|
644
|
-
_v$6 = theme().accent,
|
|
645
|
-
_v$7 = theme().background;
|
|
646
|
-
_v$5 !== _p$.e && (_p$.e = _$setProp(_el$12, "borderColor", _v$5, _p$.e));
|
|
647
|
-
_v$6 !== _p$.t && (_p$.t = _$setProp(_el$14, "backgroundColor", _v$6, _p$.t));
|
|
648
|
-
_v$7 !== _p$.a && (_p$.a = _$setProp(_el$15, "fg", _v$7, _p$.a));
|
|
649
|
-
return _p$;
|
|
650
|
-
}, {
|
|
651
|
-
e: undefined,
|
|
652
|
-
t: undefined,
|
|
653
|
-
a: undefined
|
|
654
|
-
});
|
|
655
|
-
return _el$12;
|
|
656
|
-
})();
|
|
393
|
+
})
|
|
394
|
+
});
|
|
657
395
|
}
|