@superwall/studio 2.6.0-beta.2 → 2.6.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.
@@ -98,6 +98,13 @@ export const CheckIcon = (props: IconProps) => (
98
98
  </Icon>
99
99
  );
100
100
 
101
+ export const CopyIcon = (props: IconProps) => (
102
+ <Icon {...props}>
103
+ <rect x="8" y="8" width="14" height="14" rx="2" />
104
+ <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
105
+ </Icon>
106
+ );
107
+
101
108
  export const ColumnsIcon = (props: IconProps) => (
102
109
  <Icon {...props}>
103
110
  <rect x="3" y="3" width="18" height="18" rx="2" />
@@ -225,3 +232,39 @@ export const SmartphoneIcon = (props: IconProps) => (
225
232
  <path d="M12 18h.01" />
226
233
  </Icon>
227
234
  );
235
+
236
+ const BrandIcon = ({ className, children }: React.PropsWithChildren<IconProps>) => (
237
+ <svg
238
+ className={className ? `sw-icon sw-icon--brand ${className}` : "sw-icon sw-icon--brand"}
239
+ viewBox="0 0 24 24"
240
+ aria-hidden="true"
241
+ >
242
+ {children}
243
+ </svg>
244
+ );
245
+
246
+ export const AppleIcon = (props: IconProps) => (
247
+ <BrandIcon {...props}>
248
+ <path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" />
249
+ </BrandIcon>
250
+ );
251
+
252
+ export const GooglePlayIcon = (props: IconProps) => (
253
+ <BrandIcon {...props}>
254
+ <path d="M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z" />
255
+ </BrandIcon>
256
+ );
257
+
258
+ export const StripeIcon = (props: IconProps) => (
259
+ <BrandIcon {...props}>
260
+ <path d="M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.594-7.305h.003z" />
261
+ </BrandIcon>
262
+ );
263
+
264
+ export const BoxIcon = (props: IconProps) => (
265
+ <Icon {...props}>
266
+ <path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" />
267
+ <path d="m3.3 7 8.7 5 8.7-5" />
268
+ <path d="M12 22V12" />
269
+ </Icon>
270
+ );
@@ -0,0 +1,272 @@
1
+ import * as React from "react";
2
+ import { InlineCode } from "../InlineCode";
3
+ import {
4
+ AlertTriangleIcon,
5
+ AppleIcon,
6
+ BoxIcon,
7
+ CartIcon,
8
+ CheckIcon,
9
+ CopyIcon,
10
+ GooglePlayIcon,
11
+ StripeIcon,
12
+ type IconComponent,
13
+ } from "../icons";
14
+ import { MenuPopup, useDismiss, usePopupAlign } from "./Menu";
15
+ import { productSummary } from "../../lib/products";
16
+ import type { ProductListing, ProductStore, Samples } from "../../lib/contract";
17
+
18
+ type SlotState =
19
+ | { kind: "ok"; variables: Record<string, unknown> }
20
+ | { kind: "missing" }
21
+ | { kind: "unchecked" }
22
+ | { kind: "loading" };
23
+
24
+ const slotState = (identifier: string, samples: Samples, pending: boolean): SlotState => {
25
+ if (samples.unreachable) return { kind: "unchecked" };
26
+ if (!samples.products) return { kind: pending ? "loading" : "unchecked" };
27
+ const variables = samples.products[identifier];
28
+ return variables === undefined ? { kind: "missing" } : { kind: "ok", variables };
29
+ };
30
+
31
+ const STORES: Record<ProductStore, { label: string; icon: IconComponent }> = {
32
+ "app-store": { label: "App Store", icon: AppleIcon },
33
+ "play-store": { label: "Google Play", icon: GooglePlayIcon },
34
+ stripe: { label: "Stripe", icon: StripeIcon },
35
+ custom: { label: "Custom", icon: BoxIcon },
36
+ };
37
+
38
+ const storesOf = (listing: ProductListing | undefined) =>
39
+ (listing?.stores ?? []).flatMap((store) => (Object.hasOwn(STORES, store) ? [STORES[store]] : []));
40
+
41
+ const StoreTile = ({
42
+ state,
43
+ listing,
44
+ }: {
45
+ state: SlotState;
46
+ listing: ProductListing | undefined;
47
+ }) => {
48
+ const [store] = storesOf(listing);
49
+ const Mark = state.kind === "missing" ? AlertTriangleIcon : (store?.icon ?? CartIcon);
50
+ return (
51
+ <span
52
+ className={`flex size-8 shrink-0 items-center justify-center rounded-sm border ${
53
+ state.kind === "missing"
54
+ ? "border-destructive/40 text-destructive-foreground"
55
+ : "border-border bg-muted text-fg-secondary"
56
+ }`}
57
+ >
58
+ <Mark />
59
+ </span>
60
+ );
61
+ };
62
+
63
+ const Price = ({ state }: { state: SlotState }) => {
64
+ if (state.kind !== "ok") return null;
65
+ const summary = productSummary(state.variables);
66
+ return (
67
+ <div className="flex shrink-0 flex-col items-end">
68
+ {summary.price ? (
69
+ <span className="text-sm/5 font-medium tabular-nums">{summary.price}</span>
70
+ ) : (
71
+ <span className="text-sm/5 text-fg-tertiary">No price in Superwall</span>
72
+ )}
73
+ {summary.trial && <span className="text-xs/4 text-fg-secondary">{summary.trial}</span>}
74
+ </div>
75
+ );
76
+ };
77
+
78
+ const STATUS: Record<Exclude<SlotState["kind"], "ok">, { text: string; tone: string }> = {
79
+ loading: { text: "Checking…", tone: "text-fg-tertiary" },
80
+ missing: { text: "Not in Superwall", tone: "text-destructive-foreground" },
81
+ unchecked: { text: "Couldn’t check", tone: "text-warning-foreground" },
82
+ };
83
+
84
+ const Identifier = ({
85
+ value,
86
+ label,
87
+ className,
88
+ children,
89
+ }: {
90
+ value: string;
91
+ label: string;
92
+ className: string;
93
+ children?: React.ReactNode;
94
+ }) => {
95
+ const [copied, setCopied] = React.useState(false);
96
+ React.useEffect(() => {
97
+ if (!copied) return;
98
+ const timer = setTimeout(() => setCopied(false), 1500);
99
+ return () => clearTimeout(timer);
100
+ }, [copied]);
101
+
102
+ return (
103
+ <>
104
+ <button
105
+ type="button"
106
+ className={`peer/id min-w-0 cursor-pointer truncate border-0 bg-transparent p-0 font-mono hover:text-foreground ${className}`}
107
+ aria-label={copied ? `Copied ${label}: ${value}` : `Copy ${label}: ${value}`}
108
+ title={value}
109
+ onClick={() => {
110
+ navigator.clipboard?.writeText(value).then(
111
+ () => setCopied(true),
112
+ () => setCopied(false),
113
+ );
114
+ }}
115
+ >
116
+ {value}
117
+ </button>
118
+ {children}
119
+ {copied ? (
120
+ <CheckIcon className="size-3 shrink-0 text-success" />
121
+ ) : (
122
+ <CopyIcon className="size-3 shrink-0 opacity-0 peer-hover/id:opacity-100 peer-focus-visible/id:opacity-100" />
123
+ )}
124
+ </>
125
+ );
126
+ };
127
+
128
+ const Slot = ({
129
+ reference,
130
+ identifier,
131
+ state,
132
+ listing,
133
+ }: {
134
+ reference: string;
135
+ identifier: string;
136
+ state: SlotState;
137
+ listing: ProductListing | undefined;
138
+ }) => {
139
+ const stores = storesOf(listing)
140
+ .map((store) => store.label)
141
+ .join(" + ");
142
+ const name = listing?.name && listing.name !== identifier ? listing.name : undefined;
143
+ const status = state.kind === "ok" ? undefined : STATUS[state.kind];
144
+ const copy = `${reference} identifier`;
145
+ const badge = (
146
+ <span className="sw-chip h-4.5 shrink-0 font-mono text-[0.6875rem] font-normal text-fg-secondary">
147
+ {reference}
148
+ </span>
149
+ );
150
+
151
+ return (
152
+ <section aria-label={reference} className="flex items-center gap-3 px-3 py-2">
153
+ <StoreTile state={state} listing={listing} />
154
+ <div className="flex min-w-0 flex-1 flex-col">
155
+ <div className="flex min-w-0 items-center gap-1.5 text-sm/5">
156
+ {name ? (
157
+ <>
158
+ <span className="truncate font-medium">{name}</span>
159
+ {badge}
160
+ </>
161
+ ) : (
162
+ <Identifier value={identifier} label={copy} className="text-[0.8125rem]/5">
163
+ {badge}
164
+ </Identifier>
165
+ )}
166
+ </div>
167
+ <div className="flex min-w-0 items-center gap-1.5 text-xs/4 text-fg-tertiary">
168
+ {status && <span className={`shrink-0 ${status.tone}`}>{status.text}</span>}
169
+ {stores && <span className="shrink-0">{stores}</span>}
170
+ {stores && name && <span aria-hidden="true">·</span>}
171
+ {name && <Identifier value={identifier} label={copy} className="text-xs" />}
172
+ </div>
173
+ </div>
174
+ <Price state={state} />
175
+ </section>
176
+ );
177
+ };
178
+
179
+ export const ProductsMenu = ({
180
+ products,
181
+ samples,
182
+ pending = false,
183
+ }: {
184
+ products: Record<string, string> | undefined;
185
+ samples: Samples;
186
+ pending?: boolean;
187
+ }) => {
188
+ const [open, setOpen] = React.useState(false);
189
+ const menuRef = React.useRef<HTMLDivElement>(null);
190
+ const popupRef = React.useRef<HTMLDivElement>(null);
191
+ const dismissRefs = React.useMemo(() => [menuRef, popupRef], []);
192
+ useDismiss(dismissRefs, open, () => setOpen(false));
193
+ const align = usePopupAlign(menuRef, open);
194
+
195
+ const slots = Object.entries(products ?? {}).map(([reference, identifier]) => ({
196
+ reference,
197
+ identifier,
198
+ state: slotState(identifier, samples, pending),
199
+ }));
200
+ const missing = slots.filter((slot) => slot.state.kind === "missing").length;
201
+ const flagged = slots.length > 0 && (Boolean(samples.unreachable) || missing > 0);
202
+ const label = flagged
203
+ ? samples.unreachable
204
+ ? "Products, couldn’t check"
205
+ : `Products, ${missing} missing`
206
+ : slots.length > 0
207
+ ? `Products, ${slots.length}`
208
+ : "Products";
209
+
210
+ return (
211
+ <div className="relative flex" ref={menuRef}>
212
+ <button
213
+ type="button"
214
+ className="sw-btn"
215
+ aria-expanded={open}
216
+ aria-haspopup="dialog"
217
+ aria-label={label}
218
+ onClick={() => setOpen((value) => !value)}
219
+ >
220
+ <CartIcon />
221
+ Products
222
+ {flagged ? (
223
+ <AlertTriangleIcon className="text-warning" />
224
+ ) : (
225
+ slots.length > 0 && <span className="text-fg-tertiary tabular-nums">{slots.length}</span>
226
+ )}
227
+ </button>
228
+
229
+ {open && (
230
+ <MenuPopup popupRef={popupRef} anchor={menuRef} side="top" align={align} className="w-104">
231
+ <div role="dialog" aria-label="Products" className="flex min-h-0 flex-col">
232
+ {slots.length > 0 && !samples.unreachable && !samples.products && !pending && (
233
+ <p
234
+ role="status"
235
+ className="m-0 border-b border-border px-3 py-2 text-xs text-fg-tertiary"
236
+ >
237
+ No product catalog to check these against.
238
+ </p>
239
+ )}
240
+ {slots.length === 0 ? (
241
+ <p className="m-0 px-3 py-3 text-sm text-fg-secondary">
242
+ This paywall sells nothing yet.
243
+ </p>
244
+ ) : (
245
+ <div className="flex max-h-96 scroll-fade flex-col divide-y divide-border overflow-y-auto">
246
+ {slots.map((slot) => (
247
+ <Slot
248
+ key={slot.reference}
249
+ {...slot}
250
+ listing={samples.catalog?.[slot.identifier]}
251
+ />
252
+ ))}
253
+ </div>
254
+ )}
255
+ <p className="m-0 border-t border-border px-3 py-2.5 text-xs text-fg-tertiary">
256
+ {slots.length === 0 ? (
257
+ <>
258
+ Add <InlineCode>{`products: { primary: "pro_year" }`}</InlineCode> to{" "}
259
+ <InlineCode>config.ts</InlineCode>.
260
+ </>
261
+ ) : (
262
+ <>
263
+ Products change in <InlineCode>config.ts</InlineCode>. Push and promote to ship.
264
+ </>
265
+ )}
266
+ </p>
267
+ </div>
268
+ </MenuPopup>
269
+ )}
270
+ </div>
271
+ );
272
+ };
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export { StudioShell } from "./components/chrome/StudioShell";
10
10
  export { DownloadScreenshot } from "./components/DownloadScreenshot";
11
11
  export { PreviewOnDevice } from "./components/PreviewOnDevice";
12
12
  export { Tooltip } from "./components/Tooltip";
13
+ export { UpdateBanner, updatePrompt } from "./components/UpdateBanner";
13
14
  export { TopBar } from "./components/chrome/TopBar";
14
15
  export { VariablesPanel } from "./components/panels/VariablesPanel";
15
16
  export { Segmented, Select, Switch } from "./components/controls";
@@ -62,6 +63,8 @@ export { parseProjectPayload, type StudioProjectPayload } from "./lib/project";
62
63
  export type {
63
64
  AppScheme,
64
65
  PreviewUrlBuilder,
66
+ ProductListing,
67
+ ProductStore,
65
68
  Samples,
66
69
  StudioActionName,
67
70
  StudioActionProgress,
@@ -77,4 +80,5 @@ export type {
77
80
  StudioSurfaceKind,
78
81
  StudioVersion,
79
82
  } from "./lib/surfaces";
83
+ export type { StudioUpdate, StudioUpdateKind } from "./lib/contract";
80
84
  export type { SampleDefaults, VariableOverrides } from "./lib/variables";
@@ -24,10 +24,18 @@ export type StudioStatus = {
24
24
  unreachable?: string;
25
25
  };
26
26
 
27
+ export type ProductStore = "app-store" | "play-store" | "stripe" | "custom";
28
+
29
+ export type ProductListing = {
30
+ name?: string;
31
+ stores?: readonly ProductStore[];
32
+ };
33
+
27
34
  export type Samples = {
28
35
  device?: Record<string, unknown>;
29
36
  user?: Record<string, unknown>;
30
37
  products?: Record<string, Record<string, unknown>>;
38
+ catalog?: Record<string, ProductListing>;
31
39
  live?: { device: boolean; user: boolean };
32
40
  unreachable?: string;
33
41
  };
@@ -42,3 +50,13 @@ export type StudioScreenshot = {
42
50
  label: string;
43
51
  url: string;
44
52
  };
53
+
54
+ export type StudioUpdateKind = "patch" | "minor" | "major";
55
+
56
+ export type StudioUpdate = {
57
+ current: string;
58
+ latest: string;
59
+ kind: StudioUpdateKind;
60
+ command: string;
61
+ notes: string;
62
+ };
@@ -38,8 +38,6 @@ const SYMBOLS: Record<string, string> = {
38
38
  ZAR: "R",
39
39
  };
40
40
 
41
- const MINOR = 100;
42
-
43
41
  const PER_YEAR: Record<string, number> = { day: 365, week: 52, month: 12, year: 1 };
44
42
 
45
43
  const symbolFor = (currency: string): string => SYMBOLS[currency.toUpperCase()] ?? "";
@@ -52,6 +50,44 @@ const money = (amount: number, currency: string): string => {
52
50
  }
53
51
  };
54
52
 
53
+ const fractionDigits = (currency: string): number => {
54
+ try {
55
+ const parts = new Intl.NumberFormat("en-US", { style: "currency", currency }).formatToParts(0);
56
+ return parts.find((part) => part.type === "fraction")?.value.length ?? 0;
57
+ } catch {
58
+ return 2;
59
+ }
60
+ };
61
+
62
+ const majorUnits = (amount: number, currency: string): number =>
63
+ amount / 10 ** fractionDigits(currency);
64
+
65
+ const trialVariables = (
66
+ product: DashboardProduct,
67
+ currency: string,
68
+ days: number,
69
+ ): Record<string, unknown> | undefined => {
70
+ const trialPrice = product.trial_price;
71
+ const amount = trialPrice?.amount ?? 0;
72
+ if (amount !== 0 && trialPrice?.currency?.toUpperCase() !== currency) return undefined;
73
+
74
+ const raw = majorUnits(amount, currency);
75
+ const yearly = (raw * 365) / days;
76
+ return {
77
+ trialPeriodDays: days,
78
+ trialPeriodWeeks: Math.floor(days / 7),
79
+ trialPeriodMonths: Math.floor(days / 30),
80
+ trialPeriodYears: Math.floor(days / 365),
81
+ trialPeriodText: `${days}-day`,
82
+ rawTrialPeriodPrice: raw,
83
+ trialPeriodPrice: money(raw, currency),
84
+ trialPeriodDailyPrice: money(raw / days, currency),
85
+ trialPeriodWeeklyPrice: money(yearly / 52, currency),
86
+ trialPeriodMonthlyPrice: money(yearly / 12, currency),
87
+ trialPeriodYearlyPrice: money(yearly, currency),
88
+ };
89
+ };
90
+
55
91
  const PERIODLY: Record<string, string> = {
56
92
  day: "daily",
57
93
  week: "weekly",
@@ -95,7 +131,7 @@ export const productVariables = (product: DashboardProduct): Record<string, unkn
95
131
  if (!price || typeof price.amount !== "number" || !price.currency) return variables;
96
132
 
97
133
  const currency = price.currency.toUpperCase();
98
- const value = price.amount / MINOR;
134
+ const value = majorUnits(price.amount, currency);
99
135
  variables.price = money(value, currency);
100
136
  variables.rawPrice = value;
101
137
  variables.currencyCode = currency;
@@ -116,9 +152,39 @@ export const productVariables = (product: DashboardProduct): Record<string, unkn
116
152
 
117
153
  const trialDays = product.subscription?.trial_period_days;
118
154
  if (typeof trialDays === "number" && trialDays > 0) {
119
- variables.trialPeriodDays = trialDays;
120
- variables.trialPeriodText = `${trialDays}-day`;
155
+ Object.assign(variables, trialVariables(product, currency, trialDays) ?? {});
121
156
  }
122
157
 
123
158
  return variables;
124
159
  };
160
+
161
+ export interface ProductSummary {
162
+ price?: string;
163
+ trial?: string;
164
+ }
165
+
166
+ const text = (value: unknown): string | undefined =>
167
+ typeof value === "string" && value !== "" ? value : undefined;
168
+
169
+ const count = (value: unknown): number | undefined =>
170
+ typeof value === "number" && Number.isFinite(value) ? value : undefined;
171
+
172
+ export const productSummary = (variables: Record<string, unknown>): ProductSummary => {
173
+ const price = text(variables.price);
174
+ if (!price) return {};
175
+
176
+ const period = text(variables.period);
177
+ const trialDays = count(variables.trialPeriodDays);
178
+ const trialPrice = text(variables.trialPeriodPrice);
179
+ const trial =
180
+ trialDays === undefined || trialDays <= 0
181
+ ? undefined
182
+ : count(variables.rawTrialPeriodPrice) === 0 || !trialPrice
183
+ ? `${trialDays}-day free trial`
184
+ : `${trialDays}-day trial for ${trialPrice}`;
185
+
186
+ return {
187
+ price: period ? `${price} / ${period}` : price,
188
+ ...(trial ? { trial } : {}),
189
+ };
190
+ };
@@ -1,3 +1,4 @@
1
+ import type { StudioUpdate } from "./contract";
1
2
  import { parsePresentation } from "./presentation";
2
3
  import type {
3
4
  StudioAppIdentity,
@@ -17,6 +18,7 @@ export type StudioProjectPayload = {
17
18
  samples: SampleDefaults;
18
19
  diagnostics: string[];
19
20
  capabilities: { actions: boolean };
21
+ update?: StudioUpdate;
20
22
  };
21
23
 
22
24
  const isStringRecord = (value: unknown): value is Record<string, string> =>
@@ -92,6 +94,24 @@ const parseOrigin = (value: unknown): StudioOrigin | undefined => {
92
94
  return undefined;
93
95
  };
94
96
 
97
+ const UPDATE_KINDS: ReadonlySet<string> = new Set(["patch", "minor", "major"]);
98
+
99
+ const parseUpdate = (value: unknown): StudioUpdate | undefined => {
100
+ if (!isRecord(value)) return undefined;
101
+ const { current, latest, kind, command, notes } = value;
102
+ if (
103
+ typeof current !== "string" ||
104
+ typeof latest !== "string" ||
105
+ typeof command !== "string" ||
106
+ typeof notes !== "string" ||
107
+ typeof kind !== "string" ||
108
+ !UPDATE_KINDS.has(kind)
109
+ ) {
110
+ return undefined;
111
+ }
112
+ return { current, latest, kind: kind as StudioUpdate["kind"], command, notes };
113
+ };
114
+
95
115
  export const parseProjectPayload = (data: unknown): StudioProjectPayload => {
96
116
  if (!isRecord(data)) {
97
117
  throw new Error("project payload is not an object");
@@ -104,6 +124,7 @@ export const parseProjectPayload = (data: unknown): StudioProjectPayload => {
104
124
  const group = (key: string): Record<string, unknown> =>
105
125
  isRecord(samples[key]) ? (samples[key] as Record<string, unknown>) : {};
106
126
  const app = parseApp(data.app);
127
+ const update = parseUpdate(data.update);
107
128
  return {
108
129
  title: typeof data.title === "string" ? data.title : "superwall",
109
130
  ...(app === undefined ? {} : { app }),
@@ -117,5 +138,6 @@ export const parseProjectPayload = (data: unknown): StudioProjectPayload => {
117
138
  params: group("params"),
118
139
  },
119
140
  capabilities: { actions: capabilities.actions === true },
141
+ ...(update === undefined ? {} : { update }),
120
142
  };
121
143
  };
@@ -5,6 +5,7 @@ import type {
5
5
  StudioActionResult,
6
6
  StudioScreenshot,
7
7
  StudioStatus,
8
+ StudioUpdate,
8
9
  } from "./contract";
9
10
  import type { StudioPresentation } from "./presentation";
10
11
  import type { SampleDefaults } from "./variables";
@@ -13,6 +14,8 @@ export type { StudioPresentation } from "./presentation";
13
14
 
14
15
  export type {
15
16
  AppScheme,
17
+ ProductListing,
18
+ ProductStore,
16
19
  Samples,
17
20
  StudioActionName,
18
21
  StudioActionProgress,
@@ -107,6 +110,7 @@ export type StudioSource = {
107
110
  previewLink?: (surface: StudioSurface) => Promise<string>;
108
111
  screenshots?: (surface: StudioSurface) => Promise<StudioScreenshot[] | undefined>;
109
112
  compareHint?: string;
113
+ update?: StudioUpdate;
110
114
  };
111
115
 
112
116
  export const hasActions = (source: StudioSource): boolean => source.actions !== undefined;
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import { hasIntroductoryOffer, type HostDelegate, type HostState } from "@superwall/host";
3
3
  import { ActionMenu, type ActionProgress } from "../components/menus/ActionMenu";
4
4
  import { CompareMenu, type CompareOption } from "../components/menus/CompareMenu";
5
+ import { ProductsMenu } from "../components/menus/ProductsMenu";
5
6
  import {
6
7
  Canvas,
7
8
  useCanvasScale,
@@ -30,6 +31,7 @@ import { Tooltip } from "../components/Tooltip";
30
31
  import { SidePanel } from "../components/panels/SidePanel";
31
32
  import { Toolbar, ToolbarDivider, ToolbarGroup } from "../components/chrome/Toolbar";
32
33
  import { TopBar } from "../components/chrome/TopBar";
34
+ import { UpdateBanner } from "../components/UpdateBanner";
33
35
  import {
34
36
  VariablesPanel,
35
37
  type VariableGroups,
@@ -239,11 +241,13 @@ export const SurfaceEditor = ({
239
241
  source,
240
242
  surface,
241
243
  samples,
244
+ samplesPending = false,
242
245
  actions,
243
246
  }: {
244
247
  source: StudioSource;
245
248
  surface: StudioSurface;
246
249
  samples: Samples;
250
+ samplesPending?: boolean;
247
251
  actions?: React.ReactNode;
248
252
  }) => {
249
253
  const [deviceId, setDeviceId] = React.useState(DEFAULT_DEVICE_ID);
@@ -577,6 +581,7 @@ export const SurfaceEditor = ({
577
581
  </>
578
582
  }
579
583
  />
584
+ <UpdateBanner update={source.update} />
580
585
  {unverified && (
581
586
  <div
582
587
  role="status"
@@ -780,6 +785,7 @@ export const SurfaceEditor = ({
780
785
  onSelect={setCompareWith}
781
786
  />
782
787
  )}
788
+ <ProductsMenu products={surface.products} samples={samples} pending={samplesPending} />
783
789
  <button
784
790
  type="button"
785
791
  className="sw-btn"
@@ -5,6 +5,7 @@ import { InlineCode } from "../components/InlineCode";
5
5
  import { OpenInApp } from "../components/OpenInApp";
6
6
  import { SurfaceCard } from "../components/SurfaceCard";
7
7
  import { TopBar } from "../components/chrome/TopBar";
8
+ import { UpdateBanner } from "../components/UpdateBanner";
8
9
  import { type StudioSource, type StudioStatus, type StudioSurface } from "../lib/surfaces";
9
10
  import { hostStateFor, studioDefaults } from "../lib/host";
10
11
  import { surfacePath } from "../lib/preview";
@@ -90,6 +91,7 @@ export const SurfaceList = ({
90
91
  device ? <OpenInApp origin={window.location.origin} scheme={source.scheme} /> : undefined
91
92
  }
92
93
  />
94
+ <UpdateBanner update={source.update} />
93
95
 
94
96
  <div className="flex-1 overflow-y-auto" ref={scroller}>
95
97
  <div className="mx-auto flex w-full max-w-[1440px] flex-col gap-6 p-3 sm:p-6 lg:p-10">
package/src/styles.css CHANGED
@@ -236,6 +236,11 @@
236
236
  stroke-linejoin: round;
237
237
  }
238
238
 
239
+ .sw-icon--brand {
240
+ stroke: none;
241
+ fill: currentColor;
242
+ }
243
+
239
244
  .sw-spinner {
240
245
  flex: none;
241
246
  width: 14px;