opencode-quota-gui 1.3.1 → 1.3.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 +16 -12
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-order.d.ts +2 -0
- package/dist/contracts/card-order.js +2 -2
- package/dist/contracts/card-visibility.d.ts +2 -1
- package/dist/contracts/card-visibility.js +2 -1
- package/dist/contracts/dashboard.d.ts +87 -5
- package/dist/contracts/dashboard.js +10 -0
- package/dist/contracts/dto-guards.d.ts +4 -0
- package/dist/contracts/dto-guards.js +29 -7
- package/dist/contracts/guards.js +3 -1
- package/dist/contracts/identity.d.ts +37 -5
- package/dist/contracts/identity.js +43 -0
- package/dist/contracts/provider-auto-resume.d.ts +9 -0
- package/dist/contracts/provider-auto-resume.js +24 -0
- package/dist/contracts/provider-failure.d.ts +22 -0
- package/dist/contracts/provider-failure.js +25 -1
- package/dist/contracts/row-order.d.ts +13 -0
- package/dist/contracts/row-order.js +34 -0
- package/dist/contracts/row-visibility.d.ts +53 -0
- package/dist/contracts/row-visibility.js +130 -0
- package/dist/data/modelsdev-pricing.min.json +1 -1
- package/dist/data/modelsdev-temporal.min.json +3 -634
- package/dist/gui/aggregation.d.ts +29 -1
- package/dist/gui/aggregation.js +157 -4
- package/dist/gui/analytics-bridge.d.ts +8 -9
- package/dist/gui/analytics-bridge.js +197 -54
- package/dist/gui/analytics-engine.d.ts +7 -15
- package/dist/gui/analytics-engine.js +246 -106
- package/dist/gui/analytics-model.d.ts +7 -0
- package/dist/gui/analytics-model.js +75 -9
- package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
- package/dist/gui/analytics-pricing-upkeep.js +23 -0
- package/dist/gui/analytics-protocol.d.ts +17 -7
- package/dist/gui/analytics-protocol.js +1 -0
- package/dist/gui/analytics-service.d.ts +10 -0
- package/dist/gui/analytics-service.js +30 -9
- package/dist/gui/analytics-state.d.ts +30 -5
- package/dist/gui/analytics-state.js +46 -7
- package/dist/gui/analytics-worker-runtime.d.ts +5 -0
- package/dist/gui/analytics-worker-runtime.js +9 -1
- package/dist/gui/analytics-worker.js +11 -0
- package/dist/gui/config.d.ts +2 -2
- package/dist/gui/config.js +46 -5
- package/dist/gui/identity.d.ts +6 -20
- package/dist/gui/identity.js +6 -54
- package/dist/gui/primary-quota-windows.js +55 -34
- package/dist/gui/provider-cards.d.ts +12 -8
- package/dist/gui/provider-cards.js +12 -53
- package/dist/gui/quota-notification-detector.d.ts +25 -2
- package/dist/gui/quota-notification-detector.js +60 -5
- package/dist/gui/quota-notification-observer.d.ts +1 -1
- package/dist/gui/quota-notification-observer.js +5 -1
- package/dist/gui/quota-observation.d.ts +4 -0
- package/dist/gui/quota-observation.js +18 -0
- package/dist/gui/rpc.js +3 -0
- package/dist/gui/server.js +6 -1
- package/dist/gui/snapshot-service.d.ts +3 -17
- package/dist/gui/snapshot-service.js +159 -9
- package/dist/gui/sources.js +84 -11
- package/dist/gui/temporal-status.d.ts +3 -2
- package/dist/gui/temporal-status.js +10 -6
- package/dist/gui-experimental.cjs +228 -228
- package/dist/lib/accounting-format.d.ts +8 -0
- package/dist/lib/accounting-format.js +12 -2
- package/dist/lib/anthropic-api-auth.d.ts +7 -0
- package/dist/lib/anthropic-api-auth.js +27 -0
- package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
- package/dist/lib/anthropic-api-rate-limits.js +92 -0
- package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
- package/dist/lib/anthropic-oauth-throttle.js +379 -0
- package/dist/lib/anthropic.d.ts +22 -4
- package/dist/lib/anthropic.js +498 -180
- package/dist/lib/cache-observer-ingestion.js +27 -0
- package/dist/lib/cache-observer.d.ts +3 -0
- package/dist/lib/cache-observer.js +9 -3
- package/dist/lib/cli-show.d.ts +5 -0
- package/dist/lib/cli-show.js +16 -5
- package/dist/lib/cli-status.js +3 -6
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +64 -2
- package/dist/lib/dashboard-visibility.d.ts +5 -0
- package/dist/lib/dashboard-visibility.js +11 -10
- package/dist/lib/display-sanitize.js +1 -0
- package/dist/lib/entries.d.ts +10 -1
- package/dist/lib/entries.js +4 -0
- package/dist/lib/grouped-entry-normalization.js +1 -1
- package/dist/lib/maintainer-announcements.js +2 -2
- package/dist/lib/modelsdev-pricing.d.ts +74 -2
- package/dist/lib/modelsdev-pricing.js +457 -63
- package/dist/lib/modelsdev-temporal.d.ts +6 -0
- package/dist/lib/modelsdev-temporal.js +16 -2
- package/dist/lib/opencode-config-providers.js +2 -2
- package/dist/lib/opencode-storage.d.ts +20 -0
- package/dist/lib/opencode-storage.js +89 -2
- package/dist/lib/opencode-version-core.d.ts +7 -0
- package/dist/lib/opencode-version-core.js +10 -0
- package/dist/lib/opencode-warming-refresh.d.ts +19 -0
- package/dist/lib/opencode-warming-refresh.js +95 -0
- package/dist/lib/provider-metadata.d.ts +11 -3
- package/dist/lib/provider-metadata.js +20 -2
- package/dist/lib/provider-registration.d.ts +342 -3
- package/dist/lib/provider-registration.js +409 -27
- package/dist/lib/quota-auto-resume.d.ts +74 -0
- package/dist/lib/quota-auto-resume.js +539 -0
- package/dist/lib/quota-command-format.js +22 -9
- package/dist/lib/quota-identity.d.ts +64 -0
- package/dist/lib/quota-identity.js +111 -0
- package/dist/lib/quota-providers.js +2 -2
- package/dist/lib/quota-render-data.js +2 -2
- package/dist/lib/quota-reset-notifications.js +11 -155
- package/dist/lib/quota-retry-wait.d.ts +106 -5
- package/dist/lib/quota-retry-wait.js +301 -34
- package/dist/lib/quota-runtime-context.js +1 -0
- package/dist/lib/quota-state-codec.d.ts +2 -0
- package/dist/lib/quota-state-codec.js +14 -1
- package/dist/lib/quota-state.d.ts +1 -1
- package/dist/lib/quota-state.js +60 -28
- package/dist/lib/quota-stats.d.ts +26 -0
- package/dist/lib/quota-stats.js +19 -1
- package/dist/lib/quota-surface-data.js +18 -3
- package/dist/lib/quota-telemetry.js +2 -2
- package/dist/lib/resolved-auth-identity.d.ts +19 -0
- package/dist/lib/resolved-auth-identity.js +44 -0
- package/dist/lib/state-file-lock.d.ts +26 -0
- package/dist/lib/state-file-lock.js +205 -0
- package/dist/lib/toast-format-grouped.js +7 -4
- package/dist/lib/tui-compact-format.js +29 -16
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/types.js +4 -1
- package/dist/plugin.js +67 -1
- package/dist/providers/alibaba-coding-plan.js +21 -3
- package/dist/providers/alibaba-token-plan.js +9 -5
- package/dist/providers/anthropic.d.ts +6 -2
- package/dist/providers/anthropic.js +123 -14
- package/dist/providers/chutes.js +2 -0
- package/dist/providers/claude-agent.js +24 -5
- package/dist/providers/copilot.js +5 -4
- package/dist/providers/glm-coding-plan-provider.js +30 -23
- package/dist/providers/ollama-cloud.js +10 -0
- package/dist/providers/openai.js +24 -23
- package/dist/providers/opencode-go.js +7 -6
- package/dist/providers/opencode-zen.js +1 -1
- package/dist/providers/result-helpers.d.ts +4 -2
- package/dist/providers/result-helpers.js +5 -1
- package/dist/providers/synthetic.js +4 -0
- package/dist/providers/xai.js +9 -8
- package/dist/rpc.d.ts +8 -0
- package/dist/rpc.js +15 -2
- package/dist/ui/assets/{index-BcueIm3Z.css → index-6_g1FHs-.css} +1 -1
- package/dist/ui/assets/index-sZnGUuML.js +10 -0
- package/dist/ui/assets/{popover-4bFSvRZ7.js → popover-C4ZLYe9E.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +3 -3
- package/dist/ui/assets/index-C6qRSoh8.js +0 -10
|
@@ -8,11 +8,33 @@
|
|
|
8
8
|
export declare const PROVIDER_FAILURE_CATEGORIES: readonly ["provider_api", "credentials", "discovery", "local"];
|
|
9
9
|
export type ProviderFailureCategory = (typeof PROVIDER_FAILURE_CATEGORIES)[number];
|
|
10
10
|
export declare function isProviderFailureCategory(value: unknown): value is ProviderFailureCategory;
|
|
11
|
+
/**
|
|
12
|
+
* Failures a later poll can recover from without re-authenticating. The account is unchanged, so
|
|
13
|
+
* the last measured quota stays valid (marked stale) instead of being discarded.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTransientProviderFailureCategory(value: ProviderFailureCategory | undefined): boolean;
|
|
11
16
|
export type ProviderHttpFailureCategory = Extract<ProviderFailureCategory, "credentials" | "provider_api">;
|
|
17
|
+
/**
|
|
18
|
+
* The outcome of one provider attempt, separate from whether an older
|
|
19
|
+
* measurement is still displayable:
|
|
20
|
+
*
|
|
21
|
+
* - `fresh` the attempt completed and produced a new measurement;
|
|
22
|
+
* - `reuse` no request was made because a recent measurement is still
|
|
23
|
+
* within its reuse window; the measurement keeps its own time;
|
|
24
|
+
* - `cooldown` no request was made because this process is honoring an
|
|
25
|
+
* already-known rate-limit deadline; this is not a new failure;
|
|
26
|
+
* - `transient` the request was made and failed in a way a later poll may
|
|
27
|
+
* recover from;
|
|
28
|
+
* - `credentials` the request was rejected as unauthenticated/unauthorized.
|
|
29
|
+
*/
|
|
30
|
+
declare const QUOTA_ATTEMPT_OUTCOMES: readonly ["fresh", "reuse", "cooldown", "transient", "credentials"];
|
|
31
|
+
export type QuotaAttemptOutcome = (typeof QUOTA_ATTEMPT_OUTCOMES)[number];
|
|
32
|
+
export declare function isQuotaAttemptOutcome(value: unknown): value is QuotaAttemptOutcome;
|
|
12
33
|
/**
|
|
13
34
|
* HTTP 401/403 is an authentication/authorization outcome; every other failed
|
|
14
35
|
* response is a provider API failure. Callers must only use this at an actual
|
|
15
36
|
* request/response boundary.
|
|
16
37
|
*/
|
|
17
38
|
export declare function providerFailureCategoryForHttpStatus(status: number): ProviderHttpFailureCategory;
|
|
39
|
+
export {};
|
|
18
40
|
//# sourceMappingURL=provider-failure.d.ts.map
|
|
@@ -12,7 +12,31 @@ export const PROVIDER_FAILURE_CATEGORIES = [
|
|
|
12
12
|
"local",
|
|
13
13
|
];
|
|
14
14
|
export function isProviderFailureCategory(value) {
|
|
15
|
-
return (
|
|
15
|
+
return PROVIDER_FAILURE_CATEGORIES.some((category) => category === value);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Failures a later poll can recover from without re-authenticating. The account is unchanged, so
|
|
19
|
+
* the last measured quota stays valid (marked stale) instead of being discarded.
|
|
20
|
+
*/
|
|
21
|
+
export function isTransientProviderFailureCategory(value) {
|
|
22
|
+
return value === "provider_api" || value === "discovery" || value === "local";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The outcome of one provider attempt, separate from whether an older
|
|
26
|
+
* measurement is still displayable:
|
|
27
|
+
*
|
|
28
|
+
* - `fresh` the attempt completed and produced a new measurement;
|
|
29
|
+
* - `reuse` no request was made because a recent measurement is still
|
|
30
|
+
* within its reuse window; the measurement keeps its own time;
|
|
31
|
+
* - `cooldown` no request was made because this process is honoring an
|
|
32
|
+
* already-known rate-limit deadline; this is not a new failure;
|
|
33
|
+
* - `transient` the request was made and failed in a way a later poll may
|
|
34
|
+
* recover from;
|
|
35
|
+
* - `credentials` the request was rejected as unauthenticated/unauthorized.
|
|
36
|
+
*/
|
|
37
|
+
const QUOTA_ATTEMPT_OUTCOMES = ["fresh", "reuse", "cooldown", "transient", "credentials"];
|
|
38
|
+
export function isQuotaAttemptOutcome(value) {
|
|
39
|
+
return QUOTA_ATTEMPT_OUTCOMES.some((outcome) => outcome === value);
|
|
16
40
|
}
|
|
17
41
|
/**
|
|
18
42
|
* HTTP 401/403 is an authentication/authorization outcome; every other failed
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RowVisibilityControl } from "./row-visibility.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a fresh row array ordered for presentation.
|
|
4
|
+
*
|
|
5
|
+
* - A non-empty saved order lists preferred rows first, in saved order; every
|
|
6
|
+
* other row (new, or never reordered) follows in stable input (emission)
|
|
7
|
+
* order. Unknown and duplicate preference ids are ignored.
|
|
8
|
+
* - An absent or empty saved order keeps stable input order.
|
|
9
|
+
* - With `controls`, a saved order saved under an alternate emitted shape and a
|
|
10
|
+
* row rendered in another shape resolve to the same stable control id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function orderRowsByPreference<T>(rows: readonly T[], rowOrder?: readonly string[], idOf?: (row: T) => string, controls?: readonly RowVisibilityControl[]): T[];
|
|
13
|
+
//# sourceMappingURL=row-order.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { rankByIds, stableSortByRank } from "./card-order.js";
|
|
2
|
+
import { rowControlId, rowOrderForControls } from "./row-visibility.js";
|
|
3
|
+
/**
|
|
4
|
+
* Presentation-only row ordering shared by the backend card projection and the
|
|
5
|
+
* Settings visibility list.
|
|
6
|
+
*
|
|
7
|
+
* Like `card-order`, this module is dependency-free and opaque-id-only: it never
|
|
8
|
+
* interprets an id, never adds or removes a row, and never mutates its input.
|
|
9
|
+
* The caller assembles the real rows first, then asks for a display order, so a
|
|
10
|
+
* newly emitted row keeps its provider position after every listed row.
|
|
11
|
+
*/
|
|
12
|
+
const UNKNOWN_RANK = Number.POSITIVE_INFINITY;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a fresh row array ordered for presentation.
|
|
15
|
+
*
|
|
16
|
+
* - A non-empty saved order lists preferred rows first, in saved order; every
|
|
17
|
+
* other row (new, or never reordered) follows in stable input (emission)
|
|
18
|
+
* order. Unknown and duplicate preference ids are ignored.
|
|
19
|
+
* - An absent or empty saved order keeps stable input order.
|
|
20
|
+
* - With `controls`, a saved order saved under an alternate emitted shape and a
|
|
21
|
+
* row rendered in another shape resolve to the same stable control id.
|
|
22
|
+
*/
|
|
23
|
+
export function orderRowsByPreference(rows, rowOrder,
|
|
24
|
+
// SAFETY: callers that omit idOf pass rows carrying a rowId field.
|
|
25
|
+
idOf = (row) => row.rowId, controls = []) {
|
|
26
|
+
if (rowOrder === undefined || rowOrder.length === 0)
|
|
27
|
+
return [...rows];
|
|
28
|
+
const order = rowOrderForControls(rowOrder, controls);
|
|
29
|
+
const ranks = rankByIds(order, new Set(rows.map((row) => rowControlId(idOf(row), controls))));
|
|
30
|
+
if (ranks.size === 0)
|
|
31
|
+
return [...rows];
|
|
32
|
+
return stableSortByRank(rows, (row) => ranks.get(rowControlId(idOf(row), controls)) ?? UNKNOWN_RANK);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=row-order.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative normalized row-visibility semantics.
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe and shared by the UI, Settings, the native session header and
|
|
5
|
+
* the server-side quota notification detector.
|
|
6
|
+
*
|
|
7
|
+
* Before per-window semantics, providers without a stable semantic metric
|
|
8
|
+
* emitted every row under `aggregate|<resultType>:<kind>`. A saved hide for
|
|
9
|
+
* that provider therefore matched whichever such row was emitted first. Those
|
|
10
|
+
* providers now emit typed `window:*` / `component:*` / `named:*` row keys.
|
|
11
|
+
*
|
|
12
|
+
* A saved legacy aggregate id keeps its original meaning until the user makes
|
|
13
|
+
* a new explicit choice: it resolves to the first current row on the same card
|
|
14
|
+
* with the same `|<resultType>:<kind>` discriminator. `materialize...` rewrites
|
|
15
|
+
* it to that row's typed id when Settings toggles a row of that card.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* One persistent row control: the stable declared id plus every emitted row id
|
|
19
|
+
* that renders the same field in another shape. Emitted ids never change; the
|
|
20
|
+
* alias set is how a hide or saved order follows the field across shapes.
|
|
21
|
+
*/
|
|
22
|
+
export interface RowVisibilityControl {
|
|
23
|
+
rowId: string;
|
|
24
|
+
aliases?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/** The stable control id that owns a row id (itself or one of its aliases). */
|
|
27
|
+
export declare function rowControlId(rowId: string, controls: readonly RowVisibilityControl[]): string;
|
|
28
|
+
/**
|
|
29
|
+
* Rewrites a saved row order to stable control ids, first occurrence wins.
|
|
30
|
+
* Unknown ids stay untouched so a later emission can still use them.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rowOrderForControls(rowOrder: readonly string[], controls: readonly RowVisibilityControl[]): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Resolves configured row ids against the rows a card currently emits. Exact
|
|
35
|
+
* typed ids pass through untouched. A legacy aggregate id resolves to the
|
|
36
|
+
* first emitted row of that card with the same discriminator; when no such row
|
|
37
|
+
* exists yet it stays inert so it can match a later emission.
|
|
38
|
+
*
|
|
39
|
+
* A configured id that belongs to a control (its stable declared id or any
|
|
40
|
+
* alias) hides every id the control owns. That keeps one eye effective when the
|
|
41
|
+
* provider renders the same field in another shape, and keeps a hide saved
|
|
42
|
+
* under the previous shape working after the control gains a stable id.
|
|
43
|
+
*/
|
|
44
|
+
export declare function effectiveHiddenRowIds(rowIds: readonly string[], hiddenRows: readonly string[], controls?: readonly RowVisibilityControl[]): Set<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Rewrites every legacy aggregate id for `cardId` to the current row it
|
|
47
|
+
* resolves to, and drops ones that no longer resolve. Called only after an
|
|
48
|
+
* explicit Settings row toggle, so an untouched legacy choice keeps following
|
|
49
|
+
* whichever row is emitted first. Other cards and exact ids are preserved in
|
|
50
|
+
* order.
|
|
51
|
+
*/
|
|
52
|
+
export declare function materializeLegacyHiddenRowsForCard(cardId: string, hiddenRows: readonly string[], rowIds: readonly string[]): string[];
|
|
53
|
+
//# sourceMappingURL=row-visibility.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative normalized row-visibility semantics.
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe and shared by the UI, Settings, the native session header and
|
|
5
|
+
* the server-side quota notification detector.
|
|
6
|
+
*
|
|
7
|
+
* Before per-window semantics, providers without a stable semantic metric
|
|
8
|
+
* emitted every row under `aggregate|<resultType>:<kind>`. A saved hide for
|
|
9
|
+
* that provider therefore matched whichever such row was emitted first. Those
|
|
10
|
+
* providers now emit typed `window:*` / `component:*` / `named:*` row keys.
|
|
11
|
+
*
|
|
12
|
+
* A saved legacy aggregate id keeps its original meaning until the user makes
|
|
13
|
+
* a new explicit choice: it resolves to the first current row on the same card
|
|
14
|
+
* with the same `|<resultType>:<kind>` discriminator. `materialize...` rewrites
|
|
15
|
+
* it to that row's typed id when Settings toggles a row of that card.
|
|
16
|
+
*/
|
|
17
|
+
/** The stable control id that owns a row id (itself or one of its aliases). */
|
|
18
|
+
export function rowControlId(rowId, controls) {
|
|
19
|
+
for (const control of controls) {
|
|
20
|
+
if (control.rowId === rowId || control.aliases?.includes(rowId))
|
|
21
|
+
return control.rowId;
|
|
22
|
+
}
|
|
23
|
+
return rowId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Rewrites a saved row order to stable control ids, first occurrence wins.
|
|
27
|
+
* Unknown ids stay untouched so a later emission can still use them.
|
|
28
|
+
*/
|
|
29
|
+
export function rowOrderForControls(rowOrder, controls) {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const next = [];
|
|
32
|
+
for (const id of rowOrder) {
|
|
33
|
+
const controlId = rowControlId(id, controls);
|
|
34
|
+
if (seen.has(controlId))
|
|
35
|
+
continue;
|
|
36
|
+
seen.add(controlId);
|
|
37
|
+
next.push(controlId);
|
|
38
|
+
}
|
|
39
|
+
return next;
|
|
40
|
+
}
|
|
41
|
+
function parseLegacyAggregateRowId(id) {
|
|
42
|
+
const separator = id.indexOf("#");
|
|
43
|
+
if (separator <= 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
const match = /^aggregate\|(.+)$/u.exec(id.slice(separator + 1));
|
|
46
|
+
const discriminator = match?.[1];
|
|
47
|
+
if (!discriminator)
|
|
48
|
+
return undefined;
|
|
49
|
+
return { cardId: id.slice(0, separator), discriminator };
|
|
50
|
+
}
|
|
51
|
+
function belongsToCard(rowId, cardId) {
|
|
52
|
+
return rowId.startsWith(`${cardId}#`);
|
|
53
|
+
}
|
|
54
|
+
function matchesDiscriminator(rowId, discriminator) {
|
|
55
|
+
return rowId.endsWith(`|${discriminator}`);
|
|
56
|
+
}
|
|
57
|
+
function firstRowForLegacyId(rowIds, legacy) {
|
|
58
|
+
return rowIds.find((rowId) => belongsToCard(rowId, legacy.cardId) && matchesDiscriminator(rowId, legacy.discriminator));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolves configured row ids against the rows a card currently emits. Exact
|
|
62
|
+
* typed ids pass through untouched. A legacy aggregate id resolves to the
|
|
63
|
+
* first emitted row of that card with the same discriminator; when no such row
|
|
64
|
+
* exists yet it stays inert so it can match a later emission.
|
|
65
|
+
*
|
|
66
|
+
* A configured id that belongs to a control (its stable declared id or any
|
|
67
|
+
* alias) hides every id the control owns. That keeps one eye effective when the
|
|
68
|
+
* provider renders the same field in another shape, and keeps a hide saved
|
|
69
|
+
* under the previous shape working after the control gains a stable id.
|
|
70
|
+
*/
|
|
71
|
+
export function effectiveHiddenRowIds(rowIds, hiddenRows, controls = []) {
|
|
72
|
+
const hidden = new Set(hiddenRows);
|
|
73
|
+
if (hidden.size === 0)
|
|
74
|
+
return hidden;
|
|
75
|
+
for (const id of hiddenRows) {
|
|
76
|
+
const legacy = parseLegacyAggregateRowId(id);
|
|
77
|
+
if (!legacy)
|
|
78
|
+
continue;
|
|
79
|
+
// A provider that still emits aggregate rows keeps an exact hide.
|
|
80
|
+
if (rowIds.includes(id))
|
|
81
|
+
continue;
|
|
82
|
+
const first = firstRowForLegacyId(rowIds, legacy);
|
|
83
|
+
if (first === undefined)
|
|
84
|
+
continue;
|
|
85
|
+
hidden.delete(id);
|
|
86
|
+
hidden.add(first);
|
|
87
|
+
}
|
|
88
|
+
for (const control of controls) {
|
|
89
|
+
const ids = [control.rowId, ...(control.aliases ?? [])];
|
|
90
|
+
if (!ids.some((id) => hidden.has(id)))
|
|
91
|
+
continue;
|
|
92
|
+
for (const id of ids)
|
|
93
|
+
hidden.add(id);
|
|
94
|
+
}
|
|
95
|
+
return hidden;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rewrites every legacy aggregate id for `cardId` to the current row it
|
|
99
|
+
* resolves to, and drops ones that no longer resolve. Called only after an
|
|
100
|
+
* explicit Settings row toggle, so an untouched legacy choice keeps following
|
|
101
|
+
* whichever row is emitted first. Other cards and exact ids are preserved in
|
|
102
|
+
* order.
|
|
103
|
+
*/
|
|
104
|
+
export function materializeLegacyHiddenRowsForCard(cardId, hiddenRows, rowIds) {
|
|
105
|
+
const next = [];
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const push = (id) => {
|
|
108
|
+
if (seen.has(id))
|
|
109
|
+
return;
|
|
110
|
+
seen.add(id);
|
|
111
|
+
next.push(id);
|
|
112
|
+
};
|
|
113
|
+
for (const id of hiddenRows) {
|
|
114
|
+
const legacy = parseLegacyAggregateRowId(id);
|
|
115
|
+
if (!legacy || legacy.cardId !== cardId) {
|
|
116
|
+
push(id);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
// Keep an aggregate row that still exists as its own exact id.
|
|
120
|
+
if (rowIds.includes(id)) {
|
|
121
|
+
push(id);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const first = firstRowForLegacyId(rowIds, legacy);
|
|
125
|
+
if (first !== undefined)
|
|
126
|
+
push(first);
|
|
127
|
+
}
|
|
128
|
+
return next;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=row-visibility.js.map
|