pi-ui-extend 0.1.1 → 0.1.3

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.
@@ -114,6 +114,10 @@ export class AppMouseController {
114
114
  if (event.button !== 0)
115
115
  return;
116
116
  if (target?.kind === "toast") {
117
+ if (!toastTargetContainsEvent(target, event))
118
+ return;
119
+ if (target.action === "body")
120
+ return;
117
121
  if (this.copyErrorToast(target.id)) {
118
122
  this.showClickFlashForEvent(event);
119
123
  return;
@@ -235,6 +239,14 @@ export class AppMouseController {
235
239
  const statusTarget = this.statusTargetAt(event);
236
240
  if (statusTarget)
237
241
  return statusTarget;
242
+ const toastTarget = this.renderedTargets.get(event.y);
243
+ if (toastTarget?.kind === "toast" && toastTargetContainsEvent(toastTarget, event)) {
244
+ return {
245
+ y: event.y,
246
+ startColumn: toastTarget.startColumn ?? event.x,
247
+ endColumn: toastTarget.endColumn ?? event.x + 1,
248
+ };
249
+ }
238
250
  if (this.renderedTargets.has(event.y)) {
239
251
  const bounds = nonBlankLineBounds(this.renderedRowTexts.get(event.y) ?? "", event.x);
240
252
  return { y: event.y, startColumn: bounds.startColumn, endColumn: bounds.endColumn };
@@ -469,7 +481,8 @@ export class AppMouseController {
469
481
  const session = this.host.runtimeSession();
470
482
  if (!session)
471
483
  return false;
472
- this.host.showToast(formatDcpStatsToast(session), "info");
484
+ const message = formatDcpStatsToast(session);
485
+ this.host.showToast(message, "info", { variant: "dialog" });
473
486
  return true;
474
487
  }
475
488
  handleStatusModelUsageClick(event) {
@@ -910,6 +923,11 @@ export function screenSelectionLineText(row, text, startColumn, endColumn, input
910
923
  function sameConversationPoint(left, right) {
911
924
  return !!left && left.line === right.line && left.x === right.x;
912
925
  }
926
+ function toastTargetContainsEvent(target, event) {
927
+ if (target.startColumn === undefined || target.endColumn === undefined)
928
+ return true;
929
+ return event.x >= target.startColumn && event.x < target.endColumn;
930
+ }
913
931
  function displayCellsInColumnRange(text, startColumn, endColumn) {
914
932
  let cells = "";
915
933
  for (let column = startColumn; column < endColumn; column += 1) {
@@ -2,6 +2,9 @@ export type NerdFontInstallHost = {
2
2
  showToast(message: string, kind: "success" | "error" | "warning" | "info"): void;
3
3
  render(): void;
4
4
  };
5
+ export declare const FONT_FAMILY_NAME = "JetBrainsMono Nerd Font Mono";
6
+ export declare const FONT_FILE_NAME = "JetBrainsMonoNerdFontMono-Regular.ttf";
7
+ export declare const FONT_DOWNLOAD_URL = "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFontMono-Regular.ttf";
5
8
  export declare class NerdFontController {
6
9
  private readonly host;
7
10
  private ensureStarted;
@@ -9,3 +12,6 @@ export declare class NerdFontController {
9
12
  ensureInstalledOnStartup(): void;
10
13
  private ensureInstalled;
11
14
  }
15
+ export declare function isJetBrainsNerdFontInstalled(): Promise<boolean>;
16
+ export declare function installJetBrainsNerdFont(): Promise<string>;
17
+ export declare function userFontInstallPath(): string;
@@ -1,8 +1,12 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { readdir } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
3
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
3
4
  import { homedir } from "node:os";
4
- import { join } from "node:path";
5
+ import { dirname, join } from "node:path";
5
6
  const CASK_NAME = "font-jetbrains-mono-nerd-font";
7
+ export const FONT_FAMILY_NAME = "JetBrainsMono Nerd Font Mono";
8
+ export const FONT_FILE_NAME = "JetBrainsMonoNerdFontMono-Regular.ttf";
9
+ export const FONT_DOWNLOAD_URL = "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFontMono-Regular.ttf";
6
10
  const FONT_FILE_PATTERN = /(?:JetBrainsMono|JetBrains).*Nerd.*\.(?:ttf|otf)$/iu;
7
11
  export class NerdFontController {
8
12
  host;
@@ -19,17 +23,9 @@ export class NerdFontController {
19
23
  async ensureInstalled() {
20
24
  if (await isJetBrainsNerdFontInstalled())
21
25
  return;
22
- if (process.platform !== "darwin") {
23
- this.host.showToast("Nerd Font is missing; auto-install is only configured for macOS Homebrew", "warning");
24
- return;
25
- }
26
- if (!commandExists("brew")) {
27
- this.host.showToast("Nerd Font is missing; install Homebrew or JetBrainsMono Nerd Font manually", "warning");
28
- return;
29
- }
30
26
  this.host.showToast("Installing JetBrainsMono Nerd Font…", "info");
31
27
  try {
32
- await runBrewInstall();
28
+ await installJetBrainsNerdFont();
33
29
  if (await isJetBrainsNerdFontInstalled()) {
34
30
  this.host.showToast("JetBrainsMono Nerd Font installed", "success");
35
31
  }
@@ -45,18 +41,89 @@ export class NerdFontController {
45
41
  }
46
42
  }
47
43
  }
48
- async function isJetBrainsNerdFontInstalled() {
44
+ export async function isJetBrainsNerdFontInstalled() {
49
45
  if (commandExists("brew") && spawnSync("brew", ["list", "--cask", CASK_NAME], { stdio: "ignore" }).status === 0)
50
46
  return true;
51
- const fontDirs = [join(homedir(), "Library", "Fonts"), "/Library/Fonts", "/System/Library/Fonts"];
47
+ if (process.platform === "linux" && commandExists("fc-match")) {
48
+ const result = spawnSync("fc-match", ["-f", "%{family}", FONT_FAMILY_NAME], { encoding: "utf8" });
49
+ if (result.status === 0 && /JetBrains.*Nerd/iu.test(result.stdout))
50
+ return true;
51
+ }
52
+ const fontDirs = platformFontDirs();
52
53
  for (const dir of fontDirs) {
54
+ if (await directoryContainsFont(dir))
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ export async function installJetBrainsNerdFont() {
60
+ if (process.platform === "darwin" && commandExists("brew")) {
61
+ await runBrewInstall();
62
+ return CASK_NAME;
63
+ }
64
+ const targetPath = userFontInstallPath();
65
+ await mkdir(dirname(targetPath), { recursive: true });
66
+ const response = await fetch(FONT_DOWNLOAD_URL, {
67
+ headers: { "User-Agent": "pix-font-installer" },
68
+ signal: AbortSignal.timeout(30_000),
69
+ });
70
+ if (!response.ok)
71
+ throw new Error(`download failed with HTTP ${response.status}`);
72
+ const bytes = new Uint8Array(await response.arrayBuffer());
73
+ if (bytes.length < 100_000)
74
+ throw new Error("downloaded font is unexpectedly small");
75
+ await writeFile(targetPath, bytes);
76
+ if (process.platform === "linux")
77
+ runOptionalCommand("fc-cache", ["-f", dirname(targetPath)]);
78
+ if (process.platform === "win32")
79
+ registerWindowsUserFont(targetPath);
80
+ return targetPath;
81
+ }
82
+ export function userFontInstallPath() {
83
+ switch (process.platform) {
84
+ case "darwin":
85
+ return join(homedir(), "Library", "Fonts", FONT_FILE_NAME);
86
+ case "win32":
87
+ return join(process.env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local"), "Microsoft", "Windows", "Fonts", FONT_FILE_NAME);
88
+ default:
89
+ return join(homedir(), ".local", "share", "fonts", "pix", FONT_FILE_NAME);
90
+ }
91
+ }
92
+ function platformFontDirs() {
93
+ switch (process.platform) {
94
+ case "darwin":
95
+ return [join(homedir(), "Library", "Fonts"), "/Library/Fonts", "/System/Library/Fonts"];
96
+ case "win32":
97
+ return [
98
+ join(process.env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local"), "Microsoft", "Windows", "Fonts"),
99
+ join(process.env.WINDIR ?? "C:\\Windows", "Fonts"),
100
+ ];
101
+ default:
102
+ return [join(homedir(), ".local", "share", "fonts"), join(homedir(), ".fonts"), "/usr/local/share/fonts", "/usr/share/fonts"];
103
+ }
104
+ }
105
+ async function directoryContainsFont(root) {
106
+ if (!existsSync(root))
107
+ return false;
108
+ const pending = [{ dir: root, depth: 0 }];
109
+ let scanned = 0;
110
+ while (pending.length > 0 && scanned < 5_000) {
111
+ const current = pending.pop();
112
+ if (!current)
113
+ continue;
114
+ let entries;
53
115
  try {
54
- const files = await readdir(dir);
55
- if (files.some((file) => FONT_FILE_PATTERN.test(file)))
56
- return true;
116
+ entries = await readdir(current.dir, { withFileTypes: true });
57
117
  }
58
118
  catch {
59
- // Ignore unreadable/missing font directories.
119
+ continue;
120
+ }
121
+ for (const entry of entries) {
122
+ scanned += 1;
123
+ if (entry.isFile() && FONT_FILE_PATTERN.test(entry.name))
124
+ return true;
125
+ if (entry.isDirectory() && current.depth < 4)
126
+ pending.push({ dir: join(current.dir, entry.name), depth: current.depth + 1 });
60
127
  }
61
128
  }
62
129
  return false;
@@ -80,6 +147,20 @@ async function runBrewInstall() {
80
147
  });
81
148
  });
82
149
  }
150
+ function registerWindowsUserFont(fontPath) {
151
+ const escapedPath = fontPath.replaceAll("'", "''");
152
+ const escapedName = `${FONT_FAMILY_NAME} (TrueType)`.replaceAll("'", "''");
153
+ runOptionalCommand("powershell.exe", [
154
+ "-NoProfile",
155
+ "-ExecutionPolicy",
156
+ "Bypass",
157
+ "-Command",
158
+ `New-Item -Path 'HKCU:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts' -Force | Out-Null; New-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts' -Name '${escapedName}' -Value '${escapedPath}' -PropertyType String -Force | Out-Null`,
159
+ ]);
160
+ }
161
+ function runOptionalCommand(command, args) {
162
+ spawnSync(command, args, { stdio: "ignore" });
163
+ }
83
164
  function commandExists(command) {
84
165
  if (process.platform === "win32")
85
166
  return spawnSync("where", [command], { stdio: "ignore" }).status === 0;
@@ -243,10 +243,11 @@ export class AppRenderController {
243
243
  }
244
244
  for (const toastOverlay of renderToastOverlays(this.deps.toastController.toast.visibleStates, columns, Math.max(0, statusRow - topReservedRows - 1), this.deps.theme)) {
245
245
  const row = topReservedRows + toastOverlay.row;
246
- this.deps.mouseController.renderedTargets.set(row, { kind: "toast", id: toastOverlay.id });
247
- this.deps.mouseController.renderedRowTexts.set(row, toastOverlay.text);
248
- setRenderedBackground(row, this.deps.theme.colors.toastBackground);
249
- appendFrameOutput(regionForOverlayRow(row), row, this.renderFrameRow(row, toastOverlay.output));
246
+ const rowText = this.deps.mouseController.renderedRowTexts.get(row) ?? "";
247
+ if (toastOverlay.target)
248
+ this.deps.mouseController.renderedTargets.set(row, toastOverlay.target);
249
+ this.deps.mouseController.renderedRowTexts.set(row, overlayText(rowText, toastOverlay.column, toastOverlay.text));
250
+ appendFrameOutput(regionForOverlayRow(row), row, `\x1b[${row};${toastOverlay.column}H${toastOverlay.output}`);
250
251
  }
251
252
  if (topReservedRows === 0) {
252
253
  const newTabTarget = tabLayout.targets.find((target) => target.kind === "new-tab");
@@ -14,7 +14,7 @@ export async function checkPiCliAvailability(pathValue = process.env.PATH ?? "")
14
14
  return [];
15
15
  return [{
16
16
  kind: "error",
17
- message: "pi CLI is not available on PATH. Install pi or add it to PATH before starting pix.",
17
+ message: "pi CLI is not available on PATH. Run `pix install` or add pi to PATH before starting pix.",
18
18
  }];
19
19
  }
20
20
  export function checkPiToolsSuiteExtensionAvailability(extensionsResult) {
@@ -34,13 +34,16 @@ export function checkPiToolsSuiteExtensionAvailability(extensionsResult) {
34
34
  }
35
35
  async function executableExistsOnPath(command, pathValue) {
36
36
  const dirs = pathValue.split(delimiter).filter((part) => part.length > 0);
37
+ const names = process.platform === "win32" ? [command, `${command}.cmd`, `${command}.exe`, `${command}.bat`] : [command];
37
38
  for (const dir of dirs) {
38
- try {
39
- await access(join(dir, command), fsConstants.X_OK);
40
- return true;
41
- }
42
- catch {
43
- // Keep scanning PATH entries.
39
+ for (const name of names) {
40
+ try {
41
+ await access(join(dir, name), fsConstants.X_OK);
42
+ return true;
43
+ }
44
+ catch {
45
+ // Keep scanning PATH entries.
46
+ }
44
47
  }
45
48
  }
46
49
  return false;
@@ -1,4 +1,4 @@
1
- import { Toast, type ToastKind } from "../ui.js";
1
+ import { Toast, type ToastKind, type ToastVariant } from "../ui.js";
2
2
  export type AppToastControllerHost = {
3
3
  render(): void;
4
4
  };
@@ -7,7 +7,10 @@ export declare class AppToastController {
7
7
  readonly toast: Toast;
8
8
  private readonly timers;
9
9
  constructor(host: AppToastControllerHost);
10
- showToast(message: string, kind?: ToastKind): void;
10
+ showToast(message: string, kind?: ToastKind, options?: {
11
+ durationMs?: number;
12
+ variant?: ToastVariant;
13
+ }): void;
11
14
  dismissToast(toastId: number): void;
12
15
  clearToastTimers(): void;
13
16
  }
@@ -7,17 +7,20 @@ export class AppToastController {
7
7
  constructor(host) {
8
8
  this.host = host;
9
9
  }
10
- showToast(message, kind = "info") {
11
- const toastId = this.toast.show(message, kind);
12
- if (kind === "error") {
10
+ showToast(message, kind = "info", options = {}) {
11
+ const toastId = this.toast.show(message, kind, options.variant ? { variant: options.variant } : {});
12
+ if (kind === "error" || options.variant === "dialog") {
13
13
  this.host.render();
14
14
  return;
15
15
  }
16
+ const durationMs = typeof options.durationMs === "number" && Number.isFinite(options.durationMs) && options.durationMs > 0
17
+ ? Math.floor(options.durationMs)
18
+ : TOAST_DURATION_MS;
16
19
  const timer = setTimeout(() => {
17
20
  this.toast.hide(toastId);
18
21
  this.timers.delete(toastId);
19
22
  this.host.render();
20
- }, TOAST_DURATION_MS);
23
+ }, durationMs);
21
24
  this.timers.set(toastId, timer);
22
25
  timer.unref();
23
26
  this.host.render();
@@ -1,9 +1,12 @@
1
1
  import { type Theme } from "../theme.js";
2
2
  import type { ToastEntry } from "../ui.js";
3
+ import type { ToastLineTarget } from "./types.js";
3
4
  export type ToastOverlay = {
4
5
  id: number;
5
6
  row: number;
7
+ column: number;
6
8
  text: string;
7
9
  output: string;
10
+ target?: ToastLineTarget;
8
11
  };
9
12
  export declare function renderToastOverlays(states: readonly ToastEntry[], width: number, maxRows: number, theme: Theme): ToastOverlay[];
@@ -9,6 +9,10 @@ export function renderToastOverlays(states, width, maxRows, theme) {
9
9
  for (const state of [...states].reverse()) {
10
10
  if (overlays.length >= maxRows)
11
11
  break;
12
+ if (state.variant === "dialog") {
13
+ overlays.push(...renderDialogToastOverlay(state, width, Math.max(0, maxRows - overlays.length), theme, overlays.length));
14
+ continue;
15
+ }
12
16
  const icon = toastKindIcon(state.kind);
13
17
  const lines = toastMessageLines(state.message, icon, Math.max(1, width - 6));
14
18
  const visibleLines = lines.slice(0, Math.max(0, maxRows - overlays.length));
@@ -17,19 +21,22 @@ export function renderToastOverlays(states, width, maxRows, theme) {
17
21
  const contentWidth = Math.max(...visibleLines.map((line) => stringDisplayWidth(line)));
18
22
  const toastWidth = Math.min(Math.max(12, contentWidth + 2), Math.max(1, width - 4));
19
23
  const leftWidth = Math.max(0, width - toastWidth - 2);
20
- const rightWidth = Math.max(0, width - leftWidth - toastWidth);
24
+ const column = leftWidth + 1;
21
25
  for (const line of visibleLines) {
22
26
  const message = ` ${padOrTrimPlain(line, Math.max(0, toastWidth - 2))} `;
23
- const text = `${" ".repeat(leftWidth)}${padOrTrimPlain(message, toastWidth)}${" ".repeat(rightWidth)}`;
24
- const output = [
25
- colorLine("", leftWidth, { background: theme.colors.background }),
26
- colorLine(message, toastWidth, {
27
- ...toastKindStyle(state.kind, theme),
28
- bold: true,
29
- }),
30
- colorLine("", rightWidth, { background: theme.colors.background }),
31
- ].join("");
32
- overlays.push({ id: state.id, row: overlays.length + 1, text, output });
27
+ const text = padOrTrimPlain(message, toastWidth);
28
+ const output = colorLine(message, toastWidth, {
29
+ ...toastKindStyle(state.kind, theme),
30
+ bold: true,
31
+ });
32
+ overlays.push({
33
+ id: state.id,
34
+ row: overlays.length + 1,
35
+ column,
36
+ text,
37
+ output,
38
+ target: { kind: "toast", id: state.id, action: "toast", startColumn: column, endColumn: column + toastWidth },
39
+ });
33
40
  }
34
41
  }
35
42
  return overlays;
@@ -53,6 +60,60 @@ function toastMessageLines(message, icon, maxWidth) {
53
60
  }
54
61
  return lines.length > 0 ? lines : [firstPrefix.trimEnd()];
55
62
  }
63
+ function renderDialogToastOverlay(state, width, maxRows, theme, rowOffset) {
64
+ if (maxRows <= 0 || width <= 0)
65
+ return [];
66
+ const maxDialogWidth = Math.max(1, Math.min(width - 4, 72));
67
+ const icon = toastKindIcon(state.kind);
68
+ const closeLabel = `[${APP_ICONS.close}]`;
69
+ const wrappedLines = dialogMessageLines(state.message, Math.max(1, maxDialogWidth - 4));
70
+ const title = `${icon} Dialog`;
71
+ const requiredWidth = Math.max(16, stringDisplayWidth(` ${title} ${closeLabel} `) + 2, ...wrappedLines.map((line) => stringDisplayWidth(line) + 4));
72
+ const dialogWidth = Math.min(maxDialogWidth, Math.max(16, requiredWidth));
73
+ const bodyWidth = Math.max(1, dialogWidth - 4);
74
+ const bodyLines = dialogMessageLines(state.message, bodyWidth);
75
+ const bodyRows = Math.max(0, maxRows - 2);
76
+ const visibleBodyLines = bodyLines.slice(0, bodyRows);
77
+ const includeBottom = maxRows > 1;
78
+ const dialogRows = [
79
+ dialogTopLine(title, closeLabel, dialogWidth),
80
+ ...visibleBodyLines.map((line) => `│ ${padOrTrimPlain(line, bodyWidth)} │`),
81
+ ...(includeBottom ? [`╰${"─".repeat(Math.max(0, dialogWidth - 2))}╯`] : []),
82
+ ].slice(0, maxRows);
83
+ const leftWidth = Math.max(0, width - dialogWidth - 2);
84
+ const column = leftWidth + 1;
85
+ const style = toastKindStyle(state.kind, theme);
86
+ const closeStartColumn = column + 1 + dialogTopCloseOffset(title, closeLabel, dialogWidth);
87
+ const closeEndColumn = closeStartColumn + stringDisplayWidth(closeLabel);
88
+ return dialogRows.map((text, index) => ({
89
+ id: state.id,
90
+ row: rowOffset + index + 1,
91
+ column,
92
+ text,
93
+ output: colorLine(text, dialogWidth, { ...style, bold: true }),
94
+ target: index === 0
95
+ ? { kind: "toast", id: state.id, action: "close", startColumn: closeStartColumn, endColumn: closeEndColumn }
96
+ : { kind: "toast", id: state.id, action: "body", startColumn: column, endColumn: column + dialogWidth },
97
+ }));
98
+ }
99
+ function dialogMessageLines(message, maxWidth) {
100
+ const safeMaxWidth = Math.max(1, maxWidth);
101
+ const lines = sanitizeText(message).split("\n").flatMap((line) => wrapDisplayLine(line, safeMaxWidth));
102
+ return lines.length > 0 ? lines : [""];
103
+ }
104
+ function dialogTopLine(title, closeLabel, width) {
105
+ const innerWidth = Math.max(0, width - 2);
106
+ const closeOffset = dialogTopCloseOffset(title, closeLabel, width);
107
+ const leftLabel = ` ${title} `;
108
+ const spacer = " ".repeat(Math.max(0, closeOffset - stringDisplayWidth(leftLabel)));
109
+ return `╭${padOrTrimPlain(`${leftLabel}${spacer}${closeLabel} `, innerWidth)}╮`;
110
+ }
111
+ function dialogTopCloseOffset(title, closeLabel, width) {
112
+ const innerWidth = Math.max(0, width - 2);
113
+ const leftLabel = ` ${title} `;
114
+ const closeWidth = stringDisplayWidth(closeLabel);
115
+ return Math.max(stringDisplayWidth(leftLabel), innerWidth - closeWidth - 1);
116
+ }
56
117
  function toastKindIcon(kind) {
57
118
  switch (kind) {
58
119
  case "success":
@@ -227,10 +227,14 @@ export type RenderedLine = {
227
227
  } | {
228
228
  kind: "queue-message";
229
229
  id: string;
230
- } | {
231
- kind: "toast";
232
- id: number;
233
- };
230
+ } | ToastLineTarget;
231
+ };
232
+ export type ToastLineTarget = {
233
+ kind: "toast";
234
+ id: number;
235
+ action?: "toast" | "body" | "close";
236
+ startColumn?: number;
237
+ endColumn?: number;
234
238
  };
235
239
  export type ImageClickTarget = {
236
240
  start: number;
package/dist/ui.d.ts CHANGED
@@ -28,9 +28,11 @@ export declare class PopupMenu<T> {
28
28
  }
29
29
  export declare const TOAST_KINDS: readonly ["success", "error", "warning", "info"];
30
30
  export type ToastKind = (typeof TOAST_KINDS)[number];
31
+ export type ToastVariant = "compact" | "dialog";
31
32
  export type ToastState = {
32
33
  message: string;
33
34
  kind: ToastKind;
35
+ variant?: ToastVariant;
34
36
  };
35
37
  export type ToastEntry = ToastState & {
36
38
  id: number;
@@ -47,7 +49,9 @@ export declare function isToastKind(value: unknown): value is ToastKind;
47
49
  export declare class Toast {
48
50
  private readonly entries;
49
51
  private nextId;
50
- show(message: string, kind?: ToastKind): number;
52
+ show(message: string, kind?: ToastKind, options?: {
53
+ variant?: ToastVariant;
54
+ }): number;
51
55
  hide(id?: number): void;
52
56
  get state(): ToastState | undefined;
53
57
  get visibleStates(): readonly ToastEntry[];
package/dist/ui.js CHANGED
@@ -60,10 +60,10 @@ export function isToastKind(value) {
60
60
  export class Toast {
61
61
  entries = [];
62
62
  nextId = 1;
63
- show(message, kind = "info") {
63
+ show(message, kind = "info", options = {}) {
64
64
  const id = this.nextId;
65
65
  this.nextId += 1;
66
- this.entries.push({ id, message, kind, createdAt: Date.now() });
66
+ this.entries.push({ id, message, kind, createdAt: Date.now(), ...(options.variant ? { variant: options.variant } : {}) });
67
67
  return id;
68
68
  }
69
69
  hide(id) {