@superwall/studio 1.3.0 → 1.5.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/README.md +2 -2
- package/dist/assets/index-Bi2YHYVJ.js +11 -0
- package/dist/assets/index-DrsTCwot.css +1 -0
- package/dist/index.html +2 -2
- package/dist/lib/components/DownloadScreenshot.d.ts +6 -0
- package/dist/lib/components/PreviewOnDevice.d.ts +6 -0
- package/dist/lib/components/Tooltip.d.ts +5 -0
- package/dist/lib/components/chrome/Toolbar.d.ts +1 -0
- package/dist/lib/components/chrome/TopBar.d.ts +1 -0
- package/dist/lib/components/icons.d.ts +1 -0
- package/dist/lib/components/menus/CompareMenu.d.ts +2 -1
- package/dist/lib/components/preview/Canvas.d.ts +18 -0
- package/dist/lib/components/preview/DeviceFrame.d.ts +4 -4
- package/dist/lib/components/preview/ResizeHandles.d.ts +13 -0
- package/dist/lib/index.d.ts +5 -1
- package/dist/lib/index.js +2924 -1229
- package/dist/lib/lib/actions.d.ts +1 -0
- package/dist/lib/lib/canvas.d.ts +27 -0
- package/dist/lib/lib/contract.d.ts +7 -1
- package/dist/lib/lib/devices.d.ts +9 -0
- package/dist/lib/lib/host.d.ts +2 -1
- package/dist/lib/lib/notify.d.ts +4 -0
- package/dist/lib/lib/presentation.d.ts +23 -0
- package/dist/lib/lib/preview.d.ts +1 -0
- package/dist/lib/lib/project.d.ts +1 -0
- package/dist/lib/lib/scheme.d.ts +11 -0
- package/dist/lib/lib/surfaces.d.ts +26 -2
- package/dist/lib/studio.css +1 -1
- package/package.json +3 -2
- package/src/components/DownloadScreenshot.tsx +133 -0
- package/src/components/OpenInApp.tsx +5 -25
- package/src/components/PaywallToasts.tsx +5 -3
- package/src/components/PreviewOnDevice.tsx +133 -0
- package/src/components/SurfaceCard.tsx +1 -1
- package/src/components/Tooltip.tsx +27 -0
- package/src/components/chrome/Toolbar.tsx +47 -6
- package/src/components/chrome/TopBar.tsx +37 -3
- package/src/components/icons.tsx +6 -0
- package/src/components/menus/ActionMenu.tsx +8 -8
- package/src/components/menus/CompareMenu.tsx +49 -30
- package/src/components/panels/MissingProducts.tsx +1 -1
- package/src/components/preview/Canvas.tsx +426 -0
- package/src/components/preview/DeviceFrame.tsx +83 -74
- package/src/components/preview/ResizeHandles.tsx +205 -0
- package/src/index.ts +6 -0
- package/src/lib/actions.ts +7 -0
- package/src/lib/canvas.ts +60 -0
- package/src/lib/contract.ts +8 -1
- package/src/lib/devices.ts +52 -4
- package/src/lib/host.ts +7 -2
- package/src/lib/notify.tsx +31 -0
- package/src/lib/presentation.ts +102 -0
- package/src/lib/preview.ts +3 -0
- package/src/lib/project.ts +45 -1
- package/src/lib/scheme.ts +31 -0
- package/src/lib/surfaces.ts +42 -1
- package/src/main.tsx +5 -1
- package/src/screens/SurfaceEditor.tsx +219 -52
- package/src/screens/SurfaceList.tsx +2 -2
- package/src/styles.css +89 -8
- package/dist/assets/index-CEz-HnIH.js +0 -11
- package/dist/assets/index-_HCp6gCi.css +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const STORAGE_KEY = "superwall-device-scheme";
|
|
2
|
+
|
|
3
|
+
export const readScheme = (): string | undefined => {
|
|
4
|
+
try {
|
|
5
|
+
return window.localStorage.getItem(STORAGE_KEY) ?? undefined;
|
|
6
|
+
} catch {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const storeScheme = (value: string) => {
|
|
12
|
+
try {
|
|
13
|
+
window.localStorage.setItem(STORAGE_KEY, value);
|
|
14
|
+
} catch {
|
|
15
|
+
/* private browsing */
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The link that points a device at this machine's `superwall dev` server.
|
|
21
|
+
*
|
|
22
|
+
* The SDK parses `superwall_dev` as the dev server base and the optional
|
|
23
|
+
* `superwall_dev_surface` as the surface to open with — see `DevServerPreview`
|
|
24
|
+
* in the iOS SDK, which refuses any base that is not loopback, `.local`, or a
|
|
25
|
+
* private-network address.
|
|
26
|
+
*/
|
|
27
|
+
export const devServerLink = (scheme: string, origin: string, surfaceId?: string): string => {
|
|
28
|
+
const surface =
|
|
29
|
+
surfaceId === undefined ? "" : `&superwall_dev_surface=${encodeURIComponent(surfaceId)}`;
|
|
30
|
+
return `${scheme}://?superwall_dev=${encodeURIComponent(origin)}${surface}`;
|
|
31
|
+
};
|
package/src/lib/surfaces.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { StudioPresentation } from "./presentation";
|
|
1
2
|
import type { SampleDefaults } from "./variables";
|
|
2
3
|
|
|
4
|
+
export type { StudioPresentation } from "./presentation";
|
|
5
|
+
|
|
3
6
|
export type {
|
|
4
7
|
AppScheme,
|
|
5
8
|
Samples,
|
|
@@ -7,6 +10,7 @@ export type {
|
|
|
7
10
|
StudioActionProgress,
|
|
8
11
|
StudioActionResult,
|
|
9
12
|
StudioStatus,
|
|
13
|
+
StudioVersion,
|
|
10
14
|
} from "./contract";
|
|
11
15
|
|
|
12
16
|
export type StudioSurfaceKind = "paywall" | "funnel";
|
|
@@ -20,16 +24,51 @@ export type StudioSurface = {
|
|
|
20
24
|
routes: string[];
|
|
21
25
|
locales: string[];
|
|
22
26
|
platforms?: string[];
|
|
27
|
+
presentation?: StudioPresentation;
|
|
23
28
|
paywallId?: string;
|
|
24
29
|
paywallIdentifier?: string;
|
|
30
|
+
origin?: StudioOrigin;
|
|
25
31
|
};
|
|
26
32
|
|
|
33
|
+
export type StudioScreenFramework =
|
|
34
|
+
| "swiftui"
|
|
35
|
+
| "uikit"
|
|
36
|
+
| "compose"
|
|
37
|
+
| "android-views"
|
|
38
|
+
| "react-native"
|
|
39
|
+
| "flutter";
|
|
40
|
+
|
|
41
|
+
export type StudioOrigin =
|
|
42
|
+
| { paywallId: string; url: string }
|
|
43
|
+
| { path: string; framework: StudioScreenFramework; screenshot?: string };
|
|
44
|
+
|
|
45
|
+
export const SCREEN_FRAMEWORK_LABEL: Record<StudioScreenFramework, string> = {
|
|
46
|
+
swiftui: "SwiftUI",
|
|
47
|
+
uikit: "UIKit",
|
|
48
|
+
compose: "Jetpack Compose",
|
|
49
|
+
"android-views": "Android Views",
|
|
50
|
+
"react-native": "React Native",
|
|
51
|
+
flutter: "Flutter",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const isScreenOrigin = (
|
|
55
|
+
origin: StudioOrigin,
|
|
56
|
+
): origin is Extract<StudioOrigin, { path: string }> => "path" in origin;
|
|
57
|
+
|
|
58
|
+
export const hasOriginal = (surface: StudioSurface): boolean =>
|
|
59
|
+
surface.origin !== undefined &&
|
|
60
|
+
(!isScreenOrigin(surface.origin) || surface.origin.screenshot !== undefined);
|
|
61
|
+
|
|
27
62
|
export type PreviewUrlBuilder = (surface: StudioSurface) => string;
|
|
28
63
|
|
|
29
|
-
export type CompareTarget =
|
|
64
|
+
export type CompareTarget =
|
|
65
|
+
| { type: "version"; version: number }
|
|
66
|
+
| { type: "surface"; surface: StudioSurface }
|
|
67
|
+
| { type: "origin" };
|
|
30
68
|
|
|
31
69
|
export type StudioSource = {
|
|
32
70
|
scheme?: string;
|
|
71
|
+
networkOrigin?: string;
|
|
33
72
|
title: string;
|
|
34
73
|
surfaces: StudioSurface[];
|
|
35
74
|
diagnostics?: string[];
|
|
@@ -37,6 +76,8 @@ export type StudioSource = {
|
|
|
37
76
|
previewUrl: PreviewUrlBuilder;
|
|
38
77
|
standaloneUrl?: PreviewUrlBuilder;
|
|
39
78
|
capabilities?: { actions: boolean };
|
|
79
|
+
previewLink?: (surface: StudioSurface) => Promise<string>;
|
|
80
|
+
screenshotUrl?: (surface: StudioSurface) => Promise<string | undefined>;
|
|
40
81
|
compareHint?: string;
|
|
41
82
|
};
|
|
42
83
|
|
package/src/main.tsx
CHANGED
|
@@ -13,7 +13,11 @@ const loadSource = async (): Promise<StudioSource> => {
|
|
|
13
13
|
throw new Error(`project data unavailable (${response.status})`);
|
|
14
14
|
}
|
|
15
15
|
const payload = parseProjectPayload(await response.json());
|
|
16
|
-
return {
|
|
16
|
+
return {
|
|
17
|
+
...payload,
|
|
18
|
+
previewUrl: buildPreviewPath,
|
|
19
|
+
standaloneUrl: (surface) => `/preview${surfacePath(surface)}`,
|
|
20
|
+
};
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
const Failure = ({ error }: { error: unknown }) => (
|
|
@@ -2,9 +2,18 @@ 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 {
|
|
6
|
+
Canvas,
|
|
7
|
+
useCanvasScale,
|
|
8
|
+
type CanvasHandle,
|
|
9
|
+
type CanvasZoom,
|
|
10
|
+
} from "../components/preview/Canvas";
|
|
5
11
|
import { DeviceFrame, DevicePlaceholder } from "../components/preview/DeviceFrame";
|
|
12
|
+
import { type FrameSize, ResizeHandles } from "../components/preview/ResizeHandles";
|
|
6
13
|
import { MissingProducts } from "../components/panels/MissingProducts";
|
|
7
14
|
import { PaywallToasts, useStudioDelegate } from "../components/PaywallToasts";
|
|
15
|
+
import { DownloadScreenshot } from "../components/DownloadScreenshot";
|
|
16
|
+
import { PreviewOnDevice } from "../components/PreviewOnDevice";
|
|
8
17
|
import { Segmented, Select, Switch } from "../components/controls";
|
|
9
18
|
import {
|
|
10
19
|
ExternalIcon,
|
|
@@ -24,25 +33,36 @@ import {
|
|
|
24
33
|
} from "../components/panels/VariablesPanel";
|
|
25
34
|
import { fetchStatus, runAction } from "../lib/actions";
|
|
26
35
|
import {
|
|
36
|
+
chromeFor,
|
|
27
37
|
DEFAULT_DEVICE_ID,
|
|
28
38
|
deviceById,
|
|
39
|
+
deviceVariablesFor,
|
|
40
|
+
isWebOnly,
|
|
41
|
+
webViewportFor,
|
|
29
42
|
RESPONSIVE_DEFAULT,
|
|
30
43
|
RESPONSIVE_ID,
|
|
31
44
|
STUDIO_DEVICES,
|
|
32
45
|
type DeviceChromeSpec,
|
|
33
46
|
} from "../lib/devices";
|
|
34
|
-
import { hostStateFor, studioDefaults } from "../lib/host";
|
|
35
|
-
import {
|
|
47
|
+
import { hostStateFor, previewDevice, studioDefaults } from "../lib/host";
|
|
48
|
+
import { percent } from "../lib/canvas";
|
|
49
|
+
import { hostedUrl, originalUrl } from "../lib/preview";
|
|
36
50
|
import { ACTION_STEPS, type StudioActionStep, type StudioStepState } from "../lib/steps";
|
|
37
51
|
import {
|
|
38
52
|
hasActions,
|
|
53
|
+
hasOriginal,
|
|
54
|
+
isScreenOrigin,
|
|
55
|
+
SCREEN_FRAMEWORK_LABEL,
|
|
39
56
|
type CompareTarget,
|
|
40
57
|
type Samples,
|
|
41
58
|
type StudioActionName,
|
|
59
|
+
type StudioPresentation,
|
|
42
60
|
type StudioSource,
|
|
43
61
|
type StudioStatus,
|
|
44
62
|
type StudioSurface,
|
|
63
|
+
type StudioVersion,
|
|
45
64
|
} from "../lib/surfaces";
|
|
65
|
+
import { timeAgo } from "../lib/time";
|
|
46
66
|
import { type VariableOverrides } from "../lib/variables";
|
|
47
67
|
|
|
48
68
|
const clampSize = (value: number, fallback: number): number =>
|
|
@@ -89,33 +109,64 @@ const StagePane = ({
|
|
|
89
109
|
height,
|
|
90
110
|
title,
|
|
91
111
|
src,
|
|
112
|
+
image,
|
|
92
113
|
hostState,
|
|
93
114
|
delegate,
|
|
94
115
|
reloadKey,
|
|
95
116
|
empty,
|
|
96
117
|
chrome,
|
|
118
|
+
presentation,
|
|
97
119
|
landscape,
|
|
98
120
|
theme,
|
|
121
|
+
onResize,
|
|
122
|
+
canvas,
|
|
99
123
|
}: {
|
|
100
124
|
label?: string;
|
|
101
125
|
width: number;
|
|
102
126
|
height: number;
|
|
103
127
|
title: string;
|
|
104
128
|
src?: string;
|
|
129
|
+
image?: string;
|
|
105
130
|
hostState: HostState;
|
|
106
131
|
delegate: HostDelegate;
|
|
107
132
|
reloadKey: number;
|
|
108
133
|
empty?: string;
|
|
109
134
|
chrome?: DeviceChromeSpec;
|
|
135
|
+
presentation?: StudioPresentation;
|
|
110
136
|
landscape?: boolean;
|
|
111
137
|
theme?: "light" | "dark";
|
|
138
|
+
onResize?: (next: FrameSize) => void;
|
|
139
|
+
canvas?: React.RefObject<CanvasHandle | null>;
|
|
112
140
|
}) => {
|
|
113
|
-
const
|
|
141
|
+
const scale = useCanvasScale();
|
|
142
|
+
const [broken, setBroken] = React.useState(false);
|
|
143
|
+
React.useEffect(() => setBroken(false), [image]);
|
|
114
144
|
return (
|
|
115
|
-
<div className="flex
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
<div className="flex flex-none flex-col gap-2">
|
|
146
|
+
{label && (
|
|
147
|
+
<span
|
|
148
|
+
className="origin-bottom-left text-xs whitespace-nowrap text-cream/55"
|
|
149
|
+
style={{ transform: `scale(${1 / scale})` }}
|
|
150
|
+
>
|
|
151
|
+
{label}
|
|
152
|
+
</span>
|
|
153
|
+
)}
|
|
154
|
+
<div className="relative">
|
|
155
|
+
{image && !broken ? (
|
|
156
|
+
<div
|
|
157
|
+
className="flex flex-none items-center justify-center overflow-hidden bg-black"
|
|
158
|
+
style={{ width, height }}
|
|
159
|
+
>
|
|
160
|
+
<img
|
|
161
|
+
src={image}
|
|
162
|
+
alt={title}
|
|
163
|
+
title={title}
|
|
164
|
+
className="max-h-full max-w-full object-contain"
|
|
165
|
+
draggable={false}
|
|
166
|
+
onError={() => setBroken(true)}
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
) : src ? (
|
|
119
170
|
<DeviceFrame
|
|
120
171
|
width={width}
|
|
121
172
|
height={height}
|
|
@@ -123,17 +174,27 @@ const StagePane = ({
|
|
|
123
174
|
src={src}
|
|
124
175
|
hostState={hostState}
|
|
125
176
|
delegate={delegate}
|
|
126
|
-
stageRef={paneRef}
|
|
127
177
|
reloadKey={reloadKey}
|
|
128
178
|
chrome={chrome}
|
|
179
|
+
presentation={presentation}
|
|
129
180
|
landscape={landscape}
|
|
130
181
|
theme={theme}
|
|
131
182
|
/>
|
|
132
183
|
) : (
|
|
133
|
-
<DevicePlaceholder width={width} height={height}
|
|
184
|
+
<DevicePlaceholder width={width} height={height}>
|
|
134
185
|
{empty ?? "Nothing live yet — publish to compare against production."}
|
|
135
186
|
</DevicePlaceholder>
|
|
136
187
|
)}
|
|
188
|
+
{onResize && (
|
|
189
|
+
<ResizeHandles
|
|
190
|
+
size={{ width, height }}
|
|
191
|
+
scale={scale}
|
|
192
|
+
clamp={clampSize}
|
|
193
|
+
onResize={onResize}
|
|
194
|
+
onDragStart={() => canvas?.current?.hold()}
|
|
195
|
+
onShift={(dx, dy) => canvas?.current?.pan(dx, dy)}
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
137
198
|
</div>
|
|
138
199
|
</div>
|
|
139
200
|
);
|
|
@@ -158,9 +219,15 @@ export const SurfaceEditor = ({
|
|
|
158
219
|
const [locale, setLocale] = React.useState<string | undefined>(undefined);
|
|
159
220
|
const [edited, setEdited] = React.useState<VariableOverrides>({});
|
|
160
221
|
const [panelOpen, setPanelOpen] = React.useState(false);
|
|
161
|
-
const [compareWith, setCompareWith] = React.useState<CompareTarget | undefined>(
|
|
222
|
+
const [compareWith, setCompareWith] = React.useState<CompareTarget | undefined>(() =>
|
|
223
|
+
hasOriginal(surface) && new URLSearchParams(window.location.search).get("compare") === "origin"
|
|
224
|
+
? { type: "origin" }
|
|
225
|
+
: undefined,
|
|
226
|
+
);
|
|
162
227
|
const [reloadKey, setReloadKey] = React.useState(0);
|
|
163
228
|
const [landscape, setLandscape] = React.useState(false);
|
|
229
|
+
const canvas = React.useRef<CanvasHandle>(null);
|
|
230
|
+
const [zoom, setZoom] = React.useState<CanvasZoom>({ scale: 1, fitted: true });
|
|
164
231
|
const [status, setStatus] = React.useState<StudioStatus>({});
|
|
165
232
|
const [progress, setProgress] = React.useState<ActionProgress | undefined>(undefined);
|
|
166
233
|
const dismissTimer = React.useRef<number | undefined>(undefined);
|
|
@@ -219,7 +286,14 @@ export const SurfaceEditor = ({
|
|
|
219
286
|
|
|
220
287
|
const responsive = deviceId === RESPONSIVE_ID;
|
|
221
288
|
const device = deviceById(deviceId);
|
|
222
|
-
const
|
|
289
|
+
const web = isWebOnly(surface.platforms);
|
|
290
|
+
const frameDevice = React.useMemo(() => deviceVariablesFor(device, web), [device, web]);
|
|
291
|
+
const upright = responsive
|
|
292
|
+
? size
|
|
293
|
+
: web
|
|
294
|
+
? webViewportFor(device)
|
|
295
|
+
: { width: device.width, height: device.height };
|
|
296
|
+
const presentation = web ? undefined : surface.presentation;
|
|
223
297
|
const frame = landscape ? { width: upright.height, height: upright.width } : upright;
|
|
224
298
|
|
|
225
299
|
const openPreview = () => {
|
|
@@ -246,54 +320,85 @@ export const SurfaceEditor = ({
|
|
|
246
320
|
defaults,
|
|
247
321
|
sourceSamples: source.samples,
|
|
248
322
|
samples,
|
|
249
|
-
frame: responsive ? undefined :
|
|
323
|
+
frame: responsive ? undefined : frameDevice,
|
|
250
324
|
theme,
|
|
251
325
|
locale,
|
|
252
326
|
edited,
|
|
253
327
|
}),
|
|
254
|
-
[surface, defaults, source.samples, samples, responsive,
|
|
328
|
+
[surface, defaults, source.samples, samples, responsive, frameDevice, theme, locale, edited],
|
|
255
329
|
);
|
|
256
|
-
const chrome = responsive ? undefined : device
|
|
330
|
+
const chrome = responsive ? undefined : chromeFor(device, web);
|
|
257
331
|
const previewSrc = source.previewUrl(surface);
|
|
258
|
-
const
|
|
332
|
+
const versions = status.versions ?? [];
|
|
333
|
+
const versionLabel = (entry: StudioVersion) => `v${entry.version}${entry.live ? " · live" : ""}`;
|
|
334
|
+
const pushedHint = (entry: StudioVersion) => {
|
|
335
|
+
if (entry.live) return "What SDKs receive today";
|
|
336
|
+
const ago = entry.pushedAt ? timeAgo(entry.pushedAt) : undefined;
|
|
337
|
+
return ago ? `Pushed ${ago}` : "Pushed snapshot";
|
|
338
|
+
};
|
|
259
339
|
|
|
260
340
|
const compareOptions: CompareOption[] = [
|
|
261
|
-
...(
|
|
341
|
+
...(surface.origin && hasOriginal(surface)
|
|
262
342
|
? [
|
|
263
343
|
{
|
|
264
|
-
key: "
|
|
265
|
-
label: "
|
|
266
|
-
hint:
|
|
267
|
-
|
|
344
|
+
key: "origin",
|
|
345
|
+
label: "Original",
|
|
346
|
+
hint: isScreenOrigin(surface.origin)
|
|
347
|
+
? `${SCREEN_FRAMEWORK_LABEL[surface.origin.framework]} screen ${surface.origin.path}, as captured in the simulator`
|
|
348
|
+
: `Dashboard paywall ${surface.origin.paywallId}, as it serves today`,
|
|
349
|
+
target: { type: "origin" } as const,
|
|
268
350
|
},
|
|
269
351
|
]
|
|
270
352
|
: []),
|
|
353
|
+
...versions.map((entry) => ({
|
|
354
|
+
key: `version:${entry.version}`,
|
|
355
|
+
label: versionLabel(entry),
|
|
356
|
+
hint: pushedHint(entry),
|
|
357
|
+
target: { type: "version", version: entry.version } as const,
|
|
358
|
+
})),
|
|
271
359
|
...source.surfaces
|
|
272
|
-
.map((candidate
|
|
273
|
-
key: `surface:${
|
|
360
|
+
.map((candidate) => ({
|
|
361
|
+
key: `surface:${candidate.kind}/${candidate.id}`,
|
|
274
362
|
label: nameOf(candidate),
|
|
275
363
|
hint: source.compareHint ?? "Local preview",
|
|
276
364
|
target: { type: "surface", surface: candidate } as const,
|
|
277
365
|
}))
|
|
278
366
|
.filter((option) => option.target.surface !== surface),
|
|
279
367
|
];
|
|
368
|
+
const compareNotice = status.unreachable
|
|
369
|
+
? `Couldn't read the pushed versions — ${status.unreachable}`
|
|
370
|
+
: undefined;
|
|
371
|
+
const compared =
|
|
372
|
+
compareWith?.type === "version"
|
|
373
|
+
? versions.find((entry) => entry.version === compareWith.version)
|
|
374
|
+
: undefined;
|
|
280
375
|
|
|
281
376
|
const comparePane =
|
|
282
377
|
compareWith &&
|
|
283
|
-
(compareWith.type === "
|
|
378
|
+
(compareWith.type === "version"
|
|
284
379
|
? {
|
|
285
|
-
label:
|
|
286
|
-
src:
|
|
287
|
-
title: `${surface.id}
|
|
288
|
-
empty:
|
|
289
|
-
? `Couldn't read the live version — ${status.unreachable}`
|
|
290
|
-
: undefined,
|
|
380
|
+
label: compared ? versionLabel(compared) : `v${compareWith.version}`,
|
|
381
|
+
src: compared ? hostedUrl(compared.url) : undefined,
|
|
382
|
+
title: `${surface.id} v${compareWith.version}`,
|
|
383
|
+
empty: compareNotice ?? "This version is no longer on the dashboard.",
|
|
291
384
|
}
|
|
292
|
-
:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
385
|
+
: compareWith.type === "origin"
|
|
386
|
+
? {
|
|
387
|
+
label: "Original",
|
|
388
|
+
...(surface.origin && isScreenOrigin(surface.origin)
|
|
389
|
+
? { image: surface.origin.screenshot ? originalUrl(surface) : undefined }
|
|
390
|
+
: { src: surface.origin?.url }),
|
|
391
|
+
title: `${surface.id} original`,
|
|
392
|
+
empty:
|
|
393
|
+
surface.origin && isScreenOrigin(surface.origin)
|
|
394
|
+
? "The original's screenshot is missing — capture it again with `superwall migrate --screen <path> --screenshot <file>`."
|
|
395
|
+
: "This paywall was not rebuilt from a dashboard paywall or a native screen.",
|
|
396
|
+
}
|
|
397
|
+
: {
|
|
398
|
+
label: nameOf(compareWith.surface),
|
|
399
|
+
src: source.previewUrl(compareWith.surface),
|
|
400
|
+
title: `${nameOf(compareWith.surface)} preview`,
|
|
401
|
+
});
|
|
297
402
|
|
|
298
403
|
const groups = React.useMemo((): VariableGroups => {
|
|
299
404
|
const rows = (prefix: string, record: Record<string, unknown> | undefined): VariableRow[] =>
|
|
@@ -303,18 +408,21 @@ export const SurfaceEditor = ({
|
|
|
303
408
|
|
|
304
409
|
return {
|
|
305
410
|
user: rows("user", { ...defaults.user, ...source.samples?.user, ...samples.user }),
|
|
306
|
-
device: rows(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
411
|
+
device: rows(
|
|
412
|
+
"device",
|
|
413
|
+
previewDevice({
|
|
414
|
+
...defaults.device,
|
|
415
|
+
...source.samples?.device,
|
|
416
|
+
...samples.device,
|
|
417
|
+
...frameDevice,
|
|
418
|
+
}),
|
|
419
|
+
),
|
|
312
420
|
params: rows("params", { ...defaults.params, ...source.samples?.params }),
|
|
313
421
|
products: Object.entries(surface.products ?? {}).flatMap(([reference, identifier]) =>
|
|
314
422
|
rows(`products.${reference}`, samples.products?.[identifier]),
|
|
315
423
|
),
|
|
316
424
|
};
|
|
317
|
-
}, [defaults, source.samples, samples,
|
|
425
|
+
}, [defaults, source.samples, samples, frameDevice, surface.products]);
|
|
318
426
|
|
|
319
427
|
const missingProducts = React.useMemo(() => {
|
|
320
428
|
if (!samples.products) return [];
|
|
@@ -345,11 +453,6 @@ export const SurfaceEditor = ({
|
|
|
345
453
|
onDismiss={() => setDismissedProducts(true)}
|
|
346
454
|
/>
|
|
347
455
|
)}
|
|
348
|
-
{unverified && (
|
|
349
|
-
<div className="border-b border-cream/10 bg-red/10 px-4 py-1.5 text-[0.8125rem] text-cream/75">
|
|
350
|
-
Couldn't check this paywall's products — {unverified}
|
|
351
|
-
</div>
|
|
352
|
-
)}
|
|
353
456
|
<TopBar
|
|
354
457
|
title={`${surface.project ?? source.title} / ${surface.id}${
|
|
355
458
|
surface.label ? ` · ${surface.label}` : ""
|
|
@@ -375,6 +478,8 @@ export const SurfaceEditor = ({
|
|
|
375
478
|
<ExternalIcon />
|
|
376
479
|
</button>
|
|
377
480
|
)}
|
|
481
|
+
<DownloadScreenshot source={source} surface={surface} />
|
|
482
|
+
<PreviewOnDevice source={source} surface={surface} />
|
|
378
483
|
{actionsEnabled && (
|
|
379
484
|
<ActionMenu
|
|
380
485
|
progress={progress}
|
|
@@ -392,16 +497,39 @@ export const SurfaceEditor = ({
|
|
|
392
497
|
</>
|
|
393
498
|
}
|
|
394
499
|
/>
|
|
500
|
+
{unverified && (
|
|
501
|
+
<div
|
|
502
|
+
role="status"
|
|
503
|
+
className="relative z-10 flex-none border-b border-cream/10 bg-[color-mix(in_srgb,var(--color-red)_10%,var(--color-ink))] px-4 py-1.5 text-[0.8125rem] text-cream/75"
|
|
504
|
+
>
|
|
505
|
+
Couldn't check this paywall's products — {unverified}
|
|
506
|
+
</div>
|
|
507
|
+
)}
|
|
395
508
|
|
|
396
|
-
<div className="flex min-h-0 flex-1">
|
|
397
|
-
<
|
|
509
|
+
<div className="relative flex min-h-0 flex-1">
|
|
510
|
+
<Canvas
|
|
511
|
+
ref={canvas}
|
|
512
|
+
onZoom={setZoom}
|
|
513
|
+
fitKey={[
|
|
514
|
+
deviceId,
|
|
515
|
+
responsive ? "" : `${frame.width}x${frame.height}`,
|
|
516
|
+
comparePane ? "compare" : "single",
|
|
517
|
+
presentation?.style ?? "",
|
|
518
|
+
].join(":")}
|
|
519
|
+
>
|
|
398
520
|
{comparePane && (
|
|
399
521
|
<StagePane
|
|
400
522
|
label={comparePane.label}
|
|
401
523
|
width={frame.width}
|
|
402
524
|
height={frame.height}
|
|
403
525
|
title={comparePane.title}
|
|
404
|
-
src={comparePane.src}
|
|
526
|
+
src={"src" in comparePane ? comparePane.src : undefined}
|
|
527
|
+
image={"image" in comparePane ? comparePane.image : undefined}
|
|
528
|
+
presentation={
|
|
529
|
+
compareWith?.type === "surface" && !web
|
|
530
|
+
? compareWith.surface.presentation
|
|
531
|
+
: presentation
|
|
532
|
+
}
|
|
405
533
|
hostState={hostState}
|
|
406
534
|
delegate={delegate}
|
|
407
535
|
reloadKey={reloadKey}
|
|
@@ -417,14 +545,21 @@ export const SurfaceEditor = ({
|
|
|
417
545
|
height={frame.height}
|
|
418
546
|
title={`${surface.id} preview`}
|
|
419
547
|
src={previewSrc}
|
|
548
|
+
presentation={presentation}
|
|
420
549
|
hostState={hostState}
|
|
421
550
|
delegate={delegate}
|
|
422
551
|
reloadKey={reloadKey}
|
|
423
552
|
chrome={chrome}
|
|
424
553
|
landscape={landscape}
|
|
425
554
|
theme={theme}
|
|
555
|
+
onResize={
|
|
556
|
+
responsive
|
|
557
|
+
? (next) => setSize(landscape ? { width: next.height, height: next.width } : next)
|
|
558
|
+
: undefined
|
|
559
|
+
}
|
|
560
|
+
canvas={canvas}
|
|
426
561
|
/>
|
|
427
|
-
</
|
|
562
|
+
</Canvas>
|
|
428
563
|
|
|
429
564
|
<SidePanel open={panelOpen} title="Variables" onClose={() => setPanelOpen(false)}>
|
|
430
565
|
<VariablesPanel overrides={edited} groups={groups} onChange={setEdited} />
|
|
@@ -467,6 +602,33 @@ export const SurfaceEditor = ({
|
|
|
467
602
|
</button>
|
|
468
603
|
</ToolbarGroup>
|
|
469
604
|
<ToolbarDivider />
|
|
605
|
+
<ToolbarGroup label="Zoom">
|
|
606
|
+
<div className="sw-stepper" role="group" aria-label="Zoom">
|
|
607
|
+
<button
|
|
608
|
+
type="button"
|
|
609
|
+
aria-label="Zoom out"
|
|
610
|
+
onClick={() => canvas.current?.zoomStep(-1)}
|
|
611
|
+
>
|
|
612
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
613
|
+
<path d="M5 12h14" />
|
|
614
|
+
</svg>
|
|
615
|
+
</button>
|
|
616
|
+
<button
|
|
617
|
+
type="button"
|
|
618
|
+
className="min-w-12 px-2 font-mono text-xs tabular-nums"
|
|
619
|
+
aria-label="Fit to view"
|
|
620
|
+
aria-pressed={zoom.fitted}
|
|
621
|
+
onClick={() => canvas.current?.fit()}
|
|
622
|
+
>
|
|
623
|
+
{percent(zoom.scale)}
|
|
624
|
+
</button>
|
|
625
|
+
<button type="button" aria-label="Zoom in" onClick={() => canvas.current?.zoomStep(1)}>
|
|
626
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
627
|
+
<path d="M12 5v14M5 12h14" />
|
|
628
|
+
</svg>
|
|
629
|
+
</button>
|
|
630
|
+
</div>
|
|
631
|
+
</ToolbarGroup>
|
|
470
632
|
<ToolbarGroup label="Device">
|
|
471
633
|
<Select
|
|
472
634
|
label="Device"
|
|
@@ -507,8 +669,13 @@ export const SurfaceEditor = ({
|
|
|
507
669
|
</ToolbarGroup>
|
|
508
670
|
)}
|
|
509
671
|
<ToolbarDivider />
|
|
510
|
-
{compareOptions.length > 0 && (
|
|
511
|
-
<CompareMenu
|
|
672
|
+
{(actionsEnabled || compareOptions.length > 0) && (
|
|
673
|
+
<CompareMenu
|
|
674
|
+
active={compareWith}
|
|
675
|
+
options={compareOptions}
|
|
676
|
+
notice={compareNotice}
|
|
677
|
+
onSelect={setCompareWith}
|
|
678
|
+
/>
|
|
512
679
|
)}
|
|
513
680
|
<button
|
|
514
681
|
type="button"
|
|
@@ -95,7 +95,7 @@ export const SurfaceList = ({
|
|
|
95
95
|
<div className="flex-1 overflow-y-auto px-3 pt-6 pb-16 sm:px-6 sm:pt-10" ref={scroller}>
|
|
96
96
|
<div className="mx-auto max-w-[1080px]">
|
|
97
97
|
{source.diagnostics && source.diagnostics.length > 0 && (
|
|
98
|
-
<div className="border-red bg-red/10 mb-6 border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap">
|
|
98
|
+
<div className="border-red bg-red/10 mb-6 rounded border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap">
|
|
99
99
|
{source.diagnostics.join("\n")}
|
|
100
100
|
</div>
|
|
101
101
|
)}
|
|
@@ -149,7 +149,7 @@ export const SurfaceList = ({
|
|
|
149
149
|
))}
|
|
150
150
|
|
|
151
151
|
{source.surfaces.length === 0 && (
|
|
152
|
-
<div className="border border-dashed border-cream/20 p-12 text-center text-cream/55">
|
|
152
|
+
<div className="rounded border border-dashed border-cream/20 p-12 text-center text-cream/55">
|
|
153
153
|
No paywalls yet — create{" "}
|
|
154
154
|
<code className="font-mono text-[0.8125rem] text-cream">
|
|
155
155
|
superwall/paywalls/<id>/app/page.tsx
|