@cortexkit/opencode-antigravity-auth 3.0.6 → 3.0.8
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/cli.js +1621 -183
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +228 -62
- package/dist/index.js +2728 -883
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +291 -104
- package/dist/server.js +2255 -390
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/src/common-auth-embedded/claustrum/index.js +4 -1
- package/dist/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/dist/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +10 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/dist/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/dist/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/src/common-auth-embedded/quota/format.js +203 -18
- package/dist/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/src/common-auth-embedded/quota/index.js +1 -1
- package/dist/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/src/common-auth-embedded/setup/command-error.js +79 -0
- package/dist/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/dist/src/common-auth-embedded/setup/command.js +75 -19
- package/dist/src/common-auth-embedded/setup/enroll.js +17 -5
- package/dist/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/register.js +8 -2
- package/dist/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/src/common-auth-embedded/source-output.json +142 -94
- package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/pool.js +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/dist/src/ga/server/index.d.ts +2 -0
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +18 -3
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +37 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +2 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +5 -4
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +2 -1
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +8 -6
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +7 -3
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +2 -5
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +3 -3
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +2 -5
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/request.d.ts +1 -2
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +8 -12
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/src/plugin/shared/after-handoff.js +89 -0
- package/dist/src/plugin/shared/after-handoff.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +193 -90
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +17 -1
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +16 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +60 -10
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/sidebar-projection.d.ts +4 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -1
- package/dist/src/sidebar-projection.js +6 -2
- package/dist/src/sidebar-projection.js.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +94 -0
- package/dist/src/tui/quota-layout.d.ts.map +1 -0
- package/dist/src/tui/quota-layout.js +139 -0
- package/dist/src/tui/quota-layout.js.map +1 -0
- package/dist/src/tui/route-layout.d.ts +8 -0
- package/dist/src/tui/route-layout.d.ts.map +1 -0
- package/dist/src/tui/route-layout.js +36 -0
- package/dist/src/tui/route-layout.js.map +1 -0
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +105 -191
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +60 -31
- package/dist/tui-ga-build-map.json +46 -17
- package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/types/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/types/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/types/src/ga/server/index.d.ts +2 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts +2 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +1 -2
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/types/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +16 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/src/common-auth-embedded/claustrum/index.js +4 -1
- package/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/src/common-auth-embedded/fs/private-files.js +10 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/src/common-auth-embedded/quota/format.js +203 -18
- package/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/src/common-auth-embedded/quota/index.js +1 -1
- package/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/src/common-auth-embedded/setup/command-error.js +79 -0
- package/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/src/common-auth-embedded/setup/command.js +75 -19
- package/src/common-auth-embedded/setup/enroll.js +17 -5
- package/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/register.js +8 -2
- package/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/src/common-auth-embedded/source-output.json +142 -94
- package/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/src/common-auth-embedded/store/pool.js +0 -1
- package/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-compiled/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-compiled/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-compiled/tui/quota-layout.js +378 -0
- package/src/tui-compiled/tui/route-layout.js +30 -0
- package/src/tui-compiled/tui.js +245 -501
- package/src/tui-ga-compiled/host-ga.js +82 -52
- package/src/tui-ga-compiled/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +378 -0
- package/src/tui-ga-raw/host-ga.tsx +71 -30
- package/src/tui-ga-raw/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +391 -0
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-raw/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-raw/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-raw/tui/quota-layout.tsx +391 -0
- package/src/tui-raw/tui/route-layout.js +30 -0
- package/src/tui-raw/tui.tsx +171 -411
- package/src/tui.tsx +171 -411
|
@@ -63,8 +63,12 @@ export function quotaWindowName(limit) {
|
|
|
63
63
|
function clampPercent(remaining) {
|
|
64
64
|
return Math.min(100, Math.max(0, remaining));
|
|
65
65
|
}
|
|
66
|
+
/** A remaining percentage as the whole number every form shows. */
|
|
67
|
+
function wholePercent(remaining) {
|
|
68
|
+
return Math.round(clampPercent(remaining));
|
|
69
|
+
}
|
|
66
70
|
function percentLeft(remaining) {
|
|
67
|
-
return `${
|
|
71
|
+
return `${wholePercent(remaining)}% left`;
|
|
68
72
|
}
|
|
69
73
|
function resetDetails(resetsAt, checkedAt, now) {
|
|
70
74
|
const at = resetsAt === undefined ? Number.NaN : Date.parse(resetsAt);
|
|
@@ -98,6 +102,16 @@ function displayOrder(left, right) {
|
|
|
98
102
|
* and the optional age keep the shared formatter's wording.
|
|
99
103
|
*/
|
|
100
104
|
export function quotaWindowParts(quota, options) {
|
|
105
|
+
const { windows, age } = scopedWindowParts(quota, options);
|
|
106
|
+
const parts = windows.map(({ part }) => part);
|
|
107
|
+
return age === undefined ? { windows: parts } : { windows: parts, age };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `quotaWindowParts` with each window's scope kept beside it. The narrow form
|
|
111
|
+
* needs the scope to name and pick model-scoped windows; the public parts do
|
|
112
|
+
* not carry it, so their shape stays as it was.
|
|
113
|
+
*/
|
|
114
|
+
function scopedWindowParts(quota, options) {
|
|
101
115
|
if (!quota)
|
|
102
116
|
return { windows: [] };
|
|
103
117
|
const { now } = options;
|
|
@@ -107,12 +121,18 @@ export function quotaWindowParts(quota, options) {
|
|
|
107
121
|
const windows = readings.map((limit) => {
|
|
108
122
|
const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
|
|
109
123
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
scope: limit.scope,
|
|
125
|
+
...(limit.windowMinutes === undefined
|
|
126
|
+
? {}
|
|
127
|
+
: { windowMinutes: limit.windowMinutes }),
|
|
128
|
+
part: {
|
|
129
|
+
kind: 'window',
|
|
130
|
+
name: quotaWindowName(limit),
|
|
131
|
+
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
132
|
+
remainingPercent,
|
|
133
|
+
checkedAt: limit.checkedAt,
|
|
134
|
+
...resetDetails(limit.resetsAt, limit.checkedAt, now),
|
|
135
|
+
},
|
|
116
136
|
};
|
|
117
137
|
});
|
|
118
138
|
const budget = quota.budget;
|
|
@@ -124,32 +144,196 @@ export function quotaWindowParts(quota, options) {
|
|
|
124
144
|
? `credits ${percentLeft(remainingPercent)}`
|
|
125
145
|
: 'credits available';
|
|
126
146
|
windows.push({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
scope: ALL_SCOPE,
|
|
148
|
+
spent: budget.reached,
|
|
149
|
+
part: {
|
|
150
|
+
kind: 'budget',
|
|
151
|
+
name: 'credits',
|
|
152
|
+
figure,
|
|
153
|
+
...(remainingPercent === undefined
|
|
154
|
+
? {}
|
|
155
|
+
: { remainingPercent: clampPercent(remainingPercent) }),
|
|
156
|
+
checkedAt: budget.checkedAt,
|
|
157
|
+
...resetDetails(budget.resetsAt, budget.checkedAt, now),
|
|
158
|
+
},
|
|
135
159
|
});
|
|
136
160
|
}
|
|
137
161
|
if (windows.length > 0) {
|
|
138
|
-
const age = now - Math.min(...windows.map((part) => part.checkedAt));
|
|
162
|
+
const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
|
|
139
163
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
140
164
|
return { windows, age: `checked ${shortSpan(age)} ago` };
|
|
141
165
|
}
|
|
142
166
|
}
|
|
143
167
|
return { windows };
|
|
144
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Whether the reading is stale: true exactly when the compact and full forms
|
|
171
|
+
* would end with `checked … ago`. The narrow form leaves that age out to stay
|
|
172
|
+
* short, so a caller drawing a narrow line uses this to dim it instead.
|
|
173
|
+
*/
|
|
174
|
+
export function isQuotaStale(quota, options) {
|
|
175
|
+
return scopedWindowParts(quota, options).age !== undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The model a scope names, as a display name: any namespace before a colon
|
|
179
|
+
* is dropped (`model:claude-opus-4` → `claude-opus-4`) and the first letter is
|
|
180
|
+
* capitalized (`fable` → `Fable`); the rest stays as written.
|
|
181
|
+
*/
|
|
182
|
+
function scopeDisplayName(scope) {
|
|
183
|
+
const model = scope.slice(scope.indexOf(':') + 1);
|
|
184
|
+
return model.charAt(0).toUpperCase() + model.slice(1);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Short names for the model scopes in one row: the first two letters of each
|
|
188
|
+
* display name. Names that would read the same for different models are each
|
|
189
|
+
* extended one letter at a time until they differ (`Fable` and `Fabric` read
|
|
190
|
+
* `Fabl` and `Fabr`); a name that runs out of letters stays whole.
|
|
191
|
+
*/
|
|
192
|
+
function scopeAbbreviations(scopes) {
|
|
193
|
+
const names = [...new Set(scopes.map(scopeDisplayName))];
|
|
194
|
+
const lengths = new Map(names.map((name) => [name, 2]));
|
|
195
|
+
const short = (name) => name.slice(0, lengths.get(name));
|
|
196
|
+
for (;;) {
|
|
197
|
+
const byShort = new Map();
|
|
198
|
+
for (const name of names) {
|
|
199
|
+
byShort.set(short(name), [...(byShort.get(short(name)) ?? []), name]);
|
|
200
|
+
}
|
|
201
|
+
let extended = false;
|
|
202
|
+
for (const group of byShort.values()) {
|
|
203
|
+
if (group.length < 2)
|
|
204
|
+
continue;
|
|
205
|
+
for (const name of group) {
|
|
206
|
+
const length = lengths.get(name) ?? 2;
|
|
207
|
+
if (length < name.length) {
|
|
208
|
+
lengths.set(name, length + 1);
|
|
209
|
+
extended = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!extended)
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
return new Map(scopes.map((scope) => [scope, short(scopeDisplayName(scope))]));
|
|
217
|
+
}
|
|
218
|
+
/** The most groups a grouped narrow line shows. */
|
|
219
|
+
const NARROW_GROUP_LIMIT = 2;
|
|
220
|
+
/**
|
|
221
|
+
* The names the groups read under in the narrow line, one per listed group:
|
|
222
|
+
* each label's short name, derived exactly as a model window's is (`Gemini`
|
|
223
|
+
* → `Ge`, `Other models` → `Ot`, colliding names extended until they
|
|
224
|
+
* differ), computed over every listed group so a group keeps its name
|
|
225
|
+
* whichever groups show. A blank label falls back to the group's scope.
|
|
226
|
+
*/
|
|
227
|
+
function groupShortNames(groups) {
|
|
228
|
+
const labels = groups.map((group) => group.label.trim() || group.scope);
|
|
229
|
+
const short = scopeAbbreviations(labels);
|
|
230
|
+
return labels.map((label) => short.get(label) ?? label);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The narrow line of a reading whose windows belong to named groups and that
|
|
234
|
+
* has no account-wide window: for each group, its tightest window as
|
|
235
|
+
* `Ge 7d 62%`, with ` left` once at the end. The tightest window is the
|
|
236
|
+
* one with least left, compared before rounding; on a tie the first in
|
|
237
|
+
* display order (the shorter window) wins. At most two groups show: the two
|
|
238
|
+
* with least left, earlier-listed first on a tie, and always in the order
|
|
239
|
+
* the reading lists them, so the line does not reorder as the figures move.
|
|
240
|
+
* A group with no reported window is skipped. Windows outside the listed
|
|
241
|
+
* groups and the credit budget are left out. Undefined when the rule does
|
|
242
|
+
* not apply, so the caller uses the ordinary narrow rule.
|
|
243
|
+
*/
|
|
244
|
+
function groupedNarrowPieces(groups, windows) {
|
|
245
|
+
if (!groups || groups.length === 0)
|
|
246
|
+
return undefined;
|
|
247
|
+
const reported = windows.filter(({ part }) => part.kind === 'window');
|
|
248
|
+
if (reported.some(({ scope }) => scope === ALL_SCOPE))
|
|
249
|
+
return undefined;
|
|
250
|
+
const candidates = groups.flatMap((group, listed) => {
|
|
251
|
+
const inGroup = reported.filter(({ scope }) => scope === group.scope);
|
|
252
|
+
// `windows` is already in display order, and strictly lower wins, so on
|
|
253
|
+
// a tie the shorter window keeps the place.
|
|
254
|
+
const groupTightest = inGroup.reduce((least, window) => least === undefined ||
|
|
255
|
+
(window.part.remainingPercent ?? 0) < (least.part.remainingPercent ?? 0)
|
|
256
|
+
? window
|
|
257
|
+
: least, undefined);
|
|
258
|
+
return groupTightest ? [{ group, listed, window: groupTightest }] : [];
|
|
259
|
+
});
|
|
260
|
+
if (candidates.length === 0)
|
|
261
|
+
return undefined;
|
|
262
|
+
const names = groupShortNames(groups);
|
|
263
|
+
const left = (candidate) => candidate.window.part.remainingPercent ?? 0;
|
|
264
|
+
const shown = [...candidates]
|
|
265
|
+
.sort((a, b) => left(a) - left(b) || a.listed - b.listed)
|
|
266
|
+
.slice(0, NARROW_GROUP_LIMIT)
|
|
267
|
+
.sort((a, b) => a.listed - b.listed);
|
|
268
|
+
return shown.map((candidate, index) => {
|
|
269
|
+
const { windowMinutes } = candidate.window;
|
|
270
|
+
const piece = [
|
|
271
|
+
names[candidate.listed] ?? candidate.group.scope,
|
|
272
|
+
...(windowMinutes === undefined ? [] : [lengthName(windowMinutes)]),
|
|
273
|
+
`${wholePercent(left(candidate))}%`,
|
|
274
|
+
].join(' ');
|
|
275
|
+
return index === shown.length - 1 ? `${piece} left` : piece;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The narrow form's pieces: every account-wide window as `5h 92%`, then at
|
|
280
|
+
* most one more item, with ` left` added once to the last piece. That item is
|
|
281
|
+
* the tightest (least remaining) of the model-scoped windows and the credit
|
|
282
|
+
* budget, so the line stays bounded whatever the account carries: a scoped
|
|
283
|
+
* window reads under its short model name (`Fa 98%`), the budget as `cr 75%`
|
|
284
|
+
* (`cr 0%` when spent). On a tie a scoped window wins over the budget, and
|
|
285
|
+
* among scoped windows the first in display order wins. The choice depends
|
|
286
|
+
* only on the reading, never on a width. A budget without a percentage cannot
|
|
287
|
+
* be chosen; when nothing at all is shown it keeps its compact wording
|
|
288
|
+
* (`credits available`). No age is added; `isQuotaStale` says whether the
|
|
289
|
+
* reading is stale. A window whose reset arrived after the reading keeps its
|
|
290
|
+
* figure, as in the other forms. A reading that lists named groups and has no
|
|
291
|
+
* account-wide window reads one item per group instead (see
|
|
292
|
+
* `groupedNarrowPieces`).
|
|
293
|
+
*/
|
|
294
|
+
function narrowTextParts(quota, options) {
|
|
295
|
+
const { windows } = scopedWindowParts(quota, options);
|
|
296
|
+
const grouped = groupedNarrowPieces(quota?.groups, windows);
|
|
297
|
+
if (grouped)
|
|
298
|
+
return grouped;
|
|
299
|
+
const general = windows.filter(({ part, scope }) => part.kind === 'window' && scope === ALL_SCOPE);
|
|
300
|
+
const scoped = windows.filter(({ part, scope }) => part.kind === 'window' && scope !== ALL_SCOPE);
|
|
301
|
+
const abbreviations = scopeAbbreviations(scoped.map(({ scope }) => scope));
|
|
302
|
+
// The items competing for the one slot after the account-wide windows, in
|
|
303
|
+
// tie-break order: scoped windows in display order, then the budget. A
|
|
304
|
+
// spent budget counts as 0% left; one without a percentage cannot compete.
|
|
305
|
+
const budget = windows.find(({ part }) => part.kind === 'budget');
|
|
306
|
+
const budgetLeft = budget?.spent ? 0 : budget?.part.remainingPercent;
|
|
307
|
+
const extras = [
|
|
308
|
+
...scoped.map(({ scope, part }) => ({
|
|
309
|
+
label: abbreviations.get(scope) ?? scope,
|
|
310
|
+
remaining: part.remainingPercent ?? 0,
|
|
311
|
+
})),
|
|
312
|
+
...(budgetLeft === undefined
|
|
313
|
+
? []
|
|
314
|
+
: [{ label: 'cr', remaining: budgetLeft }]),
|
|
315
|
+
];
|
|
316
|
+
// Strictly lower wins, so on a tie the earlier item keeps the slot.
|
|
317
|
+
const tightest = extras.reduce((best, item) => best === undefined || item.remaining < best.remaining ? item : best, undefined);
|
|
318
|
+
const pieces = general.map(({ part }) => `${part.name} ${wholePercent(part.remainingPercent ?? 0)}%`);
|
|
319
|
+
if (tightest) {
|
|
320
|
+
pieces.push(`${tightest.label} ${wholePercent(tightest.remaining)}%`);
|
|
321
|
+
}
|
|
322
|
+
if (pieces.length === 0)
|
|
323
|
+
return windows.map(({ part }) => part.figure);
|
|
324
|
+
return pieces.map((piece, index) => index === pieces.length - 1 ? `${piece} left` : piece);
|
|
325
|
+
}
|
|
145
326
|
/**
|
|
146
327
|
* The pieces of a quota text, in order: one per reported window
|
|
147
328
|
* (`5h 58% left, resets 2h`), then the credit budget when there is one, then
|
|
148
329
|
* `checked 3h ago` when the oldest piece shown is stale. Empty when nothing
|
|
149
330
|
* was reported; `formatQuota` turns that into a sentence. A caller printing
|
|
150
|
-
* one line per window (the terminal auth menu) uses these directly.
|
|
331
|
+
* one line per window (the terminal auth menu) uses these directly. In the
|
|
332
|
+
* narrow form the pieces are the narrow line's (`5h 92%`, `7d 66% left`).
|
|
151
333
|
*/
|
|
152
334
|
export function quotaTextParts(quota, options) {
|
|
335
|
+
if (options.form === 'narrow')
|
|
336
|
+
return narrowTextParts(quota, options);
|
|
153
337
|
const parts = quotaWindowParts(quota, options);
|
|
154
338
|
const full = (options.form ?? 'full') === 'full';
|
|
155
339
|
const text = parts.windows.map((part) => {
|
|
@@ -160,7 +344,8 @@ export function quotaTextParts(quota, options) {
|
|
|
160
344
|
}
|
|
161
345
|
/**
|
|
162
346
|
* A row's quota as one line: `5h 58% left · 7d 90% left` in the compact
|
|
163
|
-
* form, with `, resets 2h` after each window in the full form
|
|
347
|
+
* form, with `, resets 2h` after each window in the full form, and
|
|
348
|
+
* `5h 58% · 7d 90% left` in the narrow form. With nothing
|
|
164
349
|
* reported it is `NO_QUOTA_READING`, or `NO_LIMITS_REPORTED` when the
|
|
165
350
|
* provider answered without a limit for any window.
|
|
166
351
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { quotaCodec } from "./codec.js";
|
|
2
|
-
export { formatQuota, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./format.js";
|
|
2
|
+
export { formatQuota, isQuotaStale, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./format.js";
|
|
3
3
|
export { ALL_SCOPE, DEFAULT_REQUIRED_LABELS, decodeQuotaMap, emptyQuotaMap, isQuotaMap, } from "./map.js";
|
|
4
4
|
export { isQuotaObservation, mergeQuotaObservation, QuotaCodecError, } from "./merge.js";
|
|
5
5
|
export { budgetExhaustedResetAt, futureResetAt, projectQuota, readsExhausted, } from "./projection.js";
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
|
+
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
|
+
import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
|
+
import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
|
+
import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
7
|
+
import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
8
|
+
/** @jsxImportSource @opentui/solid */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
|
|
12
|
+
* sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
|
|
13
|
+
* reading age once per account, plain-word group headers and one width-fitted
|
|
14
|
+
* row per quota window.
|
|
15
|
+
*
|
|
16
|
+
* Each renderer supplies its own data source and colors. This module imports
|
|
17
|
+
* only the pure quota presentation helpers, so it stays inside both TUI
|
|
18
|
+
* import graphs: no sidebar file, preferences file, RPC, account store,
|
|
19
|
+
* OAuth, token or host SDK module, and nothing that writes to the terminal.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { For, Show } from "opentui:runtime-module:solid-js";
|
|
23
|
+
import { NO_QUOTA_READING, quotaReadingAge, quotaWindowText } from "../quota-presentation.js";
|
|
24
|
+
|
|
25
|
+
/** A text color; `undefined` leaves the host's default color in place. */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* How a renderer colors the quota layout. OpenCode 1 maps these onto its live
|
|
29
|
+
* host theme; a renderer without a theme returns `undefined` everywhere.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** The bar and threshold settings the layout reads. */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
36
|
+
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
37
|
+
*/
|
|
38
|
+
export const DEFAULT_QUOTA_APPEARANCE = {
|
|
39
|
+
barWidth: 10,
|
|
40
|
+
barFilledChar: '█',
|
|
41
|
+
barEmptyChar: '░',
|
|
42
|
+
warnThreshold: 50,
|
|
43
|
+
errorThreshold: 80
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** The account fields the quota layout reads, and nothing else. */
|
|
47
|
+
|
|
48
|
+
// Group headers name each quota pool in plain words.
|
|
49
|
+
export const GROUP_NAMES = {
|
|
50
|
+
gemini: 'Gemini',
|
|
51
|
+
'non-gemini': 'Other models'
|
|
52
|
+
};
|
|
53
|
+
export const QUOTA_ORDER = ['gemini', 'non-gemini'];
|
|
54
|
+
|
|
55
|
+
// Shown instead of a stored figure once the window has reset since it was
|
|
56
|
+
// read: the stored figure describes the window before the reset.
|
|
57
|
+
export const RESET_SINCE_READING = 'reset since last check';
|
|
58
|
+
|
|
59
|
+
// Content width used until the first layout pass reports the real one. It
|
|
60
|
+
// fits the narrowest OpenCode sidebar.
|
|
61
|
+
export const ASSUMED_CONTENT_WIDTH = 28;
|
|
62
|
+
|
|
63
|
+
// A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
|
|
64
|
+
// before the reset column is dropped; below it the bar is dropped too.
|
|
65
|
+
const MIN_BAR_WIDTH = 4;
|
|
66
|
+
// The widest figure the formatter writes: `100% left`.
|
|
67
|
+
const FIGURE_WIDTH = 9;
|
|
68
|
+
// A window name (`5h`, `7d`) and the space after it.
|
|
69
|
+
const NAME_WIDTH = 3;
|
|
70
|
+
export function quotaTone(usedPct, appearance) {
|
|
71
|
+
if (usedPct < appearance.warnThreshold) return 'ok';
|
|
72
|
+
if (usedPct < appearance.errorThreshold) return 'warn';
|
|
73
|
+
return 'err';
|
|
74
|
+
}
|
|
75
|
+
function quotaBarSegments(remainingPct, width, appearance) {
|
|
76
|
+
const usedCells = Math.max(0, Math.min(Math.round(remainingPct / 100 * width), width));
|
|
77
|
+
const tone = quotaTone(100 - remainingPct, appearance);
|
|
78
|
+
return [{
|
|
79
|
+
text: appearance.barFilledChar.repeat(usedCells),
|
|
80
|
+
tone
|
|
81
|
+
}, {
|
|
82
|
+
text: appearance.barEmptyChar.repeat(width - usedCells),
|
|
83
|
+
tone
|
|
84
|
+
}].filter(segment => segment.text.length > 0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// --- Width-fitted quota rows ------------------------------------------------
|
|
88
|
+
//
|
|
89
|
+
// The host sidebars are about 20 to 48 columns wide. Every quota line is
|
|
90
|
+
// sized from the measured content width so that it fits on one line: text is
|
|
91
|
+
// never left to the renderer's wrapping, which breaks a row mid-word or down
|
|
92
|
+
// to one character per line once the right-hand column runs out of room.
|
|
93
|
+
|
|
94
|
+
// One entry per stored window, in group order. A pool stored before
|
|
95
|
+
// per-window readings existed contributes one window without a name.
|
|
96
|
+
export function accountWindows(account, now) {
|
|
97
|
+
const result = [];
|
|
98
|
+
for (const key of QUOTA_ORDER) {
|
|
99
|
+
const entry = account.quota[key];
|
|
100
|
+
if (!entry) continue;
|
|
101
|
+
const readings = entry.windows && entry.windows.length > 0 ? entry.windows.map(window => ({
|
|
102
|
+
window: window.window,
|
|
103
|
+
remainingPercent: window.remainingPercent,
|
|
104
|
+
resetAt: window.resetAt,
|
|
105
|
+
checkedAt: window.checkedAt
|
|
106
|
+
})) : [{
|
|
107
|
+
remainingPercent: entry.remainingPercent,
|
|
108
|
+
resetAt: entry.resetAt,
|
|
109
|
+
checkedAt: entry.checkedAt
|
|
110
|
+
}];
|
|
111
|
+
for (const reading of readings) result.push({
|
|
112
|
+
key,
|
|
113
|
+
reading,
|
|
114
|
+
text: quotaWindowText(reading, now)
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// A window shows its figure only while no reset has happened since it was
|
|
121
|
+
// read and it has a read time at all.
|
|
122
|
+
export function showsFigure(window) {
|
|
123
|
+
return window.text.remaining != null && !window.text.resetSinceReading;
|
|
124
|
+
}
|
|
125
|
+
// Column widths for one `<name> <bar> <figure> <reset>` row within `width`
|
|
126
|
+
// cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
|
|
127
|
+
// is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
|
|
128
|
+
// bar, the bar is left out and the row is just the name and figure.
|
|
129
|
+
function windowRowLayout(width, named, resetWidth, maxBar) {
|
|
130
|
+
const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH;
|
|
131
|
+
if (resetWidth > 0) {
|
|
132
|
+
const bar = Math.min(maxBar, room - resetWidth - 2);
|
|
133
|
+
if (bar >= MIN_BAR_WIDTH) return {
|
|
134
|
+
bar,
|
|
135
|
+
reset: true
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const bar = Math.min(maxBar, room - 1);
|
|
139
|
+
return {
|
|
140
|
+
bar: bar >= MIN_BAR_WIDTH ? bar : 0,
|
|
141
|
+
reset: false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Shorten a label to `max` cells, marking the cut with an ellipsis.
|
|
146
|
+
export function fitLabel(label, max) {
|
|
147
|
+
if (label.length <= max) return label;
|
|
148
|
+
if (max <= 0) return '';
|
|
149
|
+
if (max === 1) return '…';
|
|
150
|
+
return `${label.slice(0, max - 1)}…`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// One quota window on one line. The bar fills with remaining quota; the
|
|
154
|
+
// figure and reset come from the shared formatter. A window that reset since
|
|
155
|
+
// its reading shows that fact, dim, in place of the stale figure.
|
|
156
|
+
function WindowRow(props) {
|
|
157
|
+
const text = () => props.window.text;
|
|
158
|
+
const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance);
|
|
159
|
+
return (() => {
|
|
160
|
+
var _el$ = _$createElement("box");
|
|
161
|
+
_$setProp(_el$, "width", '100%');
|
|
162
|
+
_$setProp(_el$, "flexDirection", 'row');
|
|
163
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
164
|
+
get when() {
|
|
165
|
+
return text().name !== '';
|
|
166
|
+
},
|
|
167
|
+
get children() {
|
|
168
|
+
var _el$2 = _$createElement("text");
|
|
169
|
+
_$setProp(_el$2, "width", 3);
|
|
170
|
+
_$setProp(_el$2, "flexShrink", 0);
|
|
171
|
+
_$setProp(_el$2, "wrapMode", 'none');
|
|
172
|
+
_$insert(_el$2, () => text().name);
|
|
173
|
+
_$effect(_$p => _$setProp(_el$2, "fg", props.palette.muted(), _$p));
|
|
174
|
+
return _el$2;
|
|
175
|
+
}
|
|
176
|
+
}), null);
|
|
177
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
178
|
+
get when() {
|
|
179
|
+
return showsFigure(props.window);
|
|
180
|
+
},
|
|
181
|
+
get fallback() {
|
|
182
|
+
return (() => {
|
|
183
|
+
var _el$7 = _$createElement("text");
|
|
184
|
+
_$setProp(_el$7, "flexShrink", 1);
|
|
185
|
+
_$setProp(_el$7, "wrapMode", 'none');
|
|
186
|
+
_$insert(_el$7, (() => {
|
|
187
|
+
var _c$ = _$memo(() => !!text().resetSinceReading);
|
|
188
|
+
return () => _c$() ? RESET_SINCE_READING : text().figure;
|
|
189
|
+
})());
|
|
190
|
+
_$effect(_$p => _$setProp(_el$7, "fg", props.palette.muted(), _$p));
|
|
191
|
+
return _el$7;
|
|
192
|
+
})();
|
|
193
|
+
},
|
|
194
|
+
get children() {
|
|
195
|
+
return [_$createComponent(Show, {
|
|
196
|
+
get when() {
|
|
197
|
+
return props.layout.bar > 0;
|
|
198
|
+
},
|
|
199
|
+
get children() {
|
|
200
|
+
var _el$3 = _$createElement("box");
|
|
201
|
+
_$setProp(_el$3, "flexShrink", 0);
|
|
202
|
+
_$setProp(_el$3, "flexDirection", 'row');
|
|
203
|
+
_$insert(_el$3, _$createComponent(For, {
|
|
204
|
+
get each() {
|
|
205
|
+
return quotaBarSegments(text().remaining ?? 0, props.layout.bar, props.appearance);
|
|
206
|
+
},
|
|
207
|
+
children: segment => (() => {
|
|
208
|
+
var _el$8 = _$createElement("text");
|
|
209
|
+
_$setProp(_el$8, "wrapMode", 'none');
|
|
210
|
+
_$insert(_el$8, () => segment.text);
|
|
211
|
+
_$effect(_$p => _$setProp(_el$8, "fg", props.palette.tone(segment.tone), _$p));
|
|
212
|
+
return _el$8;
|
|
213
|
+
})()
|
|
214
|
+
}));
|
|
215
|
+
_$effect(_$p => _$setProp(_el$3, "width", props.layout.bar + 1, _$p));
|
|
216
|
+
return _el$3;
|
|
217
|
+
}
|
|
218
|
+
}), (() => {
|
|
219
|
+
var _el$4 = _$createElement("text");
|
|
220
|
+
_$setProp(_el$4, "flexShrink", 0);
|
|
221
|
+
_$setProp(_el$4, "wrapMode", 'none');
|
|
222
|
+
_$insert(_el$4, () => text().figure);
|
|
223
|
+
_$effect(_$p => _$setProp(_el$4, "fg", props.palette.tone(tone()), _$p));
|
|
224
|
+
return _el$4;
|
|
225
|
+
})(), (() => {
|
|
226
|
+
var _el$5 = _$createElement("box");
|
|
227
|
+
_$setProp(_el$5, "flexGrow", 1);
|
|
228
|
+
return _el$5;
|
|
229
|
+
})(), _$createComponent(Show, {
|
|
230
|
+
get when() {
|
|
231
|
+
return _$memo(() => !!props.layout.reset)() && text().reset !== '';
|
|
232
|
+
},
|
|
233
|
+
get children() {
|
|
234
|
+
var _el$6 = _$createElement("text");
|
|
235
|
+
_$setProp(_el$6, "flexShrink", 0);
|
|
236
|
+
_$setProp(_el$6, "wrapMode", 'none');
|
|
237
|
+
_$insert(_el$6, () => text().reset);
|
|
238
|
+
_$effect(_$p => _$setProp(_el$6, "fg", props.palette.muted(), _$p));
|
|
239
|
+
return _el$6;
|
|
240
|
+
}
|
|
241
|
+
})];
|
|
242
|
+
}
|
|
243
|
+
}), null);
|
|
244
|
+
return _el$;
|
|
245
|
+
})();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* One account's quota block. The header line is the account label, the
|
|
250
|
+
* reading age when the oldest reading is stale, and the caller's status word
|
|
251
|
+
* right-aligned; the age moves to its own dim line when the three do not
|
|
252
|
+
* fit. Below it each quota group present gets a plain-word header and one
|
|
253
|
+
* row per window, or a single dim line when there is no reading at all.
|
|
254
|
+
* `children` render after the quota rows (the OpenCode 2 health line).
|
|
255
|
+
*/
|
|
256
|
+
export function QuotaAccountBlock(props) {
|
|
257
|
+
const windows = () => accountWindows(props.account, props.now());
|
|
258
|
+
const age = () => quotaReadingAge(windows().map(window => window.reading), props.now());
|
|
259
|
+
const ageInline = () => age() !== '' && props.account.label.length + 3 + age().length + 1 + props.status.length <= props.width();
|
|
260
|
+
const label = () => fitLabel(props.account.label, props.width() - 1 - props.status.length);
|
|
261
|
+
// One reset column width per account, so bars line up across its rows.
|
|
262
|
+
const resetWidth = () => Math.max(0, ...windows().filter(showsFigure).map(window => window.text.reset.length));
|
|
263
|
+
const layoutFor = window => windowRowLayout(props.width(), window.text.name !== '', resetWidth(), props.appearance.barWidth);
|
|
264
|
+
const groups = () => QUOTA_ORDER.map(key => ({
|
|
265
|
+
key,
|
|
266
|
+
windows: windows().filter(window => window.key === key)
|
|
267
|
+
})).filter(group => group.windows.length > 0);
|
|
268
|
+
return (() => {
|
|
269
|
+
var _el$9 = _$createElement("box"),
|
|
270
|
+
_el$0 = _$createElement("box"),
|
|
271
|
+
_el$1 = _$createElement("text"),
|
|
272
|
+
_el$10 = _$createElement("b"),
|
|
273
|
+
_el$12 = _$createElement("box"),
|
|
274
|
+
_el$13 = _$createElement("text"),
|
|
275
|
+
_el$14 = _$createElement("b");
|
|
276
|
+
_$insertNode(_el$9, _el$0);
|
|
277
|
+
_$setProp(_el$9, "width", '100%');
|
|
278
|
+
_$setProp(_el$9, "flexDirection", 'column');
|
|
279
|
+
_$insertNode(_el$0, _el$1);
|
|
280
|
+
_$insertNode(_el$0, _el$12);
|
|
281
|
+
_$insertNode(_el$0, _el$13);
|
|
282
|
+
_$setProp(_el$0, "width", '100%');
|
|
283
|
+
_$setProp(_el$0, "flexDirection", 'row');
|
|
284
|
+
_$insertNode(_el$1, _el$10);
|
|
285
|
+
_$setProp(_el$1, "flexShrink", 0);
|
|
286
|
+
_$setProp(_el$1, "wrapMode", 'none');
|
|
287
|
+
_$insert(_el$10, label);
|
|
288
|
+
_$insert(_el$0, _$createComponent(Show, {
|
|
289
|
+
get when() {
|
|
290
|
+
return ageInline();
|
|
291
|
+
},
|
|
292
|
+
get children() {
|
|
293
|
+
var _el$11 = _$createElement("text");
|
|
294
|
+
_$setProp(_el$11, "flexShrink", 0);
|
|
295
|
+
_$setProp(_el$11, "wrapMode", 'none');
|
|
296
|
+
_$insert(_el$11, () => ` · ${age()}`);
|
|
297
|
+
_$effect(_$p => _$setProp(_el$11, "fg", props.palette.muted(), _$p));
|
|
298
|
+
return _el$11;
|
|
299
|
+
}
|
|
300
|
+
}), _el$12);
|
|
301
|
+
_$setProp(_el$12, "flexGrow", 1);
|
|
302
|
+
_$insertNode(_el$13, _el$14);
|
|
303
|
+
_$setProp(_el$13, "flexShrink", 0);
|
|
304
|
+
_$setProp(_el$13, "wrapMode", 'none');
|
|
305
|
+
_$insert(_el$14, () => props.status);
|
|
306
|
+
_$insert(_el$9, _$createComponent(Show, {
|
|
307
|
+
get when() {
|
|
308
|
+
return _$memo(() => age() !== '')() && !ageInline();
|
|
309
|
+
},
|
|
310
|
+
get children() {
|
|
311
|
+
var _el$15 = _$createElement("text");
|
|
312
|
+
_$setProp(_el$15, "wrapMode", 'none');
|
|
313
|
+
_$insert(_el$15, age);
|
|
314
|
+
_$effect(_$p => _$setProp(_el$15, "fg", props.palette.muted(), _$p));
|
|
315
|
+
return _el$15;
|
|
316
|
+
}
|
|
317
|
+
}), null);
|
|
318
|
+
_$insert(_el$9, _$createComponent(Show, {
|
|
319
|
+
get when() {
|
|
320
|
+
return groups().length > 0;
|
|
321
|
+
},
|
|
322
|
+
get fallback() {
|
|
323
|
+
return (() => {
|
|
324
|
+
var _el$16 = _$createElement("text");
|
|
325
|
+
_$setProp(_el$16, "wrapMode", 'none');
|
|
326
|
+
_$insert(_el$16, NO_QUOTA_READING);
|
|
327
|
+
_$effect(_$p => _$setProp(_el$16, "fg", props.palette.muted(), _$p));
|
|
328
|
+
return _el$16;
|
|
329
|
+
})();
|
|
330
|
+
},
|
|
331
|
+
get children() {
|
|
332
|
+
return _$createComponent(For, {
|
|
333
|
+
get each() {
|
|
334
|
+
return groups();
|
|
335
|
+
},
|
|
336
|
+
children: group => [(() => {
|
|
337
|
+
var _el$17 = _$createElement("text");
|
|
338
|
+
_$setProp(_el$17, "wrapMode", 'none');
|
|
339
|
+
_$insert(_el$17, () => GROUP_NAMES[group.key]);
|
|
340
|
+
_$effect(_$p => _$setProp(_el$17, "fg", props.palette.muted(), _$p));
|
|
341
|
+
return _el$17;
|
|
342
|
+
})(), _$createComponent(For, {
|
|
343
|
+
get each() {
|
|
344
|
+
return group.windows;
|
|
345
|
+
},
|
|
346
|
+
children: window => _$createComponent(WindowRow, {
|
|
347
|
+
get palette() {
|
|
348
|
+
return props.palette;
|
|
349
|
+
},
|
|
350
|
+
get appearance() {
|
|
351
|
+
return props.appearance;
|
|
352
|
+
},
|
|
353
|
+
window: window,
|
|
354
|
+
get layout() {
|
|
355
|
+
return layoutFor(window);
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
})]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}), null);
|
|
362
|
+
_$insert(_el$9, () => props.children, null);
|
|
363
|
+
_$effect(_p$ => {
|
|
364
|
+
var _v$ = props.marginTop ?? 0,
|
|
365
|
+
_v$2 = props.palette.text(),
|
|
366
|
+
_v$3 = props.palette.tone(props.statusTone);
|
|
367
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$9, "marginTop", _v$, _p$.e));
|
|
368
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$1, "fg", _v$2, _p$.t));
|
|
369
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp(_el$13, "fg", _v$3, _p$.a));
|
|
370
|
+
return _p$;
|
|
371
|
+
}, {
|
|
372
|
+
e: undefined,
|
|
373
|
+
t: undefined,
|
|
374
|
+
a: undefined
|
|
375
|
+
});
|
|
376
|
+
return _el$9;
|
|
377
|
+
})();
|
|
378
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function routeLineFits(label, value, width) {
|
|
2
|
+
return label.length + 1 + value.length <= width;
|
|
3
|
+
}
|
|
4
|
+
function fitPrimaryPart(value, maxWidth) {
|
|
5
|
+
if (value.length <= maxWidth)
|
|
6
|
+
return value;
|
|
7
|
+
if (maxWidth <= 0)
|
|
8
|
+
return "";
|
|
9
|
+
let fitted = "";
|
|
10
|
+
for (const word of value.trim().split(/\s+/)) {
|
|
11
|
+
const candidate = fitted ? `${fitted} ${word}` : word;
|
|
12
|
+
if (candidate.length > maxWidth) {
|
|
13
|
+
const marked = fitted ? `${fitted}\u2026` : "\u2026";
|
|
14
|
+
return marked.length <= maxWidth ? marked : fitted;
|
|
15
|
+
}
|
|
16
|
+
fitted = candidate;
|
|
17
|
+
}
|
|
18
|
+
return fitted;
|
|
19
|
+
}
|
|
20
|
+
export function fitRouteParts(label, parts, width) {
|
|
21
|
+
const [primary = "", ...optional] = parts;
|
|
22
|
+
let value = fitPrimaryPart(primary, width - label.length - 1);
|
|
23
|
+
for (const part of optional) {
|
|
24
|
+
const candidate = `${value} \xB7 ${part}`;
|
|
25
|
+
if (!routeLineFits(label, candidate, width))
|
|
26
|
+
break;
|
|
27
|
+
value = candidate;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|