@superwall/studio 1.1.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/LICENSE +105 -0
- package/README.md +78 -0
- package/dist/assets/index-CVKGrx00.js +11 -0
- package/dist/assets/index-D4RIpSbg.css +1 -0
- package/dist/icon.svg +5 -0
- package/dist/index.html +23 -0
- package/package.json +66 -0
- package/src/StudioApp.tsx +78 -0
- package/src/components/ActionMenu.tsx +174 -0
- package/src/components/CompareMenu.tsx +147 -0
- package/src/components/DeviceChrome.tsx +124 -0
- package/src/components/DeviceFrame.tsx +210 -0
- package/src/components/MissingProducts.tsx +46 -0
- package/src/components/OpenInApp.tsx +68 -0
- package/src/components/PaywallToasts.tsx +208 -0
- package/src/components/SidePanel.tsx +36 -0
- package/src/components/SurfaceCard.tsx +93 -0
- package/src/components/Toolbar.tsx +16 -0
- package/src/components/TopBar.tsx +41 -0
- package/src/components/VariablesPanel.tsx +200 -0
- package/src/components/controls.tsx +70 -0
- package/src/components/icons.tsx +139 -0
- package/src/index.ts +20 -0
- package/src/lib/actions.ts +79 -0
- package/src/lib/devices.ts +109 -0
- package/src/lib/events.ts +77 -0
- package/src/lib/preview.ts +39 -0
- package/src/lib/project.ts +64 -0
- package/src/lib/time.ts +21 -0
- package/src/lib/types.ts +85 -0
- package/src/main.tsx +49 -0
- package/src/screens/SurfaceEditor.tsx +498 -0
- package/src/screens/SurfaceList.tsx +156 -0
- package/src/styles.css +221 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export type DeviceChromeSpec = {
|
|
2
|
+
radius: number;
|
|
3
|
+
cutout?: "island" | "punch";
|
|
4
|
+
statusBarHeight: number;
|
|
5
|
+
homeIndicator: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type StudioDevice = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
device?: {
|
|
14
|
+
platform: "iOS" | "Android";
|
|
15
|
+
deviceModel: string;
|
|
16
|
+
osVersion: string;
|
|
17
|
+
};
|
|
18
|
+
chrome?: DeviceChromeSpec;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const IPHONE_ISLAND: DeviceChromeSpec = {
|
|
22
|
+
radius: 54,
|
|
23
|
+
cutout: "island",
|
|
24
|
+
statusBarHeight: 64,
|
|
25
|
+
homeIndicator: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const STUDIO_DEVICES: readonly StudioDevice[] = [
|
|
29
|
+
{
|
|
30
|
+
id: "iphone-se",
|
|
31
|
+
name: "iPhone SE",
|
|
32
|
+
width: 375,
|
|
33
|
+
height: 667,
|
|
34
|
+
device: { platform: "iOS", deviceModel: "iPhone14,6", osVersion: "26.0" },
|
|
35
|
+
chrome: { radius: 0, statusBarHeight: 20, homeIndicator: false },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "iphone-17",
|
|
39
|
+
name: "iPhone 17",
|
|
40
|
+
width: 402,
|
|
41
|
+
height: 874,
|
|
42
|
+
device: { platform: "iOS", deviceModel: "iPhone18,3", osVersion: "26.0" },
|
|
43
|
+
chrome: IPHONE_ISLAND,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "iphone-air",
|
|
47
|
+
name: "iPhone Air",
|
|
48
|
+
width: 420,
|
|
49
|
+
height: 912,
|
|
50
|
+
device: { platform: "iOS", deviceModel: "iPhone18,4", osVersion: "26.0" },
|
|
51
|
+
chrome: IPHONE_ISLAND,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "iphone-17-pro-max",
|
|
55
|
+
name: "iPhone 17 Pro Max",
|
|
56
|
+
width: 440,
|
|
57
|
+
height: 956,
|
|
58
|
+
device: { platform: "iOS", deviceModel: "iPhone18,2", osVersion: "26.0" },
|
|
59
|
+
chrome: IPHONE_ISLAND,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "pixel-10",
|
|
63
|
+
name: "Pixel 10",
|
|
64
|
+
width: 412,
|
|
65
|
+
height: 915,
|
|
66
|
+
device: { platform: "Android", deviceModel: "Pixel 10", osVersion: "16" },
|
|
67
|
+
chrome: { radius: 28, cutout: "punch", statusBarHeight: 48, homeIndicator: true },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "galaxy-s25",
|
|
71
|
+
name: "Galaxy S25",
|
|
72
|
+
width: 360,
|
|
73
|
+
height: 780,
|
|
74
|
+
device: { platform: "Android", deviceModel: "SM-S931B", osVersion: "15" },
|
|
75
|
+
chrome: { radius: 26, cutout: "punch", statusBarHeight: 40, homeIndicator: true },
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "ipad-mini",
|
|
79
|
+
name: "iPad mini",
|
|
80
|
+
width: 744,
|
|
81
|
+
height: 1133,
|
|
82
|
+
device: { platform: "iOS", deviceModel: "iPad14,1", osVersion: "26.0" },
|
|
83
|
+
chrome: { radius: 21, statusBarHeight: 24, homeIndicator: true },
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "ipad-pro-11",
|
|
87
|
+
name: "iPad Pro 11″",
|
|
88
|
+
width: 834,
|
|
89
|
+
height: 1194,
|
|
90
|
+
device: { platform: "iOS", deviceModel: "iPad16,3", osVersion: "26.0" },
|
|
91
|
+
chrome: { radius: 18, statusBarHeight: 24, homeIndicator: true },
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "desktop",
|
|
95
|
+
name: "Desktop",
|
|
96
|
+
width: 1440,
|
|
97
|
+
height: 900,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
export const DEFAULT_DEVICE_ID = "iphone-17";
|
|
102
|
+
|
|
103
|
+
export const RESPONSIVE_ID = "responsive";
|
|
104
|
+
export const RESPONSIVE_DEFAULT = { width: 393, height: 852 };
|
|
105
|
+
|
|
106
|
+
export const deviceById = (id: string): StudioDevice =>
|
|
107
|
+
STUDIO_DEVICES.find((device) => device.id === id) ??
|
|
108
|
+
STUDIO_DEVICES.find((device) => device.id === DEFAULT_DEVICE_ID) ??
|
|
109
|
+
STUDIO_DEVICES[0];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const STUDIO_CHANNEL = "superwall-studio";
|
|
2
|
+
|
|
3
|
+
export type PaywallEvent = { event_name: string } & Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
export type BridgeMessage =
|
|
6
|
+
| { channel: typeof STUDIO_CHANNEL; type: "event"; message: PaywallEvent }
|
|
7
|
+
| {
|
|
8
|
+
channel: typeof STUDIO_CHANNEL;
|
|
9
|
+
type: "ask";
|
|
10
|
+
id: string;
|
|
11
|
+
kind: "purchase" | "permission" | "callback";
|
|
12
|
+
subject: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type EventNotice = {
|
|
16
|
+
action: string;
|
|
17
|
+
subject?: string;
|
|
18
|
+
tone: "info" | "success" | "warning";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const SILENT = new Set([
|
|
22
|
+
"ping",
|
|
23
|
+
"page_view",
|
|
24
|
+
"page_styles",
|
|
25
|
+
"has_set_dom",
|
|
26
|
+
"haptic_feedback",
|
|
27
|
+
"var_click",
|
|
28
|
+
"template_variables",
|
|
29
|
+
"template_substitutions_prefix",
|
|
30
|
+
"products",
|
|
31
|
+
"paywall_open",
|
|
32
|
+
"experiment",
|
|
33
|
+
"purchase",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
const SUBJECT: Record<string, readonly string[]> = {
|
|
37
|
+
open_url: ["url"],
|
|
38
|
+
open_url_external: ["url"],
|
|
39
|
+
open_deep_link: ["link", "url"],
|
|
40
|
+
custom_placement: ["name", "placementName"],
|
|
41
|
+
custom: ["name", "data"],
|
|
42
|
+
request_permission: ["permissionType"],
|
|
43
|
+
request_callback: ["name"],
|
|
44
|
+
schedule_notification: ["title"],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const WARNING = new Set(["close", "transaction_abandon", "transaction_fail"]);
|
|
48
|
+
|
|
49
|
+
const SUCCESS = new Set(["transaction_complete", "freeTrial_start"]);
|
|
50
|
+
|
|
51
|
+
const subjectOf = (event: PaywallEvent): string | undefined => {
|
|
52
|
+
for (const key of SUBJECT[event.event_name] ?? []) {
|
|
53
|
+
const value = event[key];
|
|
54
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const noticeFor = (event: PaywallEvent): EventNotice | undefined => {
|
|
60
|
+
if (SILENT.has(event.event_name)) return undefined;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
action: event.event_name,
|
|
64
|
+
subject: subjectOf(event),
|
|
65
|
+
tone: WARNING.has(event.event_name)
|
|
66
|
+
? "warning"
|
|
67
|
+
: SUCCESS.has(event.event_name)
|
|
68
|
+
? "success"
|
|
69
|
+
: "info",
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const isBridgeMessage = (data: unknown): data is BridgeMessage =>
|
|
74
|
+
typeof data === "object" &&
|
|
75
|
+
data !== null &&
|
|
76
|
+
Reflect.get(data, "channel") === STUDIO_CHANNEL &&
|
|
77
|
+
(Reflect.get(data, "type") === "event" || Reflect.get(data, "type") === "ask");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PreviewOverrides, PreviewUrlBuilder, StudioSurface } from "./types";
|
|
2
|
+
|
|
3
|
+
const overrideParams = (overrides: PreviewOverrides): URLSearchParams => {
|
|
4
|
+
const params = new URLSearchParams();
|
|
5
|
+
if (overrides.theme) params.set("theme", overrides.theme);
|
|
6
|
+
if (overrides.locale) params.set("locale", overrides.locale);
|
|
7
|
+
for (const [key, group] of [
|
|
8
|
+
["sw_device", overrides.device],
|
|
9
|
+
["sw_user", overrides.user],
|
|
10
|
+
["sw_params", overrides.params],
|
|
11
|
+
["sw_products", overrides.products],
|
|
12
|
+
] as const) {
|
|
13
|
+
if (group && Object.keys(group).length > 0) params.set(key, JSON.stringify(group));
|
|
14
|
+
}
|
|
15
|
+
if (overrides.trialEligible !== undefined) {
|
|
16
|
+
params.set("sw_trial", overrides.trialEligible ? "1" : "0");
|
|
17
|
+
}
|
|
18
|
+
return params;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const surfacePath = (surface: StudioSurface): string =>
|
|
22
|
+
`${surface.project ? `/${surface.project}` : ""}/${surface.kind}/${surface.id}`;
|
|
23
|
+
|
|
24
|
+
export const devicePreviewPath = (surface: StudioSurface): string =>
|
|
25
|
+
`/preview${surfacePath(surface)}?sw_preview=1`;
|
|
26
|
+
|
|
27
|
+
export const buildPreviewPath: PreviewUrlBuilder = (
|
|
28
|
+
surface: StudioSurface,
|
|
29
|
+
overrides: PreviewOverrides,
|
|
30
|
+
): string => {
|
|
31
|
+
const query = overrideParams(overrides).toString();
|
|
32
|
+
return `/preview${surfacePath(surface)}${query ? `?${query}` : ""}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const withOverrides = (url: string, overrides: PreviewOverrides): string => {
|
|
36
|
+
const query = overrideParams(overrides).toString();
|
|
37
|
+
if (!query) return url;
|
|
38
|
+
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
39
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SampleDefaults, StudioSurface, StudioSurfaceKind } from "./types";
|
|
2
|
+
|
|
3
|
+
export type StudioProjectPayload = {
|
|
4
|
+
title: string;
|
|
5
|
+
scheme?: string;
|
|
6
|
+
surfaces: StudioSurface[];
|
|
7
|
+
samples: SampleDefaults;
|
|
8
|
+
diagnostics: string[];
|
|
9
|
+
capabilities: { actions: boolean };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const isStringRecord = (value: unknown): value is Record<string, string> =>
|
|
13
|
+
typeof value === "object" &&
|
|
14
|
+
value !== null &&
|
|
15
|
+
!Array.isArray(value) &&
|
|
16
|
+
Object.values(value).every((entry) => typeof entry === "string");
|
|
17
|
+
|
|
18
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
19
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
|
|
21
|
+
const isStringArray = (value: unknown): value is string[] =>
|
|
22
|
+
Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
23
|
+
|
|
24
|
+
const parseSurface = (value: unknown): StudioSurface | undefined => {
|
|
25
|
+
if (!isRecord(value)) return undefined;
|
|
26
|
+
const kind: StudioSurfaceKind | undefined =
|
|
27
|
+
value.kind === "paywall" || value.kind === "funnel" ? value.kind : undefined;
|
|
28
|
+
if (!kind || typeof value.id !== "string") return undefined;
|
|
29
|
+
return {
|
|
30
|
+
kind,
|
|
31
|
+
id: value.id,
|
|
32
|
+
...(typeof value.project === "string" ? { project: value.project } : {}),
|
|
33
|
+
routes: isStringArray(value.routes) ? value.routes : [],
|
|
34
|
+
products: isStringRecord(value.products) ? value.products : {},
|
|
35
|
+
locales: isStringArray(value.locales) ? value.locales : [],
|
|
36
|
+
...(isStringArray(value.platforms) ? { platforms: value.platforms } : {}),
|
|
37
|
+
paywallId: typeof value.paywallId === "string" ? value.paywallId : undefined,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const parseProjectPayload = (data: unknown): StudioProjectPayload => {
|
|
42
|
+
if (!isRecord(data)) {
|
|
43
|
+
throw new Error("project payload is not an object");
|
|
44
|
+
}
|
|
45
|
+
const surfaces = Array.isArray(data.surfaces)
|
|
46
|
+
? data.surfaces.map(parseSurface).filter((surface) => surface !== undefined)
|
|
47
|
+
: [];
|
|
48
|
+
const capabilities = isRecord(data.capabilities) ? data.capabilities : {};
|
|
49
|
+
const samples = isRecord(data.samples) ? data.samples : {};
|
|
50
|
+
const group = (key: string): Record<string, unknown> =>
|
|
51
|
+
isRecord(samples[key]) ? (samples[key] as Record<string, unknown>) : {};
|
|
52
|
+
return {
|
|
53
|
+
title: typeof data.title === "string" ? data.title : "superwall",
|
|
54
|
+
scheme: typeof data.scheme === "string" ? data.scheme : undefined,
|
|
55
|
+
surfaces,
|
|
56
|
+
diagnostics: isStringArray(data.diagnostics) ? data.diagnostics : [],
|
|
57
|
+
samples: {
|
|
58
|
+
device: group("device"),
|
|
59
|
+
user: group("user"),
|
|
60
|
+
params: group("params"),
|
|
61
|
+
},
|
|
62
|
+
capabilities: { actions: capabilities.actions === true },
|
|
63
|
+
};
|
|
64
|
+
};
|
package/src/lib/time.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const UNITS: [number, Intl.RelativeTimeFormatUnit][] = [
|
|
2
|
+
[60, "second"],
|
|
3
|
+
[60, "minute"],
|
|
4
|
+
[24, "hour"],
|
|
5
|
+
[7, "day"],
|
|
6
|
+
[4.348, "week"],
|
|
7
|
+
[12, "month"],
|
|
8
|
+
[Number.POSITIVE_INFINITY, "year"],
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const timeAgo = (iso: string, now = Date.now()): string | undefined => {
|
|
12
|
+
const then = Date.parse(iso);
|
|
13
|
+
if (Number.isNaN(then)) return undefined;
|
|
14
|
+
let value = Math.max(0, (now - then) / 1000);
|
|
15
|
+
const formatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
16
|
+
for (const [factor, unit] of UNITS) {
|
|
17
|
+
if (value < factor) return formatter.format(-Math.round(value), unit);
|
|
18
|
+
value /= factor;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export type StudioSurfaceKind = "paywall" | "funnel";
|
|
2
|
+
|
|
3
|
+
export type StudioSurface = {
|
|
4
|
+
kind: StudioSurfaceKind;
|
|
5
|
+
id: string;
|
|
6
|
+
project?: string;
|
|
7
|
+
products?: Record<string, string>;
|
|
8
|
+
routes: string[];
|
|
9
|
+
locales: string[];
|
|
10
|
+
platforms?: string[];
|
|
11
|
+
paywallId?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SampleDefaults = {
|
|
15
|
+
device: Record<string, unknown>;
|
|
16
|
+
user: Record<string, unknown>;
|
|
17
|
+
params: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type PreviewOverrides = {
|
|
21
|
+
theme?: "light" | "dark";
|
|
22
|
+
locale?: string;
|
|
23
|
+
device?: Record<string, unknown>;
|
|
24
|
+
user?: Record<string, unknown>;
|
|
25
|
+
params?: Record<string, unknown>;
|
|
26
|
+
products?: Record<string, Record<string, unknown>>;
|
|
27
|
+
trialEligible?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type PreviewUrlBuilder = (surface: StudioSurface, overrides: PreviewOverrides) => string;
|
|
31
|
+
|
|
32
|
+
export type StudioActionName = "push" | "promote" | "publish";
|
|
33
|
+
|
|
34
|
+
export type CompareTarget = { type: "live" } | { type: "surface"; surface: StudioSurface };
|
|
35
|
+
|
|
36
|
+
export type StudioActionResult =
|
|
37
|
+
| { ok: true; version: number; live: boolean }
|
|
38
|
+
| { ok: false; error: string };
|
|
39
|
+
|
|
40
|
+
export type StudioStepState = "pending" | "active" | "done" | "failed";
|
|
41
|
+
|
|
42
|
+
export type StudioActionStep = "link" | "build" | "assets" | "push" | "source" | "promote";
|
|
43
|
+
|
|
44
|
+
export const ACTION_STEPS: Record<StudioActionName, StudioActionStep[]> = {
|
|
45
|
+
push: ["link", "build", "assets", "push", "source"],
|
|
46
|
+
publish: ["link", "build", "assets", "push", "source", "promote"],
|
|
47
|
+
promote: ["link", "promote"],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const STEP_LABELS: Record<StudioActionStep, string> = {
|
|
51
|
+
link: "Find paywall",
|
|
52
|
+
build: "Build snapshot",
|
|
53
|
+
assets: "Sync assets",
|
|
54
|
+
push: "Push version",
|
|
55
|
+
source: "Push source",
|
|
56
|
+
promote: "Promote to live",
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type StudioStatus = {
|
|
60
|
+
paywallId?: string;
|
|
61
|
+
liveUrl?: string;
|
|
62
|
+
active?: boolean;
|
|
63
|
+
updatedAt?: string;
|
|
64
|
+
/** Why the live version couldn't be read, when it couldn't. */
|
|
65
|
+
unreachable?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type StudioSource = {
|
|
69
|
+
scheme?: string;
|
|
70
|
+
title: string;
|
|
71
|
+
surfaces: StudioSurface[];
|
|
72
|
+
diagnostics?: string[];
|
|
73
|
+
samples?: SampleDefaults;
|
|
74
|
+
previewUrl: PreviewUrlBuilder;
|
|
75
|
+
capabilities?: { actions: boolean };
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type Samples = {
|
|
79
|
+
device?: Record<string, unknown>;
|
|
80
|
+
user?: Record<string, unknown>;
|
|
81
|
+
products?: Record<string, Record<string, unknown>>;
|
|
82
|
+
live?: { device: boolean; user: boolean };
|
|
83
|
+
/** Why samples couldn't be fetched, when they couldn't. */
|
|
84
|
+
unreachable?: string;
|
|
85
|
+
};
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { buildPreviewPath } from "./lib/preview";
|
|
4
|
+
import { parseProjectPayload } from "./lib/project";
|
|
5
|
+
import { StudioApp } from "./StudioApp";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
import type { StudioSource } from "./lib/types";
|
|
8
|
+
|
|
9
|
+
const loadSource = async (): Promise<StudioSource> => {
|
|
10
|
+
const response = await fetch("/__studio/project.json");
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`project data unavailable (${response.status})`);
|
|
13
|
+
}
|
|
14
|
+
const payload = parseProjectPayload(await response.json());
|
|
15
|
+
return { ...payload, previewUrl: buildPreviewPath };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Failure = ({ error }: { error: unknown }) => (
|
|
19
|
+
<div className="bg-ink text-cream fixed inset-0 flex font-sans antialiased">
|
|
20
|
+
<div className="m-auto flex flex-col items-center gap-3 text-center text-sm text-cream/55">
|
|
21
|
+
<span className="sw-chip font-mono text-[0.6875rem]">studio</span>
|
|
22
|
+
<p className="m-0">{String(error)}</p>
|
|
23
|
+
<p className="m-0 text-cream/55">
|
|
24
|
+
Is <code className="font-mono text-[0.8125rem] text-cream">superwall dev</code> running in a
|
|
25
|
+
project directory?
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const root = createRoot(document.getElementById("root")!);
|
|
32
|
+
|
|
33
|
+
const device = /^\/device\/?$/.test(window.location.pathname);
|
|
34
|
+
|
|
35
|
+
loadSource()
|
|
36
|
+
.then((source) => {
|
|
37
|
+
root.render(
|
|
38
|
+
<React.StrictMode>
|
|
39
|
+
<StudioApp source={source} device={device} />
|
|
40
|
+
</React.StrictMode>,
|
|
41
|
+
);
|
|
42
|
+
})
|
|
43
|
+
.catch((error: unknown) => {
|
|
44
|
+
root.render(
|
|
45
|
+
<React.StrictMode>
|
|
46
|
+
<Failure error={error} />
|
|
47
|
+
</React.StrictMode>,
|
|
48
|
+
);
|
|
49
|
+
});
|