@vvedantb/ui 0.85.0 → 0.86.0

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/app/src/index.ts CHANGED
@@ -16,6 +16,11 @@ export {
16
16
  fetchDeployFingerprint,
17
17
  fingerprintFromHtml,
18
18
  } from "./update/deployFingerprint.js";
19
+ export {
20
+ fetchReleaseNotes,
21
+ newReleaseNotes,
22
+ type ReleaseNote,
23
+ } from "./update/releaseNotes.js";
19
24
  export {
20
25
  showUpdateAvailableToast,
21
26
  startUpdateAvailableWatcher,
@@ -0,0 +1,74 @@
1
+ /** One changelog entry of a deploy, from its `/release-notes.json`. */
2
+ export type ReleaseNote = { id: string; date: string; title: string };
3
+
4
+ export type WhatsNewState = {
5
+ notes: ReleaseNote[];
6
+ refresh: () => void;
7
+ onClose: () => void;
8
+ };
9
+
10
+ function isReleaseNote(value: unknown): value is ReleaseNote {
11
+ if (typeof value !== "object" || value === null) return false;
12
+ const note = value as Record<string, unknown>;
13
+ return typeof note.id === "string" && typeof note.date === "string" && typeof note.title === "string";
14
+ }
15
+
16
+ /**
17
+ * The live deploy's `/release-notes.json` entries. Null when the deploy has
18
+ * no such file (an SPA fallback answers HTML) or the request fails.
19
+ */
20
+ export async function fetchReleaseNotes(origin: string): Promise<ReleaseNote[] | null> {
21
+ try {
22
+ const response = await fetch(`${origin}/release-notes.json?_vb=${Date.now()}`, {
23
+ cache: "no-store",
24
+ headers: { Accept: "application/json" },
25
+ });
26
+ if (!response.ok) return null;
27
+ const body: unknown = await response.json();
28
+ const notes = (body as { notes?: unknown } | null)?.notes;
29
+ return Array.isArray(notes) ? notes.filter(isReleaseNote) : null;
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * The entries of `next` that `current` does not have, in `next`'s order.
37
+ * Empty when either deploy has no release notes.
38
+ */
39
+ export function newReleaseNotes(current: ReleaseNote[] | null, next: ReleaseNote[] | null): ReleaseNote[] {
40
+ if (!current || !next) return [];
41
+ const seen = new Set(current.map((note) => note.id));
42
+ return next.filter((note) => !seen.has(note.id));
43
+ }
44
+
45
+ let whatsNew: WhatsNewState | null = null;
46
+ const listeners = new Set<() => void>();
47
+
48
+ function emit(): void {
49
+ for (const listener of listeners) listener();
50
+ }
51
+
52
+ /** Open the "What's new" dialog that `SonnerToaster` renders. */
53
+ export function openWhatsNew(state: WhatsNewState): void {
54
+ whatsNew = state;
55
+ emit();
56
+ }
57
+
58
+ /** Close the "What's new" dialog. */
59
+ export function closeWhatsNew(): void {
60
+ if (whatsNew === null) return;
61
+ whatsNew = null;
62
+ emit();
63
+ }
64
+
65
+ export function subscribeWhatsNew(listener: () => void): () => void {
66
+ listeners.add(listener);
67
+ return () => {
68
+ listeners.delete(listener);
69
+ };
70
+ }
71
+
72
+ export function getWhatsNew(): WhatsNewState | null {
73
+ return whatsNew;
74
+ }
@@ -1,10 +1,17 @@
1
1
  import { fetchDeployFingerprint } from "./deployFingerprint.js";
2
+ import {
3
+ fetchReleaseNotes,
4
+ newReleaseNotes,
5
+ openWhatsNew,
6
+ type ReleaseNote,
7
+ } from "./releaseNotes.js";
2
8
 
3
9
  export type UpdateToastOptions = {
4
10
  id: string;
5
11
  description: string;
6
12
  duration: number;
7
13
  action: { label: string; onClick: () => void };
14
+ cancel?: { label: string; onClick: () => void };
8
15
  };
9
16
 
10
17
  export type UpdateAvailableWatcherOptions = {
@@ -15,12 +22,15 @@ export type UpdateAvailableWatcherOptions = {
15
22
  toastId?: string;
16
23
  enabled?: boolean;
17
24
  reload?: () => void;
25
+ onWhatsNew?: (notes: ReleaseNote[], refresh: () => void) => void;
18
26
  };
19
27
 
20
28
  export type ShowUpdateAvailableToastOptions = Pick<
21
29
  UpdateAvailableWatcherOptions,
22
- "toast" | "closeConvex" | "toastId" | "reload"
23
- >;
30
+ "toast" | "closeConvex" | "toastId" | "reload" | "onWhatsNew"
31
+ > & {
32
+ notes?: ReleaseNote[];
33
+ };
24
34
 
25
35
  const DEFAULT_POLL_MS = 60_000;
26
36
  const DEFAULT_TOAST_ID = "app-update-available";
@@ -29,27 +39,40 @@ const DEFAULT_TOAST_ID = "app-update-available";
29
39
  * Show the sticky "Update available" toast with a Refresh action. Refresh
30
40
  * calls `closeConvex` (errors ignored), then reloads. The same `toastId`
31
41
  * replaces an open toast instead of stacking a second one.
42
+ *
43
+ * With `notes`, the toast also has a "What's new" button. It calls
44
+ * `onWhatsNew`, else opens the dialog that `SonnerToaster` renders; closing
45
+ * that dialog shows the toast again.
32
46
  */
33
- export function showUpdateAvailableToast({
34
- toast,
35
- closeConvex,
36
- toastId = DEFAULT_TOAST_ID,
37
- reload = () => window.location.reload(),
38
- }: ShowUpdateAvailableToastOptions): void {
47
+ export function showUpdateAvailableToast(options: ShowUpdateAvailableToastOptions): void {
48
+ const {
49
+ toast,
50
+ closeConvex,
51
+ toastId = DEFAULT_TOAST_ID,
52
+ reload = () => window.location.reload(),
53
+ onWhatsNew,
54
+ notes = [],
55
+ } = options;
56
+ const refresh = (): void => {
57
+ try {
58
+ closeConvex?.();
59
+ } catch {
60
+ }
61
+ reload();
62
+ };
63
+ const showWhatsNew = (): void => {
64
+ if (onWhatsNew) {
65
+ onWhatsNew(notes, refresh);
66
+ return;
67
+ }
68
+ openWhatsNew({ notes, refresh, onClose: () => showUpdateAvailableToast(options) });
69
+ };
39
70
  toast.message("Update available", {
40
71
  id: toastId,
41
72
  description: "Refresh to load the latest version.",
42
73
  duration: Number.POSITIVE_INFINITY,
43
- action: {
44
- label: "Refresh",
45
- onClick: () => {
46
- try {
47
- closeConvex?.();
48
- } catch {
49
- }
50
- reload();
51
- },
52
- },
74
+ action: { label: "Refresh", onClick: refresh },
75
+ ...(notes.length > 0 ? { cancel: { label: "What's new", onClick: showWhatsNew } } : {}),
53
76
  });
54
77
  }
55
78
 
@@ -57,6 +80,10 @@ export function showUpdateAvailableToast({
57
80
  * Poll the live index HTML for a new Vite asset fingerprint (and re-check when
58
81
  * the tab becomes visible). Calls `showUpdateAvailableToast` once when a newer
59
82
  * deploy is serving. Returns a stop function.
83
+ *
84
+ * It also reads `/release-notes.json` (written by `@vvedantb/config`'s
85
+ * `releaseNotes`) at the start and again when the new deploy shows. The
86
+ * toast offers "What's new" only for entries the running deploy lacks.
60
87
  */
61
88
  export function startUpdateAvailableWatcher(
62
89
  options: UpdateAvailableWatcherOptions,
@@ -69,17 +96,21 @@ export function startUpdateAvailableWatcher(
69
96
  toastId,
70
97
  enabled = true,
71
98
  reload,
99
+ onWhatsNew,
72
100
  } = options;
73
101
  if (!enabled) return () => {};
74
102
 
75
103
  let cancelled = false;
76
104
  let shown = false;
77
105
  let baseline: string | null = null;
106
+ let baselineNotes: ReleaseNote[] | null = null;
78
107
 
79
- const showToast = (): void => {
108
+ const showToast = async (): Promise<void> => {
80
109
  if (shown) return;
81
110
  shown = true;
82
- showUpdateAvailableToast({ toast, closeConvex, toastId, reload });
111
+ const notes = newReleaseNotes(baselineNotes, await fetchReleaseNotes(origin));
112
+ if (cancelled) return;
113
+ showUpdateAvailableToast({ toast, closeConvex, toastId, reload, onWhatsNew, notes });
83
114
  };
84
115
 
85
116
  const check = async (): Promise<void> => {
@@ -88,9 +119,10 @@ export function startUpdateAvailableWatcher(
88
119
  if (cancelled || next === null) return;
89
120
  if (baseline === null) {
90
121
  baseline = next;
122
+ baselineNotes = await fetchReleaseNotes(origin);
91
123
  return;
92
124
  }
93
- if (next !== baseline) showToast();
125
+ if (next !== baseline) await showToast();
94
126
  };
95
127
 
96
128
  void check();
@@ -3,6 +3,7 @@ export { requestConfirm, shouldSkipConfirm } from "./confirm/confirmSkip.js";
3
3
  export { useRequestConfirm } from "./confirm/useRequestConfirm.js";
4
4
  export { ConfirmSkipHint, skipConfirmTitle } from "./confirm/ConfirmSkipHint.js";
5
5
  export { fetchDeployFingerprint, fingerprintFromHtml } from "./update/deployFingerprint.js";
6
+ export { fetchReleaseNotes, newReleaseNotes } from "./update/releaseNotes.js";
6
7
  export { showUpdateAvailableToast, startUpdateAvailableWatcher } from "./update/updateWatcher.js";
7
8
  export { isChunkLoadError, claimStaleDeployReload, reloadForStaleDeploy, stripStaleDeployReloadParam, installStaleDeployReload, STALE_DEPLOY_RELOAD_KEY, STALE_DEPLOY_RELOAD_PARAM } from "./update/staleDeployReload.js";
8
9
  export { SettingsSection } from "./settings/SettingsSection.js";
@@ -0,0 +1,65 @@
1
+ /** One changelog entry of a deploy, from its `/release-notes.json`. */
2
+
3
+ function isReleaseNote(value) {
4
+ if (typeof value !== "object" || value === null) return false;
5
+ const note = value;
6
+ return typeof note.id === "string" && typeof note.date === "string" && typeof note.title === "string";
7
+ }
8
+
9
+ /**
10
+ * The live deploy's `/release-notes.json` entries. Null when the deploy has
11
+ * no such file (an SPA fallback answers HTML) or the request fails.
12
+ */
13
+ export async function fetchReleaseNotes(origin) {
14
+ try {
15
+ const response = await fetch(`${origin}/release-notes.json?_vb=${Date.now()}`, {
16
+ cache: "no-store",
17
+ headers: {
18
+ Accept: "application/json"
19
+ }
20
+ });
21
+ if (!response.ok) return null;
22
+ const body = await response.json();
23
+ const notes = body?.notes;
24
+ return Array.isArray(notes) ? notes.filter(isReleaseNote) : null;
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+
30
+ /**
31
+ * The entries of `next` that `current` does not have, in `next`'s order.
32
+ * Empty when either deploy has no release notes.
33
+ */
34
+ export function newReleaseNotes(current, next) {
35
+ if (!current || !next) return [];
36
+ const seen = new Set(current.map(note => note.id));
37
+ return next.filter(note => !seen.has(note.id));
38
+ }
39
+ let whatsNew = null;
40
+ const listeners = new Set();
41
+ function emit() {
42
+ for (const listener of listeners) listener();
43
+ }
44
+
45
+ /** Open the "What's new" dialog that `SonnerToaster` renders. */
46
+ export function openWhatsNew(state) {
47
+ whatsNew = state;
48
+ emit();
49
+ }
50
+
51
+ /** Close the "What's new" dialog. */
52
+ export function closeWhatsNew() {
53
+ if (whatsNew === null) return;
54
+ whatsNew = null;
55
+ emit();
56
+ }
57
+ export function subscribeWhatsNew(listener) {
58
+ listeners.add(listener);
59
+ return () => {
60
+ listeners.delete(listener);
61
+ };
62
+ }
63
+ export function getWhatsNew() {
64
+ return whatsNew;
65
+ }
@@ -1,4 +1,5 @@
1
1
  import { fetchDeployFingerprint } from "./deployFingerprint.js";
2
+ import { fetchReleaseNotes, newReleaseNotes, openWhatsNew } from "./releaseNotes.js";
2
3
  const DEFAULT_POLL_MS = 60_000;
3
4
  const DEFAULT_TOAST_ID = "app-update-available";
4
5
 
@@ -6,26 +7,51 @@ const DEFAULT_TOAST_ID = "app-update-available";
6
7
  * Show the sticky "Update available" toast with a Refresh action. Refresh
7
8
  * calls `closeConvex` (errors ignored), then reloads. The same `toastId`
8
9
  * replaces an open toast instead of stacking a second one.
10
+ *
11
+ * With `notes`, the toast also has a "What's new" button. It calls
12
+ * `onWhatsNew`, else opens the dialog that `SonnerToaster` renders; closing
13
+ * that dialog shows the toast again.
9
14
  */
10
- export function showUpdateAvailableToast({
11
- toast,
12
- closeConvex,
13
- toastId = DEFAULT_TOAST_ID,
14
- reload = () => window.location.reload()
15
- }) {
15
+ export function showUpdateAvailableToast(options) {
16
+ const {
17
+ toast,
18
+ closeConvex,
19
+ toastId = DEFAULT_TOAST_ID,
20
+ reload = () => window.location.reload(),
21
+ onWhatsNew,
22
+ notes = []
23
+ } = options;
24
+ const refresh = () => {
25
+ try {
26
+ closeConvex?.();
27
+ } catch {}
28
+ reload();
29
+ };
30
+ const showWhatsNew = () => {
31
+ if (onWhatsNew) {
32
+ onWhatsNew(notes, refresh);
33
+ return;
34
+ }
35
+ openWhatsNew({
36
+ notes,
37
+ refresh,
38
+ onClose: () => showUpdateAvailableToast(options)
39
+ });
40
+ };
16
41
  toast.message("Update available", {
17
42
  id: toastId,
18
43
  description: "Refresh to load the latest version.",
19
44
  duration: Number.POSITIVE_INFINITY,
20
45
  action: {
21
46
  label: "Refresh",
22
- onClick: () => {
23
- try {
24
- closeConvex?.();
25
- } catch {}
26
- reload();
47
+ onClick: refresh
48
+ },
49
+ ...(notes.length > 0 ? {
50
+ cancel: {
51
+ label: "What's new",
52
+ onClick: showWhatsNew
27
53
  }
28
- }
54
+ } : {})
29
55
  });
30
56
  }
31
57
 
@@ -33,6 +59,10 @@ export function showUpdateAvailableToast({
33
59
  * Poll the live index HTML for a new Vite asset fingerprint (and re-check when
34
60
  * the tab becomes visible). Calls `showUpdateAvailableToast` once when a newer
35
61
  * deploy is serving. Returns a stop function.
62
+ *
63
+ * It also reads `/release-notes.json` (written by `@vvedantb/config`'s
64
+ * `releaseNotes`) at the start and again when the new deploy shows. The
65
+ * toast offers "What's new" only for entries the running deploy lacks.
36
66
  */
37
67
  export function startUpdateAvailableWatcher(options) {
38
68
  const {
@@ -42,20 +72,26 @@ export function startUpdateAvailableWatcher(options) {
42
72
  pollMs = DEFAULT_POLL_MS,
43
73
  toastId,
44
74
  enabled = true,
45
- reload
75
+ reload,
76
+ onWhatsNew
46
77
  } = options;
47
78
  if (!enabled) return () => {};
48
79
  let cancelled = false;
49
80
  let shown = false;
50
81
  let baseline = null;
51
- const showToast = () => {
82
+ let baselineNotes = null;
83
+ const showToast = async () => {
52
84
  if (shown) return;
53
85
  shown = true;
86
+ const notes = newReleaseNotes(baselineNotes, await fetchReleaseNotes(origin));
87
+ if (cancelled) return;
54
88
  showUpdateAvailableToast({
55
89
  toast,
56
90
  closeConvex,
57
91
  toastId,
58
- reload
92
+ reload,
93
+ onWhatsNew,
94
+ notes
59
95
  });
60
96
  };
61
97
  const check = async () => {
@@ -64,9 +100,10 @@ export function startUpdateAvailableWatcher(options) {
64
100
  if (cancelled || next === null) return;
65
101
  if (baseline === null) {
66
102
  baseline = next;
103
+ baselineNotes = await fetchReleaseNotes(origin);
67
104
  return;
68
105
  }
69
- if (next !== baseline) showToast();
106
+ if (next !== baseline) await showToast();
70
107
  };
71
108
  void check();
72
109
  const intervalId = setInterval(() => {
@@ -175,6 +175,7 @@ export { requestConfirm, shouldSkipConfirm } from "../app/src/confirm/confirmSki
175
175
  export { useRequestConfirm } from "../app/src/confirm/useRequestConfirm.js";
176
176
  export { ConfirmSkipHint, skipConfirmTitle } from "../app/src/confirm/ConfirmSkipHint.js";
177
177
  export { fetchDeployFingerprint, fingerprintFromHtml } from "../app/src/update/deployFingerprint.js";
178
+ export { fetchReleaseNotes, newReleaseNotes } from "../app/src/update/releaseNotes.js";
178
179
  export { showUpdateAvailableToast, startUpdateAvailableWatcher } from "../app/src/update/updateWatcher.js";
179
180
  export { isChunkLoadError, claimStaleDeployReload, reloadForStaleDeploy, stripStaleDeployReloadParam, installStaleDeployReload, STALE_DEPLOY_RELOAD_KEY, STALE_DEPLOY_RELOAD_PARAM } from "../app/src/update/staleDeployReload.js";
180
181
  export { SettingsSection } from "../app/src/settings/SettingsSection.js";
@@ -3,7 +3,8 @@ import { Toaster as SonnerPrimitive } from "sonner";
3
3
  import { filledToastIcons } from "./sonner-icons.js";
4
4
  import { useUiConfig } from "./ui-config.js";
5
5
  import "./sonner.css";
6
- import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { WhatsNewDialog } from "./whats-new-dialog.js";
7
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
7
8
  const defaultToasterClassName = "toaster group !font-sans";
8
9
  const hideStackedContentClassName = "[&[data-expanded=false][data-front=false]>*]:opacity-0";
9
10
  const hoverChipCloseButtonClassName = "pointer-events-none absolute -right-2 -top-2 z-10 flex h-6 w-6 items-center justify-center rounded-full border border-border bg-card/95 text-muted-foreground opacity-0 transition-opacity hover:border-border! hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring group-hover:pointer-events-auto group-hover:opacity-100 max-sm:pointer-events-auto max-sm:opacity-100 max-sm:hit-target";
@@ -97,7 +98,7 @@ function withConfigDefaults(defaults, props) {
97
98
  return merged;
98
99
  }
99
100
  function SonnerToaster(props) {
100
- const $ = _c(10);
101
+ const $ = _c(13);
101
102
  const {
102
103
  classes,
103
104
  position: t0,
@@ -188,7 +189,24 @@ function SonnerToaster(props) {
188
189
  } else {
189
190
  t13 = $[9];
190
191
  }
191
- return t13;
192
+ let t14;
193
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
194
+ t14 = /*#__PURE__*/_jsx(WhatsNewDialog, {});
195
+ $[10] = t14;
196
+ } else {
197
+ t14 = $[10];
198
+ }
199
+ let t15;
200
+ if ($[11] !== t13) {
201
+ t15 = /*#__PURE__*/_jsxs(_Fragment, {
202
+ children: [t13, t14]
203
+ });
204
+ $[11] = t13;
205
+ $[12] = t15;
206
+ } else {
207
+ t15 = $[12];
208
+ }
209
+ return t15;
192
210
  }
193
211
  export { SonnerToaster, createToasterClassNames, hoverChipCloseButtonClassName, mergeToastClassNames, mergeToastOptions, mergeToasterStyle, sonnerVarsStyle };
194
212
  export { filledToastIcons } from "./sonner-icons.js";
@@ -0,0 +1,142 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useSyncExternalStore } from "react";
3
+ import { closeWhatsNew, getWhatsNew, subscribeWhatsNew } from "../../app/src/update/releaseNotes.js";
4
+ import { Button } from "./button.js";
5
+ import { Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./dialog.js";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const getServerSnapshot = () => null;
8
+
9
+ /**
10
+ * The "What's new" dialog of the update toast: the changelog titles that the
11
+ * new deploy adds, with Refresh. `SonnerToaster` renders it.
12
+ */
13
+ export function WhatsNewDialog() {
14
+ const $ = _c(23);
15
+ const state = useSyncExternalStore(subscribeWhatsNew, getWhatsNew, getServerSnapshot);
16
+ let t0;
17
+ if ($[0] !== state) {
18
+ t0 = () => {
19
+ if (!state) {
20
+ return;
21
+ }
22
+ closeWhatsNew();
23
+ state.onClose();
24
+ };
25
+ $[0] = state;
26
+ $[1] = t0;
27
+ } else {
28
+ t0 = $[1];
29
+ }
30
+ const close = t0;
31
+ const t1 = state !== null;
32
+ let t2;
33
+ if ($[2] !== close) {
34
+ t2 = open => open ? undefined : close();
35
+ $[2] = close;
36
+ $[3] = t2;
37
+ } else {
38
+ t2 = $[3];
39
+ }
40
+ let t3;
41
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
42
+ t3 = /*#__PURE__*/_jsxs(DialogHeader, {
43
+ children: [/*#__PURE__*/_jsx(DialogTitle, {
44
+ children: "What's new"
45
+ }), /*#__PURE__*/_jsx(DialogDescription, {
46
+ children: "Refresh to load the latest version."
47
+ })]
48
+ });
49
+ $[4] = t3;
50
+ } else {
51
+ t3 = $[4];
52
+ }
53
+ let t4;
54
+ if ($[5] !== state?.notes) {
55
+ t4 = state?.notes.map(_temp);
56
+ $[5] = state?.notes;
57
+ $[6] = t4;
58
+ } else {
59
+ t4 = $[6];
60
+ }
61
+ let t5;
62
+ if ($[7] !== t4) {
63
+ t5 = /*#__PURE__*/_jsx(DialogBody, {
64
+ children: /*#__PURE__*/_jsx("ul", {
65
+ className: "list-disc space-y-1.5 pl-5 text-sm",
66
+ children: t4
67
+ })
68
+ });
69
+ $[7] = t4;
70
+ $[8] = t5;
71
+ } else {
72
+ t5 = $[8];
73
+ }
74
+ let t6;
75
+ if ($[9] !== close) {
76
+ t6 = /*#__PURE__*/_jsx(Button, {
77
+ variant: "outline",
78
+ onClick: close,
79
+ children: "Later"
80
+ });
81
+ $[9] = close;
82
+ $[10] = t6;
83
+ } else {
84
+ t6 = $[10];
85
+ }
86
+ let t7;
87
+ if ($[11] !== state) {
88
+ t7 = /*#__PURE__*/_jsx(Button, {
89
+ onClick: () => {
90
+ closeWhatsNew();
91
+ state?.refresh();
92
+ },
93
+ children: "Refresh"
94
+ });
95
+ $[11] = state;
96
+ $[12] = t7;
97
+ } else {
98
+ t7 = $[12];
99
+ }
100
+ let t8;
101
+ if ($[13] !== t6 || $[14] !== t7) {
102
+ t8 = /*#__PURE__*/_jsxs(DialogFooter, {
103
+ children: [t6, t7]
104
+ });
105
+ $[13] = t6;
106
+ $[14] = t7;
107
+ $[15] = t8;
108
+ } else {
109
+ t8 = $[15];
110
+ }
111
+ let t9;
112
+ if ($[16] !== t5 || $[17] !== t8) {
113
+ t9 = /*#__PURE__*/_jsxs(DialogContent, {
114
+ children: [t3, t5, t8]
115
+ });
116
+ $[16] = t5;
117
+ $[17] = t8;
118
+ $[18] = t9;
119
+ } else {
120
+ t9 = $[18];
121
+ }
122
+ let t10;
123
+ if ($[19] !== t1 || $[20] !== t2 || $[21] !== t9) {
124
+ t10 = /*#__PURE__*/_jsx(Dialog, {
125
+ open: t1,
126
+ onOpenChange: t2,
127
+ children: t9
128
+ });
129
+ $[19] = t1;
130
+ $[20] = t2;
131
+ $[21] = t9;
132
+ $[22] = t10;
133
+ } else {
134
+ t10 = $[22];
135
+ }
136
+ return t10;
137
+ }
138
+ function _temp(note) {
139
+ return /*#__PURE__*/_jsx("li", {
140
+ children: note.title
141
+ }, note.id);
142
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.85.0",
3
+ "version": "0.86.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
6
6
  "type": "module",
@@ -246,6 +246,7 @@
246
246
  "check:tokens": "node tokens/scripts/check-component-tokens.mjs",
247
247
  "build": "node scripts/build-dist.mjs && node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsrs -p tsconfig.json",
248
248
  "typecheck": "tsrs --noEmit --fast -p tsconfig.json && tsrs --noEmit --fast -p tsconfig.consumer.json && tsrs --noEmit --fast -p tsconfig.consumer-speech.json && tsrs --noEmit --fast -p tokens/tsconfig.json",
249
+ "lint": "oxlint -c .oxlintrc.json shell src app",
249
250
  "test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
250
251
  "verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
251
252
  "analyze": "node tokens/verify/analyze.mjs",
package/src/client.ts CHANGED
@@ -373,6 +373,11 @@ export { requestConfirm, shouldSkipConfirm } from "../app/src/confirm/confirmSki
373
373
  export { useRequestConfirm } from "../app/src/confirm/useRequestConfirm";
374
374
  export { ConfirmSkipHint, skipConfirmTitle } from "../app/src/confirm/ConfirmSkipHint";
375
375
  export { fetchDeployFingerprint, fingerprintFromHtml } from "../app/src/update/deployFingerprint";
376
+ export {
377
+ fetchReleaseNotes,
378
+ newReleaseNotes,
379
+ type ReleaseNote,
380
+ } from "../app/src/update/releaseNotes";
376
381
  export {
377
382
  showUpdateAvailableToast,
378
383
  startUpdateAvailableWatcher,
package/src/ui/sonner.tsx CHANGED
@@ -3,6 +3,7 @@ import { Toaster as SonnerPrimitive, type ToasterProps } from "sonner";
3
3
  import { filledToastIcons } from "./sonner-icons";
4
4
  import { useUiConfig } from "./ui-config";
5
5
  import "./sonner.css";
6
+ import { WhatsNewDialog } from "./whats-new-dialog";
6
7
 
7
8
  type ToastClassNames = NonNullable<
8
9
  NonNullable<ToasterProps["toastOptions"]>["classNames"]
@@ -178,6 +179,7 @@ function SonnerToaster(props: ToasterProps & SonnerToasterOptions) {
178
179
  ? { ...loadingOverride, ...icons }
179
180
  : icons;
180
181
  return (
182
+ <>
181
183
  <SonnerPrimitive
182
184
  expand={false}
183
185
  visibleToasts={4}
@@ -211,6 +213,8 @@ function SonnerToaster(props: ToasterProps & SonnerToasterOptions) {
211
213
  toastOptions,
212
214
  )}
213
215
  />
216
+ <WhatsNewDialog />
217
+ </>
214
218
  );
215
219
  }
216
220
 
@@ -0,0 +1,60 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import {
3
+ closeWhatsNew,
4
+ getWhatsNew,
5
+ subscribeWhatsNew,
6
+ type WhatsNewState,
7
+ } from "../../app/src/update/releaseNotes";
8
+ import { Button } from "./button";
9
+ import {
10
+ Dialog,
11
+ DialogBody,
12
+ DialogContent,
13
+ DialogDescription,
14
+ DialogFooter,
15
+ DialogHeader,
16
+ DialogTitle,
17
+ } from "./dialog";
18
+
19
+ const getServerSnapshot = (): WhatsNewState | null => null;
20
+
21
+ /**
22
+ * The "What's new" dialog of the update toast: the changelog titles that the
23
+ * new deploy adds, with Refresh. `SonnerToaster` renders it.
24
+ */
25
+ export function WhatsNewDialog() {
26
+ const state = useSyncExternalStore(subscribeWhatsNew, getWhatsNew, getServerSnapshot);
27
+ const close = (): void => {
28
+ if (!state) return;
29
+ closeWhatsNew();
30
+ state.onClose();
31
+ };
32
+ return (
33
+ <Dialog open={state !== null} onOpenChange={(open) => (open ? undefined : close())}>
34
+ <DialogContent>
35
+ <DialogHeader>
36
+ <DialogTitle>What's new</DialogTitle>
37
+ <DialogDescription>Refresh to load the latest version.</DialogDescription>
38
+ </DialogHeader>
39
+ <DialogBody>
40
+ <ul className="list-disc space-y-1.5 pl-5 text-sm">
41
+ {state?.notes.map((note) => <li key={note.id}>{note.title}</li>)}
42
+ </ul>
43
+ </DialogBody>
44
+ <DialogFooter>
45
+ <Button variant="outline" onClick={close}>
46
+ Later
47
+ </Button>
48
+ <Button
49
+ onClick={() => {
50
+ closeWhatsNew();
51
+ state?.refresh();
52
+ }}
53
+ >
54
+ Refresh
55
+ </Button>
56
+ </DialogFooter>
57
+ </DialogContent>
58
+ </Dialog>
59
+ );
60
+ }