@opengeni/react 0.29.0 → 0.32.1
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/approvals.d.ts +14 -0
- package/dist/{chunk-M7X4JZOD.js → chunk-4QOQ2DSR.js} +8 -1
- package/dist/chunk-4QOQ2DSR.js.map +1 -0
- package/dist/{chunk-HQFPO7VX.js → chunk-7CJOAW3V.js} +24 -3
- package/dist/{chunk-HQFPO7VX.js.map → chunk-7CJOAW3V.js.map} +1 -1
- package/dist/{chunk-CSJBF3QJ.js → chunk-A2WITZTI.js} +377 -113
- package/dist/chunk-A2WITZTI.js.map +1 -0
- package/dist/{chunk-BC6RKIHS.js → chunk-GZ4KR67U.js} +11 -11
- package/dist/{chunk-AVLMIWYO.js → chunk-KZRUYCL4.js} +12 -6
- package/dist/chunk-KZRUYCL4.js.map +1 -0
- package/dist/{chunk-OKXCECLG.js → chunk-TCCE5ZU5.js} +171 -22
- package/dist/chunk-TCCE5ZU5.js.map +1 -0
- package/dist/chunk-U255M5EZ.js +178 -0
- package/dist/chunk-U255M5EZ.js.map +1 -0
- package/dist/{chunk-IPVOVOW6.js → chunk-WY2QN2CX.js} +2539 -2174
- package/dist/chunk-WY2QN2CX.js.map +1 -0
- package/dist/chunk-ZNNE2VES.js +6413 -0
- package/dist/chunk-ZNNE2VES.js.map +1 -0
- package/dist/client.d.ts +33 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/registry.d.ts +41 -0
- package/dist/commands/types.d.ts +85 -0
- package/dist/components/approval-surface.d.ts +28 -0
- package/dist/components/chat-composer.d.ts +51 -0
- package/dist/components/code-editor.d.ts +43 -0
- package/dist/components/command-palette.d.ts +25 -0
- package/dist/components/composer-transcription-control.d.ts +36 -0
- package/dist/components/composer.d.ts +277 -0
- package/dist/components/copy-button.d.ts +26 -0
- package/dist/components/desktop-viewer.d.ts +85 -0
- package/dist/components/diff-view.d.ts +38 -0
- package/dist/components/enrollment-consent.d.ts +33 -0
- package/dist/components/enrollment-device-flow.d.ts +27 -0
- package/dist/components/file-browser.d.ts +47 -0
- package/dist/components/fleet-tile.d.ts +18 -0
- package/dist/components/human-input-form.d.ts +47 -0
- package/dist/components/machine-card.d.ts +21 -0
- package/dist/components/machine-dock-bar.d.ts +31 -0
- package/dist/components/machine-health-pill.d.ts +9 -0
- package/dist/components/machine-metrics.d.ts +15 -0
- package/dist/components/machine-status-pill.d.ts +54 -0
- package/dist/components/machines/health.d.ts +25 -0
- package/dist/components/machines/machine-detail.d.ts +14 -0
- package/dist/components/machines/metric-history-chart.d.ts +24 -0
- package/dist/components/machines/metric-sparkline.d.ts +9 -0
- package/dist/components/machines/series.d.ts +24 -0
- package/dist/components/machines-dashboard.d.ts +30 -0
- package/dist/components/markdown.d.ts +31 -0
- package/dist/components/message-timeline.d.ts +98 -0
- package/dist/components/model-picker.d.ts +19 -0
- package/dist/components/pierre-diff.d.ts +34 -0
- package/dist/components/pierre-file.d.ts +27 -0
- package/dist/components/queue-draft-policy.d.ts +7 -0
- package/dist/components/queue-surface-implementation.d.ts +20 -0
- package/dist/components/queue-surface-state.d.ts +12 -0
- package/dist/components/queue-surface.d.ts +12 -0
- package/dist/components/sandbox-files.d.ts +49 -0
- package/dist/components/sandbox-terminal.d.ts +123 -0
- package/dist/components/sandbox-workspace.d.ts +128 -0
- package/dist/components/session-chrome.d.ts +70 -0
- package/dist/components/session-status.d.ts +25 -0
- package/dist/components/soften-streaming-markdown.d.ts +13 -0
- package/dist/components/stream-reveal.d.ts +37 -0
- package/dist/components/tip-follow.d.ts +139 -0
- package/dist/components/tooltip.d.ts +16 -0
- package/dist/components/workbench-changes.d.ts +34 -0
- package/dist/components/workspace-dock.d.ts +35 -0
- package/dist/composer.d.ts +11 -7
- package/dist/composer.js +9 -6
- package/dist/hooks/internal.d.ts +46 -0
- package/dist/hooks/use-available-models.d.ts +37 -0
- package/dist/hooks/use-billing-usage.d.ts +26 -0
- package/dist/hooks/use-codex-accounts.d.ts +69 -0
- package/dist/{use-composer-ClHy1rkL.d.ts → hooks/use-composer.d.ts} +16 -24
- package/dist/hooks/use-desktop-stream.d.ts +43 -0
- package/dist/hooks/use-environments.d.ts +35 -0
- package/dist/{use-file-attachments-BmT8WtqO.d.ts → hooks/use-file-attachments.d.ts} +6 -9
- package/dist/hooks/use-goal.d.ts +46 -0
- package/dist/hooks/use-human-input.d.ts +26 -0
- package/dist/hooks/use-last-started-turn-policy.d.ts +27 -0
- package/dist/hooks/use-machine-chip.d.ts +54 -0
- package/dist/hooks/use-machines.d.ts +81 -0
- package/dist/hooks/use-packs.d.ts +27 -0
- package/dist/hooks/use-relay-frame-stream.d.ts +53 -0
- package/dist/hooks/use-rigs.d.ts +87 -0
- package/dist/hooks/use-sandbox-files.d.ts +108 -0
- package/dist/hooks/use-sandbox-git.d.ts +58 -0
- package/dist/hooks/use-sandbox-terminal.d.ts +62 -0
- package/dist/hooks/use-scheduled-tasks.d.ts +15 -0
- package/dist/hooks/use-session-capabilities.d.ts +83 -0
- package/dist/hooks/use-session-control.d.ts +22 -0
- package/dist/hooks/use-session-events.d.ts +92 -0
- package/dist/hooks/use-session-lineage.d.ts +17 -0
- package/dist/hooks/use-session-mcp-approval-policy.d.ts +23 -0
- package/dist/hooks/use-session.d.ts +23 -0
- package/dist/hooks/use-slash-commands.d.ts +66 -0
- package/dist/hooks/use-terminal-stream.d.ts +46 -0
- package/dist/hooks/use-transcription.d.ts +73 -0
- package/dist/hooks/use-turn-queue.d.ts +44 -0
- package/dist/hooks/use-voice-input.d.ts +25 -0
- package/dist/hooks/use-windowed-sections.d.ts +42 -0
- package/dist/hooks/use-workspace-capture.d.ts +49 -0
- package/dist/hooks/use-workspace-edit.d.ts +73 -0
- package/dist/hooks/use-workspace-sessions.d.ts +30 -0
- package/dist/hooks/use-workspaces.d.ts +22 -0
- package/dist/human-input.d.ts +18 -0
- package/dist/index.d.ts +144 -2119
- package/dist/index.js +421 -324
- package/dist/index.js.map +1 -1
- package/dist/lib/clipboard.d.ts +7 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/format.d.ts +48 -0
- package/dist/lib/git-patch.d.ts +8 -0
- package/dist/lib/motion-inspect.d.ts +5 -0
- package/dist/lib/motion.d.ts +14 -0
- package/dist/lib/noto-sans-arabic-loader.d.ts +1 -0
- package/dist/lib/noto-sans-jp-loader.generated.d.ts +1 -0
- package/dist/lib/relay-wire.d.ts +30 -0
- package/dist/lib/use-portal-token-style.d.ts +9 -0
- package/dist/lib/use-theme-type.d.ts +5 -0
- package/dist/lib/use-unicode-fonts.d.ts +12 -0
- package/dist/lib/xterm-renderer.d.ts +19 -0
- package/dist/lib/xterm-theme.d.ts +75 -0
- package/dist/machines.d.ts +30 -413
- package/dist/machines.js +3 -3
- package/dist/model-policy.d.ts +32 -0
- package/dist/model-policy.js +33 -0
- package/dist/model-policy.js.map +1 -0
- package/dist/provider.d.ts +16 -0
- package/dist/{queue-surface-implementation-UQ535OKQ.js → queue-surface-implementation-THPAKGMD.js} +2 -2
- package/dist/{queue-surface-implementation-UQ535OKQ.js.map → queue-surface-implementation-THPAKGMD.js.map} +1 -1
- package/dist/session-context.d.ts +82 -0
- package/dist/session-ui.d.ts +10 -7
- package/dist/session-ui.js +9 -5
- package/dist/session.d.ts +28 -6
- package/dist/session.js +11 -11
- package/dist/timeline/activity-rail.d.ts +19 -0
- package/dist/timeline/disclosure-context.d.ts +14 -0
- package/dist/timeline/entrance.d.ts +14 -0
- package/dist/timeline/fleet-decision-projection.d.ts +9 -0
- package/dist/timeline/fleet-decision-row.d.ts +11 -0
- package/dist/timeline/fold-memory.d.ts +15 -0
- package/dist/timeline/index.d.ts +18 -0
- package/dist/timeline/parsers.d.ts +96 -0
- package/dist/timeline/projection.d.ts +38 -0
- package/dist/timeline/registry.d.ts +40 -0
- package/dist/timeline/screenshot-lightbox.d.ts +26 -0
- package/dist/timeline/seen-activity-ids.d.ts +2 -0
- package/dist/timeline/shared.d.ts +125 -0
- package/dist/timeline/tool-diff.d.ts +8 -0
- package/dist/timeline/tool-display-name.d.ts +10 -0
- package/dist/timeline/tool-renderers.d.ts +5 -0
- package/dist/timeline/turn-summary.d.ts +116 -0
- package/dist/{use-turn-queue-D_1a8W_l.d.ts → timeline/types.d.ts} +41 -69
- package/dist/types/machines.d.ts +11 -0
- package/package.json +8 -4
- package/src/client.ts +1 -0
- package/src/components/composer-transcription-control.tsx +278 -130
- package/src/components/composer.tsx +20 -15
- package/src/components/copy-button.tsx +127 -0
- package/src/components/markdown.tsx +231 -32
- package/src/components/message-timeline.tsx +1304 -378
- package/src/components/model-picker.tsx +83 -43
- package/src/components/queue-surface-implementation.tsx +1 -1
- package/src/components/session-chrome.tsx +942 -0
- package/src/components/soften-streaming-markdown.ts +205 -0
- package/src/components/stream-reveal.ts +195 -0
- package/src/components/tip-follow.ts +459 -0
- package/src/components/tooltip.tsx +103 -0
- package/src/composer.ts +6 -0
- package/src/hooks/internal.ts +30 -4
- package/src/hooks/use-available-models.ts +51 -4
- package/src/hooks/use-composer.ts +23 -3
- package/src/hooks/use-last-started-turn-policy.ts +95 -0
- package/src/hooks/use-session-events.ts +359 -5
- package/src/hooks/use-voice-input.ts +232 -0
- package/src/index.ts +47 -1
- package/src/lib/clipboard.ts +58 -0
- package/src/lib/format.ts +18 -0
- package/src/lib/motion-inspect.ts +5 -0
- package/src/lib/motion.ts +80 -0
- package/src/model-policy.ts +210 -0
- package/src/session-ui.ts +7 -0
- package/src/timeline/activity-rail.tsx +46 -7
- package/src/timeline/entrance.tsx +10 -0
- package/src/timeline/fold-memory.ts +52 -0
- package/src/timeline/index.ts +9 -1
- package/src/timeline/projection.ts +226 -41
- package/src/timeline/seen-activity-ids.ts +19 -0
- package/src/timeline/shared.tsx +1 -1
- package/src/timeline/tool-renderers.tsx +75 -6
- package/src/timeline/turn-summary.tsx +387 -97
- package/src/timeline/types.ts +21 -0
- package/styles/index.css +99 -7
- package/styles/tokens.css +44 -3
- package/dist/chunk-AVLMIWYO.js.map +0 -1
- package/dist/chunk-CSJBF3QJ.js.map +0 -1
- package/dist/chunk-IPVOVOW6.js.map +0 -1
- package/dist/chunk-M7X4JZOD.js.map +0 -1
- package/dist/chunk-OKXCECLG.js.map +0 -1
- package/dist/chunk-ZMNPFZWL.js +0 -3918
- package/dist/chunk-ZMNPFZWL.js.map +0 -1
- package/dist/composer-BMzimGTO.d.ts +0 -528
- package/dist/session-DaONt-dY.d.ts +0 -264
- package/dist/session-context-CAjlaeZb.d.ts +0 -84
- package/dist/session-ui-B5_roA95.d.ts +0 -259
- /package/dist/{chunk-BC6RKIHS.js.map → chunk-GZ4KR67U.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy plain text to the clipboard. Prefers the async Clipboard API; falls
|
|
3
|
+
* back to a short-lived textarea for older embeds / denied permissions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function copyTextToClipboard(text: string): Promise<boolean>;
|
|
6
|
+
/** Serialize an HTML table to tab-separated values (spreadsheet-friendly). */
|
|
7
|
+
export declare function tableElementToTsv(table: HTMLTableElement | null | undefined): string;
|
package/dist/lib/cn.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Compact relative time: "now", "42s", "7m", "3h", "2d", then a date. */
|
|
2
|
+
export declare function formatRelativeTime(iso: string, now?: Date): string;
|
|
3
|
+
/** Human-readable byte size: "512 B", "8.0 KB", "1.4 MB", "3 GB". */
|
|
4
|
+
export declare function formatBytes(bytes: number): string;
|
|
5
|
+
/** Single-line preview of arbitrary text, for tiles and collapsed rows. */
|
|
6
|
+
export declare function truncate(text: string, maxLength: number): string;
|
|
7
|
+
/** Render an unknown payload as readable text (pretty JSON when possible). */
|
|
8
|
+
export declare function stringifyPayload(value: unknown): string;
|
|
9
|
+
/** JSON.parse that returns `undefined` instead of throwing. */
|
|
10
|
+
export declare function tryParseJson(text: string): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* The canonical credit-death sentence. Credit exhaustion is the one failure a
|
|
13
|
+
* user can fix themselves — the copy must say what happened (empty balance),
|
|
14
|
+
* what to do (add credits), and what is safe (nothing was lost). Crucially it
|
|
15
|
+
* must NOT say "send a message to revive": a revive turn burns credits the
|
|
16
|
+
* workspace no longer has.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CREDIT_EXHAUSTION_MESSAGE = "Out of OpenGeni credits \u2014 this workspace's balance is empty. Add credits to continue; the conversation is preserved.";
|
|
19
|
+
/**
|
|
20
|
+
* Actionable composer copy for an edge rejection before a turn is accepted.
|
|
21
|
+
* Unlike an in-flight credit exhaustion, this path has not consumed the
|
|
22
|
+
* actor-private draft or any finalized attachment.
|
|
23
|
+
*/
|
|
24
|
+
export declare const COMPOSER_PAYMENT_REQUIRED_MESSAGE = "This turn requires OpenGeni managed credits, but the account balance is empty. Add credits or choose a connected Codex subscription model, then retry. Your draft and attachments are preserved.";
|
|
25
|
+
export declare function composerSubmissionErrorMessage(error: Error): string;
|
|
26
|
+
/**
|
|
27
|
+
* Does this failure/completion payload (or raw error string) mean the
|
|
28
|
+
* workspace ran out of OpenGeni credits? Matches the engine's
|
|
29
|
+
* "insufficient OpenGeni credits" text (case-insensitive, substring — it
|
|
30
|
+
* arrives both bare and wrapped in "Activity task failed: …") and the
|
|
31
|
+
* budget-exhausted segment limit the engine stamps on a turn it ended early.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isCreditExhaustion(input: {
|
|
34
|
+
error?: string | null;
|
|
35
|
+
detail?: string | null;
|
|
36
|
+
segmentLimit?: string | null;
|
|
37
|
+
} | string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Humanize engine/provider failure text before it reaches the timeline or a
|
|
40
|
+
* failure banner. Raw provider errors leak the wrong audience's instructions —
|
|
41
|
+
* "Incorrect API key … find your API key at platform.openai.com" tells a
|
|
42
|
+
* managed-deployment USER to fix credentials only an OPERATOR controls (and is
|
|
43
|
+
* flatly wrong for Azure or subscription-backed engines). Auth, quota, and
|
|
44
|
+
* credit-exhaustion failures collapse to one neutral, honest sentence; every
|
|
45
|
+
* other reason passes through untouched. Raw payloads stay available in the
|
|
46
|
+
* debug surfaces.
|
|
47
|
+
*/
|
|
48
|
+
export declare function humanizeFailureReason(reason: string | null): string | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GitFileDiff } from "@opengeni/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Reconstruct a unified-diff patch string for a single `GitFileDiff` so it can
|
|
4
|
+
* be fed to a generic patch renderer (e.g. Pierre's `PatchDiff`). The hook
|
|
5
|
+
* already carries per-line old/new numbers and a hunk header, so we emit a
|
|
6
|
+
* conventional `--- / +++ / @@` patch the parser understands.
|
|
7
|
+
*/
|
|
8
|
+
export declare function gitFileDiffToPatch(file: GitFileDiff): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function prefersReducedMotion(): boolean;
|
|
2
|
+
/** Test seam: forget the cached MediaQueryList so a stubbed matchMedia applies. */
|
|
3
|
+
export declare function resetReducedMotionCache(): void;
|
|
4
|
+
/** Active VT type for markdown crystallize — scoped CSS, not a full-page blink. */
|
|
5
|
+
export declare const MARKDOWN_CRYSTALLIZE_VT_TYPE = "og-md-crystallize";
|
|
6
|
+
/**
|
|
7
|
+
* Run a DOM update inside the browser View Transition API when available.
|
|
8
|
+
* Snapshots the before/after paint and cross-fades (or custom CSS morphs)
|
|
9
|
+
* between them — the platform "morph" primitive React's experimental
|
|
10
|
+
* `<ViewTransition>` wraps. Falls back to a synchronous update.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runViewTransition(update: () => void, options?: {
|
|
13
|
+
types?: string[];
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadNotoSansArabic(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadNotoSansJp(text: string): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** `StreamKind.STREAM_KIND_DESKTOP` (agent-proto enum value). */
|
|
2
|
+
export declare const STREAM_KIND_DESKTOP = 2;
|
|
3
|
+
/** `StreamRole.STREAM_ROLE_CLIENT` (agent-proto enum value). */
|
|
4
|
+
export declare const STREAM_ROLE_CLIENT = 2;
|
|
5
|
+
export interface RelayChannel {
|
|
6
|
+
channelId: string;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
agentId: string;
|
|
9
|
+
kind: number;
|
|
10
|
+
port: number;
|
|
11
|
+
}
|
|
12
|
+
export interface RelayStreamOpen {
|
|
13
|
+
channel: RelayChannel;
|
|
14
|
+
token: string;
|
|
15
|
+
role: number;
|
|
16
|
+
resumeFromSeq: string;
|
|
17
|
+
}
|
|
18
|
+
/** Encode a `StreamOpen`, byte-compatible with `StreamOpen.encode(...).finish()`. */
|
|
19
|
+
export declare function encodeStreamOpen(message: RelayStreamOpen): Uint8Array;
|
|
20
|
+
/** Decode a `StreamOpenAck` (we need `accepted` + the error message). */
|
|
21
|
+
export declare function decodeStreamOpenAck(bytes: Uint8Array): {
|
|
22
|
+
accepted: boolean;
|
|
23
|
+
error?: {
|
|
24
|
+
message?: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** Decode a `StreamFrame`, extracting only the `data` (framebuffer PNG) bytes. */
|
|
28
|
+
export declare function decodeStreamFrame(bytes: Uint8Array): {
|
|
29
|
+
data: Uint8Array;
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CSSProperties, type RefObject } from "react";
|
|
2
|
+
export type PortalTokenStyle = CSSProperties & Record<`--${string}`, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Copy the effective SDK tokens across a portal boundary. A locally themed or
|
|
5
|
+
* rebranded embed cannot rely on CSS inheritance once a portal mounts under
|
|
6
|
+
* `<body>`. Ancestor theme/class/style mutations and OS color-scheme changes
|
|
7
|
+
* keep the copied values live.
|
|
8
|
+
*/
|
|
9
|
+
export declare function usePortalTokenStyle(sourceRef: RefObject<HTMLElement | null>): PortalTokenStyle;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type UnicodeFontNeeds = {
|
|
2
|
+
japanese: boolean;
|
|
3
|
+
arabic: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function detectUnicodeFontNeeds(values: Iterable<string>): UnicodeFontNeeds;
|
|
6
|
+
/**
|
|
7
|
+
* Load large script-specific font manifests only when visible workspace content
|
|
8
|
+
* needs them. Fontsource splits the actual glyphs by unicode-range, so Chromium
|
|
9
|
+
* then fetches only the small shards used by the path instead of charging every
|
|
10
|
+
* Latin-only session for the complete font.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useUnicodeFallbackFonts(values: readonly string[]): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type RendererTier = "webgl" | "canvas" | "dom";
|
|
2
|
+
export type RendererAddon = {
|
|
3
|
+
dispose: () => void;
|
|
4
|
+
};
|
|
5
|
+
/** A loader constructs + `loadAddon`s its renderer, wiring `onLoss` to the
|
|
6
|
+
* addon's context-loss event, and throws if the renderer can't initialize. */
|
|
7
|
+
export type RendererLoaders = {
|
|
8
|
+
webgl?: ((onLoss: () => void) => Promise<RendererAddon>) | undefined;
|
|
9
|
+
canvas?: (() => Promise<RendererAddon>) | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** The next lower renderer tier, or null at the bottom (DOM). Pure. */
|
|
12
|
+
export declare function nextRendererTier(tier: RendererTier): RendererTier | null;
|
|
13
|
+
/**
|
|
14
|
+
* Attach the highest renderer tier at or below `prefer` that initializes,
|
|
15
|
+
* reporting the settled tier via `onTier`. On a WebGL/canvas context loss the
|
|
16
|
+
* loader's `onLoss` re-enters at the next tier down, so `onTier` is called again
|
|
17
|
+
* with the downgraded tier. Returns the tier chosen on this pass.
|
|
18
|
+
*/
|
|
19
|
+
export declare function attachRenderer(prefer: RendererTier, loaders: RendererLoaders, onTier: (tier: RendererTier) => void): Promise<RendererTier>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { XtermTheme } from "../components/sandbox-terminal";
|
|
2
|
+
export type ThemeMode = "dark" | "light";
|
|
3
|
+
/** Reads a resolved token value (already `getComputedStyle`-flattened). */
|
|
4
|
+
export type TokenReader = (name: string) => string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* The 16 ANSI colors + selection/cursor treatment, designed against the og
|
|
7
|
+
* OKLCH palette. Hues are borrowed from the og status ramp so terminal color
|
|
8
|
+
* reads as part of the same system: red≈status-failed(22), green≈status-idle
|
|
9
|
+
* (155), yellow≈status-running(80), blue≈accent(255), magenta≈status-waiting
|
|
10
|
+
* (305), cyan≈200. Dark uses lifted lightness on the dark slate ground; light
|
|
11
|
+
* uses deeper, more saturated inks on the near-white ground. Bright variants
|
|
12
|
+
* add lightness + a touch of chroma. `black`/`white` are neutral slate ramp
|
|
13
|
+
* stops (never pure #000/#fff — that clashes with the calm neutral ground).
|
|
14
|
+
*/
|
|
15
|
+
export type AnsiPalette = {
|
|
16
|
+
black: string;
|
|
17
|
+
red: string;
|
|
18
|
+
green: string;
|
|
19
|
+
yellow: string;
|
|
20
|
+
blue: string;
|
|
21
|
+
magenta: string;
|
|
22
|
+
cyan: string;
|
|
23
|
+
white: string;
|
|
24
|
+
brightBlack: string;
|
|
25
|
+
brightRed: string;
|
|
26
|
+
brightGreen: string;
|
|
27
|
+
brightYellow: string;
|
|
28
|
+
brightBlue: string;
|
|
29
|
+
brightMagenta: string;
|
|
30
|
+
brightCyan: string;
|
|
31
|
+
brightWhite: string;
|
|
32
|
+
/** Selection wash + its foreground; sits over the terminal ground. */
|
|
33
|
+
selectionBackground: string;
|
|
34
|
+
selectionForeground: string;
|
|
35
|
+
selectionInactiveBackground: string;
|
|
36
|
+
};
|
|
37
|
+
/** The designed ANSI-16 palette for a theme mode. Pure. */
|
|
38
|
+
export declare function ogAnsiPalette(mode: ThemeMode): AnsiPalette;
|
|
39
|
+
/**
|
|
40
|
+
* Build a COMPLETE xterm ITheme from token values. Background/foreground/cursor
|
|
41
|
+
* come from the live `--og-*` tokens (so an embedder's rebrand flows through);
|
|
42
|
+
* the ANSI-16 + selection come from the designed palette for `mode`. Every ANSI
|
|
43
|
+
* slot is always set — xterm never falls back to its stock VGA colors. Pure.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildXtermTheme(read: TokenReader, mode: ThemeMode): XtermTheme;
|
|
46
|
+
/**
|
|
47
|
+
* Derive a COMPLETE xterm `ITheme` from the live `--og-*` token system on the
|
|
48
|
+
* DOM. Reads the COMPUTED values so xterm gets concrete colors, detects the
|
|
49
|
+
* active theme mode, and fills every ANSI slot. Call on mount + re-derive on a
|
|
50
|
+
* `data-og-theme` flip. SSR-safe: returns undefined off the DOM.
|
|
51
|
+
*
|
|
52
|
+
* `root` should be an element INSIDE the themed subtree (e.g. the terminal
|
|
53
|
+
* container) so nested `[data-og-theme]` themes resolve correctly; when omitted
|
|
54
|
+
* it falls back to the nearest `[data-og-theme]` element, then documentElement.
|
|
55
|
+
*/
|
|
56
|
+
export declare function xtermThemeFromTokens(root?: HTMLElement | null): XtermTheme | undefined;
|
|
57
|
+
export type ResolvedTerminalFont = {
|
|
58
|
+
fontFamily: string;
|
|
59
|
+
fontSize: number;
|
|
60
|
+
lineHeight: number;
|
|
61
|
+
};
|
|
62
|
+
export type FontOverrides = {
|
|
63
|
+
fontFamily?: string | undefined;
|
|
64
|
+
fontSize?: number | undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve xterm's font from token values. The critical bug this fixes:
|
|
68
|
+
* `fontFamily: "var(--og-font-mono)"` is measured by xterm via a canvas font
|
|
69
|
+
* string where `var()` does NOT resolve, so xterm silently mis-measures every
|
|
70
|
+
* glyph. Here the family is a CONCRETE stack; a `var(` in the input is treated
|
|
71
|
+
* as unresolved and replaced with the fallback. Pure over a token `read`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveTerminalFontFromReader(read: TokenReader, overrides?: FontOverrides): ResolvedTerminalFont;
|
|
74
|
+
/** DOM wrapper: resolve the terminal font from an element's computed tokens. */
|
|
75
|
+
export declare function resolveTerminalFont(el: HTMLElement, overrides?: FontOverrides): ResolvedTerminalFont;
|