@superwall/studio 1.2.0 → 1.3.0-beta.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.
- package/README.md +27 -14
- package/dist/assets/index-DyLb5fiB.js +11 -0
- package/dist/index.html +1 -1
- package/dist/lib/StudioApp.d.ts +2 -3
- package/dist/lib/components/PaywallToasts.d.ts +3 -0
- package/dist/lib/components/SurfaceCard.d.ts +4 -2
- package/dist/lib/components/icons.d.ts +0 -2
- package/dist/lib/components/{ActionMenu.d.ts → menus/ActionMenu.d.ts} +2 -1
- package/dist/lib/components/{CompareMenu.d.ts → menus/CompareMenu.d.ts} +1 -1
- package/dist/lib/components/{VariablesPanel.d.ts → panels/VariablesPanel.d.ts} +3 -3
- package/dist/lib/components/{DeviceChrome.d.ts → preview/DeviceChrome.d.ts} +1 -1
- package/dist/lib/components/{DeviceFrame.d.ts → preview/DeviceFrame.d.ts} +5 -2
- package/dist/lib/components/preview/HostedIframe.d.ts +7 -0
- package/dist/lib/index.d.ts +12 -6
- package/dist/lib/index.js +1467 -945
- package/dist/lib/lib/actions.d.ts +1 -1
- package/dist/lib/lib/contract.d.ts +33 -0
- package/dist/lib/lib/devices.d.ts +1 -1
- package/dist/lib/lib/host.d.ts +15 -0
- package/dist/lib/lib/notices.d.ts +9 -0
- package/dist/lib/lib/preview.d.ts +2 -4
- package/dist/lib/lib/project.d.ts +2 -1
- package/dist/lib/lib/steps.d.ts +5 -0
- package/dist/lib/lib/surfaces.d.ts +35 -0
- package/dist/lib/lib/variables.d.ts +12 -0
- package/dist/lib/products.js +26 -12
- package/dist/lib/screens/SurfaceEditor.d.ts +1 -1
- package/dist/lib/screens/SurfaceList.d.ts +1 -1
- package/package.json +5 -1
- package/src/StudioApp.tsx +6 -10
- package/src/components/PaywallToasts.tsx +162 -86
- package/src/components/SurfaceCard.tsx +9 -2
- package/src/components/icons.tsx +0 -13
- package/src/components/{ActionMenu.tsx → menus/ActionMenu.tsx} +3 -3
- package/src/components/{CompareMenu.tsx → menus/CompareMenu.tsx} +2 -2
- package/src/components/{SidePanel.tsx → panels/SidePanel.tsx} +1 -1
- package/src/components/{VariablesPanel.tsx → panels/VariablesPanel.tsx} +4 -4
- package/src/components/{DeviceChrome.tsx → preview/DeviceChrome.tsx} +1 -1
- package/src/components/{DeviceFrame.tsx → preview/DeviceFrame.tsx} +14 -55
- package/src/components/preview/HostedIframe.tsx +46 -0
- package/src/index.ts +24 -12
- package/src/lib/actions.ts +1 -1
- package/src/lib/contract.ts +30 -0
- package/src/lib/devices.ts +5 -4
- package/src/lib/host.ts +80 -0
- package/src/lib/notices.ts +63 -0
- package/src/lib/preview.ts +8 -40
- package/src/lib/products.ts +20 -1
- package/src/lib/project.ts +2 -1
- package/src/lib/steps.ts +20 -0
- package/src/lib/surfaces.ts +41 -0
- package/src/lib/time.ts +1 -2
- package/src/lib/variables.ts +13 -0
- package/src/main.tsx +3 -3
- package/src/screens/SurfaceEditor.tsx +77 -66
- package/src/screens/SurfaceList.tsx +17 -7
- package/src/vite-env.d.ts +1 -0
- package/dist/assets/index-CVKQ82YR.js +0 -11
- package/dist/lib/lib/events.d.ts +0 -27
- package/dist/lib/lib/types.d.ts +0 -77
- package/src/lib/events.ts +0 -86
- package/src/lib/types.ts +0 -87
- /package/dist/lib/components/{StudioShell.d.ts → chrome/StudioShell.d.ts} +0 -0
- /package/dist/lib/components/{Toolbar.d.ts → chrome/Toolbar.d.ts} +0 -0
- /package/dist/lib/components/{TopBar.d.ts → chrome/TopBar.d.ts} +0 -0
- /package/dist/lib/components/{MissingProducts.d.ts → panels/MissingProducts.d.ts} +0 -0
- /package/dist/lib/components/{SidePanel.d.ts → panels/SidePanel.d.ts} +0 -0
- /package/src/components/{StudioShell.tsx → chrome/StudioShell.tsx} +0 -0
- /package/src/components/{Toolbar.tsx → chrome/Toolbar.tsx} +0 -0
- /package/src/components/{TopBar.tsx → chrome/TopBar.tsx} +0 -0
- /package/src/components/{MissingProducts.tsx → panels/MissingProducts.tsx} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SampleDefaults } from "./variables";
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
AppScheme,
|
|
5
|
+
Samples,
|
|
6
|
+
StudioActionName,
|
|
7
|
+
StudioActionProgress,
|
|
8
|
+
StudioActionResult,
|
|
9
|
+
StudioStatus,
|
|
10
|
+
} from "./contract";
|
|
11
|
+
|
|
12
|
+
export type StudioSurfaceKind = "paywall" | "funnel";
|
|
13
|
+
|
|
14
|
+
export type StudioSurface = {
|
|
15
|
+
kind: StudioSurfaceKind;
|
|
16
|
+
id: string;
|
|
17
|
+
project?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
products?: Record<string, string>;
|
|
20
|
+
routes: string[];
|
|
21
|
+
locales: string[];
|
|
22
|
+
platforms?: string[];
|
|
23
|
+
paywallId?: string;
|
|
24
|
+
paywallIdentifier?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type PreviewUrlBuilder = (surface: StudioSurface) => string;
|
|
28
|
+
|
|
29
|
+
export type CompareTarget = { type: "live" } | { type: "surface"; surface: StudioSurface };
|
|
30
|
+
|
|
31
|
+
export type StudioSource = {
|
|
32
|
+
scheme?: string;
|
|
33
|
+
title: string;
|
|
34
|
+
surfaces: StudioSurface[];
|
|
35
|
+
diagnostics?: string[];
|
|
36
|
+
samples?: SampleDefaults;
|
|
37
|
+
previewUrl: PreviewUrlBuilder;
|
|
38
|
+
standaloneUrl?: PreviewUrlBuilder;
|
|
39
|
+
capabilities?: { actions: boolean };
|
|
40
|
+
compareHint?: string;
|
|
41
|
+
};
|
package/src/lib/time.ts
CHANGED
|
@@ -5,7 +5,6 @@ const UNITS: [number, Intl.RelativeTimeFormatUnit][] = [
|
|
|
5
5
|
[7, "day"],
|
|
6
6
|
[4.348, "week"],
|
|
7
7
|
[12, "month"],
|
|
8
|
-
[Number.POSITIVE_INFINITY, "year"],
|
|
9
8
|
];
|
|
10
9
|
|
|
11
10
|
export const timeAgo = (iso: string, now = Date.now()): string | undefined => {
|
|
@@ -17,5 +16,5 @@ export const timeAgo = (iso: string, now = Date.now()): string | undefined => {
|
|
|
17
16
|
if (value < factor) return formatter.format(-Math.round(value), unit);
|
|
18
17
|
value /= factor;
|
|
19
18
|
}
|
|
20
|
-
return
|
|
19
|
+
return formatter.format(-Math.round(value), "year");
|
|
21
20
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SampleDefaults = {
|
|
2
|
+
device: Record<string, unknown>;
|
|
3
|
+
user: Record<string, unknown>;
|
|
4
|
+
params: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type VariableOverrides = {
|
|
8
|
+
device?: Record<string, unknown>;
|
|
9
|
+
user?: Record<string, unknown>;
|
|
10
|
+
params?: Record<string, unknown>;
|
|
11
|
+
products?: Record<string, Record<string, unknown>>;
|
|
12
|
+
introductoryOfferEligible?: boolean;
|
|
13
|
+
};
|
package/src/main.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
|
-
import { buildPreviewPath } from "./lib/preview";
|
|
3
|
+
import { buildPreviewPath, surfacePath } from "./lib/preview";
|
|
4
4
|
import { parseProjectPayload } from "./lib/project";
|
|
5
5
|
import { StudioApp } from "./StudioApp";
|
|
6
6
|
import "./styles.css";
|
|
7
|
-
import type { StudioSource } from "./lib/
|
|
7
|
+
import type { StudioSource } from "./lib/surfaces";
|
|
8
8
|
|
|
9
9
|
const loadSource = async (): Promise<StudioSource> => {
|
|
10
10
|
const response = await fetch("/__studio/project.json");
|
|
@@ -12,7 +12,7 @@ const loadSource = async (): Promise<StudioSource> => {
|
|
|
12
12
|
throw new Error(`project data unavailable (${response.status})`);
|
|
13
13
|
}
|
|
14
14
|
const payload = parseProjectPayload(await response.json());
|
|
15
|
-
return { ...payload, previewUrl: buildPreviewPath };
|
|
15
|
+
return { ...payload, previewUrl: buildPreviewPath, standaloneUrl: surfacePath };
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const Failure = ({ error }: { error: unknown }) => (
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { hasIntroductoryOffer, type HostDelegate, type HostState } from "@superwall/host";
|
|
3
|
+
import { ActionMenu, type ActionProgress } from "../components/menus/ActionMenu";
|
|
4
|
+
import { CompareMenu, type CompareOption } from "../components/menus/CompareMenu";
|
|
5
|
+
import { DeviceFrame, DevicePlaceholder } from "../components/preview/DeviceFrame";
|
|
6
|
+
import { MissingProducts } from "../components/panels/MissingProducts";
|
|
7
|
+
import { PaywallToasts, useStudioDelegate } from "../components/PaywallToasts";
|
|
7
8
|
import { Segmented, Select, Switch } from "../components/controls";
|
|
8
9
|
import {
|
|
9
10
|
ExternalIcon,
|
|
@@ -13,16 +14,15 @@ import {
|
|
|
13
14
|
SlidersIcon,
|
|
14
15
|
SunIcon,
|
|
15
16
|
} from "../components/icons";
|
|
16
|
-
import { SidePanel } from "../components/SidePanel";
|
|
17
|
-
import { Toolbar, ToolbarDivider, ToolbarGroup } from "../components/Toolbar";
|
|
18
|
-
import { TopBar } from "../components/TopBar";
|
|
17
|
+
import { SidePanel } from "../components/panels/SidePanel";
|
|
18
|
+
import { Toolbar, ToolbarDivider, ToolbarGroup } from "../components/chrome/Toolbar";
|
|
19
|
+
import { TopBar } from "../components/chrome/TopBar";
|
|
19
20
|
import {
|
|
20
21
|
VariablesPanel,
|
|
21
22
|
type VariableGroups,
|
|
22
23
|
type VariableRow,
|
|
23
|
-
} from "../components/VariablesPanel";
|
|
24
|
+
} from "../components/panels/VariablesPanel";
|
|
24
25
|
import { fetchStatus, runAction } from "../lib/actions";
|
|
25
|
-
import { localesAnnounced } from "../lib/events";
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_DEVICE_ID,
|
|
28
28
|
deviceById,
|
|
@@ -31,19 +31,18 @@ import {
|
|
|
31
31
|
STUDIO_DEVICES,
|
|
32
32
|
type DeviceChromeSpec,
|
|
33
33
|
} from "../lib/devices";
|
|
34
|
-
import {
|
|
34
|
+
import { hostStateFor, studioDefaults } from "../lib/host";
|
|
35
|
+
import { hostedUrl } from "../lib/preview";
|
|
36
|
+
import { ACTION_STEPS, type StudioActionStep, type StudioStepState } from "../lib/steps";
|
|
35
37
|
import {
|
|
36
|
-
ACTION_STEPS,
|
|
37
38
|
type CompareTarget,
|
|
38
|
-
type PreviewOverrides,
|
|
39
|
-
type StudioActionName,
|
|
40
|
-
type StudioActionStep,
|
|
41
39
|
type Samples,
|
|
40
|
+
type StudioActionName,
|
|
42
41
|
type StudioSource,
|
|
43
42
|
type StudioStatus,
|
|
44
|
-
type StudioStepState,
|
|
45
43
|
type StudioSurface,
|
|
46
|
-
} from "../lib/
|
|
44
|
+
} from "../lib/surfaces";
|
|
45
|
+
import { type VariableOverrides } from "../lib/variables";
|
|
47
46
|
|
|
48
47
|
const clampSize = (value: number, fallback: number): number =>
|
|
49
48
|
Number.isFinite(value) ? Math.min(3000, Math.max(200, Math.round(value))) : fallback;
|
|
@@ -89,6 +88,8 @@ const StagePane = ({
|
|
|
89
88
|
height,
|
|
90
89
|
title,
|
|
91
90
|
src,
|
|
91
|
+
hostState,
|
|
92
|
+
delegate,
|
|
92
93
|
reloadKey,
|
|
93
94
|
empty,
|
|
94
95
|
chrome,
|
|
@@ -100,6 +101,8 @@ const StagePane = ({
|
|
|
100
101
|
height: number;
|
|
101
102
|
title: string;
|
|
102
103
|
src?: string;
|
|
104
|
+
hostState: HostState;
|
|
105
|
+
delegate: HostDelegate;
|
|
103
106
|
reloadKey: number;
|
|
104
107
|
empty?: string;
|
|
105
108
|
chrome?: DeviceChromeSpec;
|
|
@@ -117,6 +120,8 @@ const StagePane = ({
|
|
|
117
120
|
height={height}
|
|
118
121
|
title={title}
|
|
119
122
|
src={src}
|
|
123
|
+
hostState={hostState}
|
|
124
|
+
delegate={delegate}
|
|
120
125
|
stageRef={paneRef}
|
|
121
126
|
reloadKey={reloadKey}
|
|
122
127
|
chrome={chrome}
|
|
@@ -152,7 +157,7 @@ export const SurfaceEditor = ({
|
|
|
152
157
|
const [size, setSize] = React.useState(RESPONSIVE_DEFAULT);
|
|
153
158
|
const [theme, setTheme] = React.useState<"light" | "dark">("light");
|
|
154
159
|
const [locale, setLocale] = React.useState<string | undefined>(undefined);
|
|
155
|
-
const [edited, setEdited] = React.useState<
|
|
160
|
+
const [edited, setEdited] = React.useState<VariableOverrides>({});
|
|
156
161
|
const [panelOpen, setPanelOpen] = React.useState(false);
|
|
157
162
|
const [compareWith, setCompareWith] = React.useState<CompareTarget | undefined>(undefined);
|
|
158
163
|
const [reloadKey, setReloadKey] = React.useState(0);
|
|
@@ -163,17 +168,10 @@ export const SurfaceEditor = ({
|
|
|
163
168
|
React.useEffect(() => () => window.clearTimeout(dismissTimer.current), []);
|
|
164
169
|
|
|
165
170
|
const actionsEnabled = source.capabilities?.actions === true;
|
|
171
|
+
const delegate = useStudioDelegate();
|
|
172
|
+
const defaults = React.useMemo(studioDefaults, [surface]);
|
|
166
173
|
|
|
167
|
-
const
|
|
168
|
-
React.useEffect(() => {
|
|
169
|
-
const onMessage = (event: MessageEvent) => {
|
|
170
|
-
const locales = localesAnnounced(event.data);
|
|
171
|
-
if (locales) setAnnounced(locales);
|
|
172
|
-
};
|
|
173
|
-
window.addEventListener("message", onMessage);
|
|
174
|
-
return () => window.removeEventListener("message", onMessage);
|
|
175
|
-
}, []);
|
|
176
|
-
const locales = surface.locales.length > 0 ? surface.locales : announced;
|
|
174
|
+
const locales = surface.locales;
|
|
177
175
|
|
|
178
176
|
React.useEffect(() => {
|
|
179
177
|
if (!actionsEnabled) return;
|
|
@@ -220,41 +218,45 @@ export const SurfaceEditor = ({
|
|
|
220
218
|
}
|
|
221
219
|
};
|
|
222
220
|
|
|
221
|
+
const responsive = deviceId === RESPONSIVE_ID;
|
|
222
|
+
const device = deviceById(deviceId);
|
|
223
|
+
const upright = responsive ? size : { width: device.width, height: device.height };
|
|
224
|
+
const frame = landscape ? { width: upright.height, height: upright.width } : upright;
|
|
225
|
+
|
|
223
226
|
const openPreview = () => {
|
|
227
|
+
const standalone = source.standaloneUrl?.(surface);
|
|
228
|
+
if (standalone === undefined) return;
|
|
224
229
|
if (frame.width > 768) {
|
|
225
|
-
window.open(
|
|
230
|
+
window.open(standalone, "_blank");
|
|
226
231
|
return;
|
|
227
232
|
}
|
|
228
233
|
const left = Math.max(0, window.screen.width / 2 - frame.width / 2);
|
|
229
234
|
const top = Math.max(0, window.screen.height / 2 - frame.height / 2);
|
|
230
235
|
const popup = window.open(
|
|
231
|
-
|
|
236
|
+
standalone,
|
|
232
237
|
"superwall-preview",
|
|
233
238
|
`toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=${frame.width},height=${frame.height},top=${top},left=${left}`,
|
|
234
239
|
);
|
|
235
|
-
if (!popup) window.open(
|
|
240
|
+
if (!popup) window.open(standalone, "_blank");
|
|
236
241
|
};
|
|
237
242
|
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
device
|
|
251
|
-
|
|
252
|
-
...edited.device,
|
|
253
|
-
},
|
|
254
|
-
};
|
|
243
|
+
const hostState = React.useMemo(
|
|
244
|
+
() =>
|
|
245
|
+
hostStateFor({
|
|
246
|
+
surface,
|
|
247
|
+
defaults,
|
|
248
|
+
sourceSamples: source.samples,
|
|
249
|
+
samples,
|
|
250
|
+
frame: responsive ? undefined : device.device,
|
|
251
|
+
theme,
|
|
252
|
+
locale,
|
|
253
|
+
edited,
|
|
254
|
+
}),
|
|
255
|
+
[surface, defaults, source.samples, samples, responsive, device.device, theme, locale, edited],
|
|
256
|
+
);
|
|
255
257
|
const chrome = responsive ? undefined : device.chrome;
|
|
256
|
-
const previewSrc = source.previewUrl(surface
|
|
257
|
-
const liveSrc = status.liveUrl ?
|
|
258
|
+
const previewSrc = source.previewUrl(surface);
|
|
259
|
+
const liveSrc = status.liveUrl ? hostedUrl(status.liveUrl) : undefined;
|
|
258
260
|
|
|
259
261
|
const compareOptions: CompareOption[] = [
|
|
260
262
|
...(actionsEnabled
|
|
@@ -290,7 +292,7 @@ export const SurfaceEditor = ({
|
|
|
290
292
|
}
|
|
291
293
|
: {
|
|
292
294
|
label: nameOf(compareWith.surface),
|
|
293
|
-
src: source.previewUrl(compareWith.surface
|
|
295
|
+
src: source.previewUrl(compareWith.surface),
|
|
294
296
|
title: `${nameOf(compareWith.surface)} preview`,
|
|
295
297
|
});
|
|
296
298
|
|
|
@@ -301,18 +303,19 @@ export const SurfaceEditor = ({
|
|
|
301
303
|
.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
302
304
|
|
|
303
305
|
return {
|
|
304
|
-
user: rows("user", { ...source.samples?.user, ...samples.user }),
|
|
306
|
+
user: rows("user", { ...defaults.user, ...source.samples?.user, ...samples.user }),
|
|
305
307
|
device: rows("device", {
|
|
308
|
+
...defaults.device,
|
|
306
309
|
...source.samples?.device,
|
|
307
310
|
...samples.device,
|
|
308
311
|
...(device.device as Record<string, unknown>),
|
|
309
312
|
}),
|
|
310
|
-
params: rows("params", source.samples?.params),
|
|
313
|
+
params: rows("params", { ...defaults.params, ...source.samples?.params }),
|
|
311
314
|
products: Object.entries(surface.products ?? {}).flatMap(([reference, identifier]) =>
|
|
312
315
|
rows(`products.${reference}`, samples.products?.[identifier]),
|
|
313
316
|
),
|
|
314
317
|
};
|
|
315
|
-
}, [source.samples, samples, device.device, surface.products]);
|
|
318
|
+
}, [defaults, source.samples, samples, device.device, surface.products]);
|
|
316
319
|
|
|
317
320
|
const missingProducts = React.useMemo(() => {
|
|
318
321
|
if (!samples.products) return [];
|
|
@@ -364,14 +367,16 @@ export const SurfaceEditor = ({
|
|
|
364
367
|
>
|
|
365
368
|
<RotateIcon />
|
|
366
369
|
</button>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
{source.standaloneUrl && (
|
|
371
|
+
<button
|
|
372
|
+
type="button"
|
|
373
|
+
className="sw-btn sw-btn--icon"
|
|
374
|
+
aria-label="Open preview"
|
|
375
|
+
onClick={openPreview}
|
|
376
|
+
>
|
|
377
|
+
<ExternalIcon />
|
|
378
|
+
</button>
|
|
379
|
+
)}
|
|
375
380
|
{actionsEnabled && (
|
|
376
381
|
<ActionMenu
|
|
377
382
|
progress={progress}
|
|
@@ -399,6 +404,8 @@ export const SurfaceEditor = ({
|
|
|
399
404
|
height={frame.height}
|
|
400
405
|
title={comparePane.title}
|
|
401
406
|
src={comparePane.src}
|
|
407
|
+
hostState={hostState}
|
|
408
|
+
delegate={delegate}
|
|
402
409
|
reloadKey={reloadKey}
|
|
403
410
|
empty={"empty" in comparePane ? comparePane.empty : undefined}
|
|
404
411
|
chrome={chrome}
|
|
@@ -412,6 +419,8 @@ export const SurfaceEditor = ({
|
|
|
412
419
|
height={frame.height}
|
|
413
420
|
title={`${surface.id} preview`}
|
|
414
421
|
src={previewSrc}
|
|
422
|
+
hostState={hostState}
|
|
423
|
+
delegate={delegate}
|
|
415
424
|
reloadKey={reloadKey}
|
|
416
425
|
chrome={chrome}
|
|
417
426
|
landscape={landscape}
|
|
@@ -425,11 +434,13 @@ export const SurfaceEditor = ({
|
|
|
425
434
|
</div>
|
|
426
435
|
|
|
427
436
|
<Toolbar>
|
|
428
|
-
<ToolbarGroup label="
|
|
437
|
+
<ToolbarGroup label="Intro offer">
|
|
429
438
|
<Switch
|
|
430
|
-
label="
|
|
431
|
-
checked={
|
|
432
|
-
onChange={(checked) =>
|
|
439
|
+
label="Introductory offer"
|
|
440
|
+
checked={hasIntroductoryOffer(hostState)}
|
|
441
|
+
onChange={(checked) =>
|
|
442
|
+
setEdited((current) => ({ ...current, introductoryOfferEligible: checked }))
|
|
443
|
+
}
|
|
433
444
|
/>
|
|
434
445
|
</ToolbarGroup>
|
|
435
446
|
<ToolbarGroup label="Theme">
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { OpenInApp } from "../components/OpenInApp";
|
|
3
3
|
import { SurfaceCard } from "../components/SurfaceCard";
|
|
4
|
-
import { TopBar } from "../components/TopBar";
|
|
4
|
+
import { TopBar } from "../components/chrome/TopBar";
|
|
5
5
|
import { fetchStatus } from "../lib/actions";
|
|
6
|
-
import type { StudioSource, StudioStatus, StudioSurface } from "../lib/
|
|
7
|
-
import {
|
|
6
|
+
import type { StudioSource, StudioStatus, StudioSurface } from "../lib/surfaces";
|
|
7
|
+
import { hostStateFor, studioDefaults } from "../lib/host";
|
|
8
|
+
import { surfacePath } from "../lib/preview";
|
|
8
9
|
|
|
9
10
|
let lastScroll = 0;
|
|
10
11
|
|
|
@@ -18,6 +19,7 @@ export const SurfaceList = ({
|
|
|
18
19
|
device?: boolean;
|
|
19
20
|
}) => {
|
|
20
21
|
const [statuses, setStatuses] = React.useState<Record<string, StudioStatus>>({});
|
|
22
|
+
const defaults = React.useMemo(studioDefaults, [source]);
|
|
21
23
|
|
|
22
24
|
React.useEffect(() => {
|
|
23
25
|
if (source.capabilities?.actions !== true) return;
|
|
@@ -119,9 +121,17 @@ export const SurfaceList = ({
|
|
|
119
121
|
key={surfacePath(surface)}
|
|
120
122
|
surface={surface}
|
|
121
123
|
status={statuses[surfacePath(surface)]}
|
|
122
|
-
previewSrc={source.previewUrl(surface
|
|
124
|
+
previewSrc={source.previewUrl(surface)}
|
|
125
|
+
hostState={hostStateFor({
|
|
126
|
+
surface,
|
|
127
|
+
defaults,
|
|
128
|
+
sourceSamples: source.samples,
|
|
129
|
+
samples: {},
|
|
130
|
+
theme: "light",
|
|
131
|
+
edited: {},
|
|
132
|
+
})}
|
|
123
133
|
onOpen={() => onOpen(surface)}
|
|
124
|
-
href={device ?
|
|
134
|
+
href={device ? surfacePath(surface) : undefined}
|
|
125
135
|
/>
|
|
126
136
|
))}
|
|
127
137
|
</div>
|
|
@@ -147,8 +157,8 @@ export const SurfaceList = ({
|
|
|
147
157
|
|
|
148
158
|
{!device && (
|
|
149
159
|
<footer className="bg-bar flex h-11 flex-none items-center justify-center border-t border-cream/10 text-xs text-cream/55">
|
|
150
|
-
Previews run against
|
|
151
|
-
live.
|
|
160
|
+
Previews run against a real SDK host — you choose the outcomes. Edit files under
|
|
161
|
+
superwall/ and they update live.
|
|
152
162
|
</footer>
|
|
153
163
|
)}
|
|
154
164
|
</>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|