@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.
Files changed (71) hide show
  1. package/README.md +27 -14
  2. package/dist/assets/index-DyLb5fiB.js +11 -0
  3. package/dist/index.html +1 -1
  4. package/dist/lib/StudioApp.d.ts +2 -3
  5. package/dist/lib/components/PaywallToasts.d.ts +3 -0
  6. package/dist/lib/components/SurfaceCard.d.ts +4 -2
  7. package/dist/lib/components/icons.d.ts +0 -2
  8. package/dist/lib/components/{ActionMenu.d.ts → menus/ActionMenu.d.ts} +2 -1
  9. package/dist/lib/components/{CompareMenu.d.ts → menus/CompareMenu.d.ts} +1 -1
  10. package/dist/lib/components/{VariablesPanel.d.ts → panels/VariablesPanel.d.ts} +3 -3
  11. package/dist/lib/components/{DeviceChrome.d.ts → preview/DeviceChrome.d.ts} +1 -1
  12. package/dist/lib/components/{DeviceFrame.d.ts → preview/DeviceFrame.d.ts} +5 -2
  13. package/dist/lib/components/preview/HostedIframe.d.ts +7 -0
  14. package/dist/lib/index.d.ts +12 -6
  15. package/dist/lib/index.js +1467 -945
  16. package/dist/lib/lib/actions.d.ts +1 -1
  17. package/dist/lib/lib/contract.d.ts +33 -0
  18. package/dist/lib/lib/devices.d.ts +1 -1
  19. package/dist/lib/lib/host.d.ts +15 -0
  20. package/dist/lib/lib/notices.d.ts +9 -0
  21. package/dist/lib/lib/preview.d.ts +2 -4
  22. package/dist/lib/lib/project.d.ts +2 -1
  23. package/dist/lib/lib/steps.d.ts +5 -0
  24. package/dist/lib/lib/surfaces.d.ts +35 -0
  25. package/dist/lib/lib/variables.d.ts +12 -0
  26. package/dist/lib/products.js +26 -12
  27. package/dist/lib/screens/SurfaceEditor.d.ts +1 -1
  28. package/dist/lib/screens/SurfaceList.d.ts +1 -1
  29. package/package.json +5 -1
  30. package/src/StudioApp.tsx +6 -10
  31. package/src/components/PaywallToasts.tsx +162 -86
  32. package/src/components/SurfaceCard.tsx +9 -2
  33. package/src/components/icons.tsx +0 -13
  34. package/src/components/{ActionMenu.tsx → menus/ActionMenu.tsx} +3 -3
  35. package/src/components/{CompareMenu.tsx → menus/CompareMenu.tsx} +2 -2
  36. package/src/components/{SidePanel.tsx → panels/SidePanel.tsx} +1 -1
  37. package/src/components/{VariablesPanel.tsx → panels/VariablesPanel.tsx} +4 -4
  38. package/src/components/{DeviceChrome.tsx → preview/DeviceChrome.tsx} +1 -1
  39. package/src/components/{DeviceFrame.tsx → preview/DeviceFrame.tsx} +14 -55
  40. package/src/components/preview/HostedIframe.tsx +46 -0
  41. package/src/index.ts +24 -12
  42. package/src/lib/actions.ts +1 -1
  43. package/src/lib/contract.ts +30 -0
  44. package/src/lib/devices.ts +5 -4
  45. package/src/lib/host.ts +80 -0
  46. package/src/lib/notices.ts +63 -0
  47. package/src/lib/preview.ts +8 -40
  48. package/src/lib/products.ts +20 -1
  49. package/src/lib/project.ts +2 -1
  50. package/src/lib/steps.ts +20 -0
  51. package/src/lib/surfaces.ts +41 -0
  52. package/src/lib/time.ts +1 -2
  53. package/src/lib/variables.ts +13 -0
  54. package/src/main.tsx +3 -3
  55. package/src/screens/SurfaceEditor.tsx +77 -66
  56. package/src/screens/SurfaceList.tsx +17 -7
  57. package/src/vite-env.d.ts +1 -0
  58. package/dist/assets/index-CVKQ82YR.js +0 -11
  59. package/dist/lib/lib/events.d.ts +0 -27
  60. package/dist/lib/lib/types.d.ts +0 -77
  61. package/src/lib/events.ts +0 -86
  62. package/src/lib/types.ts +0 -87
  63. /package/dist/lib/components/{StudioShell.d.ts → chrome/StudioShell.d.ts} +0 -0
  64. /package/dist/lib/components/{Toolbar.d.ts → chrome/Toolbar.d.ts} +0 -0
  65. /package/dist/lib/components/{TopBar.d.ts → chrome/TopBar.d.ts} +0 -0
  66. /package/dist/lib/components/{MissingProducts.d.ts → panels/MissingProducts.d.ts} +0 -0
  67. /package/dist/lib/components/{SidePanel.d.ts → panels/SidePanel.d.ts} +0 -0
  68. /package/src/components/{StudioShell.tsx → chrome/StudioShell.tsx} +0 -0
  69. /package/src/components/{Toolbar.tsx → chrome/Toolbar.tsx} +0 -0
  70. /package/src/components/{TopBar.tsx → chrome/TopBar.tsx} +0 -0
  71. /package/src/components/{MissingProducts.tsx → panels/MissingProducts.tsx} +0 -0
@@ -1,27 +0,0 @@
1
- export declare const STUDIO_CHANNEL = "superwall-studio";
2
- export type PaywallEvent = {
3
- event_name: string;
4
- } & Record<string, unknown>;
5
- export type BridgeMessage = {
6
- channel: typeof STUDIO_CHANNEL;
7
- type: "hello";
8
- locales: string[];
9
- } | {
10
- channel: typeof STUDIO_CHANNEL;
11
- type: "event";
12
- message: PaywallEvent;
13
- } | {
14
- channel: typeof STUDIO_CHANNEL;
15
- type: "ask";
16
- id: string;
17
- kind: "purchase" | "permission" | "callback";
18
- subject: string;
19
- };
20
- export type EventNotice = {
21
- action: string;
22
- subject?: string;
23
- tone: "info" | "success" | "warning";
24
- };
25
- export declare const noticeFor: (event: PaywallEvent) => EventNotice | undefined;
26
- export declare const isBridgeMessage: (data: unknown) => data is BridgeMessage;
27
- export declare const localesAnnounced: (data: unknown) => string[] | undefined;
@@ -1,77 +0,0 @@
1
- export type StudioSurfaceKind = "paywall" | "funnel";
2
- export type StudioSurface = {
3
- kind: StudioSurfaceKind;
4
- id: string;
5
- project?: string;
6
- label?: string;
7
- products?: Record<string, string>;
8
- routes: string[];
9
- locales: string[];
10
- platforms?: string[];
11
- paywallId?: string;
12
- };
13
- export type SampleDefaults = {
14
- device: Record<string, unknown>;
15
- user: Record<string, unknown>;
16
- params: Record<string, unknown>;
17
- };
18
- export type PreviewOverrides = {
19
- theme?: "light" | "dark";
20
- locale?: string;
21
- device?: Record<string, unknown>;
22
- user?: Record<string, unknown>;
23
- params?: Record<string, unknown>;
24
- products?: Record<string, Record<string, unknown>>;
25
- trialEligible?: boolean;
26
- };
27
- export type PreviewUrlBuilder = (surface: StudioSurface, overrides: PreviewOverrides) => string;
28
- export type StudioActionName = "push" | "promote" | "publish";
29
- export type CompareTarget = {
30
- type: "live";
31
- } | {
32
- type: "surface";
33
- surface: StudioSurface;
34
- };
35
- export type StudioActionResult = {
36
- ok: true;
37
- version: number;
38
- live: boolean;
39
- } | {
40
- ok: false;
41
- error: string;
42
- };
43
- export type StudioStepState = "pending" | "active" | "done" | "failed";
44
- export type StudioActionStep = "link" | "build" | "assets" | "push" | "source" | "promote";
45
- export declare const ACTION_STEPS: Record<StudioActionName, StudioActionStep[]>;
46
- export declare const STEP_LABELS: Record<StudioActionStep, string>;
47
- export type StudioStatus = {
48
- paywallId?: string;
49
- liveUrl?: string;
50
- active?: boolean;
51
- updatedAt?: string;
52
- /** Why the live version couldn't be read, when it couldn't. */
53
- unreachable?: string;
54
- };
55
- export type StudioSource = {
56
- scheme?: string;
57
- title: string;
58
- surfaces: StudioSurface[];
59
- diagnostics?: string[];
60
- samples?: SampleDefaults;
61
- previewUrl: PreviewUrlBuilder;
62
- capabilities?: {
63
- actions: boolean;
64
- };
65
- compareHint?: string;
66
- };
67
- export type Samples = {
68
- device?: Record<string, unknown>;
69
- user?: Record<string, unknown>;
70
- products?: Record<string, Record<string, unknown>>;
71
- live?: {
72
- device: boolean;
73
- user: boolean;
74
- };
75
- /** Why samples couldn't be fetched, when they couldn't. */
76
- unreachable?: string;
77
- };
package/src/lib/events.ts DELETED
@@ -1,86 +0,0 @@
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: "hello"; locales: string[] }
7
- | { channel: typeof STUDIO_CHANNEL; type: "event"; message: PaywallEvent }
8
- | {
9
- channel: typeof STUDIO_CHANNEL;
10
- type: "ask";
11
- id: string;
12
- kind: "purchase" | "permission" | "callback";
13
- subject: string;
14
- };
15
-
16
- export type EventNotice = {
17
- action: string;
18
- subject?: string;
19
- tone: "info" | "success" | "warning";
20
- };
21
-
22
- const SILENT = new Set([
23
- "ping",
24
- "page_view",
25
- "page_styles",
26
- "has_set_dom",
27
- "haptic_feedback",
28
- "var_click",
29
- "template_variables",
30
- "template_substitutions_prefix",
31
- "products",
32
- "paywall_open",
33
- "experiment",
34
- "purchase",
35
- ]);
36
-
37
- const SUBJECT: Record<string, readonly string[]> = {
38
- open_url: ["url"],
39
- open_url_external: ["url"],
40
- open_deep_link: ["link", "url"],
41
- custom_placement: ["name", "placementName"],
42
- custom: ["name", "data"],
43
- request_permission: ["permissionType"],
44
- request_callback: ["name"],
45
- schedule_notification: ["title"],
46
- };
47
-
48
- const WARNING = new Set(["close", "transaction_abandon", "transaction_fail"]);
49
-
50
- const SUCCESS = new Set(["transaction_complete", "freeTrial_start"]);
51
-
52
- const subjectOf = (event: PaywallEvent): string | undefined => {
53
- for (const key of SUBJECT[event.event_name] ?? []) {
54
- const value = event[key];
55
- if (typeof value === "string" && value.length > 0) return value;
56
- }
57
- return undefined;
58
- };
59
-
60
- export const noticeFor = (event: PaywallEvent): EventNotice | undefined => {
61
- if (SILENT.has(event.event_name)) return undefined;
62
-
63
- return {
64
- action: event.event_name,
65
- subject: subjectOf(event),
66
- tone: WARNING.has(event.event_name)
67
- ? "warning"
68
- : SUCCESS.has(event.event_name)
69
- ? "success"
70
- : "info",
71
- };
72
- };
73
-
74
- export const isBridgeMessage = (data: unknown): data is BridgeMessage =>
75
- typeof data === "object" &&
76
- data !== null &&
77
- Reflect.get(data, "channel") === STUDIO_CHANNEL &&
78
- ["hello", "event", "ask"].includes(String(Reflect.get(data, "type")));
79
-
80
- const isStringArray = (value: unknown): value is string[] =>
81
- Array.isArray(value) && value.every((entry) => typeof entry === "string");
82
-
83
- export const localesAnnounced = (data: unknown): string[] | undefined =>
84
- isBridgeMessage(data) && data.type === "hello" && isStringArray(data.locales)
85
- ? data.locales
86
- : undefined;
package/src/lib/types.ts DELETED
@@ -1,87 +0,0 @@
1
- export type StudioSurfaceKind = "paywall" | "funnel";
2
-
3
- export type StudioSurface = {
4
- kind: StudioSurfaceKind;
5
- id: string;
6
- project?: string;
7
- label?: string;
8
- products?: Record<string, string>;
9
- routes: string[];
10
- locales: string[];
11
- platforms?: string[];
12
- paywallId?: string;
13
- };
14
-
15
- export type SampleDefaults = {
16
- device: Record<string, unknown>;
17
- user: Record<string, unknown>;
18
- params: Record<string, unknown>;
19
- };
20
-
21
- export type PreviewOverrides = {
22
- theme?: "light" | "dark";
23
- locale?: string;
24
- device?: Record<string, unknown>;
25
- user?: Record<string, unknown>;
26
- params?: Record<string, unknown>;
27
- products?: Record<string, Record<string, unknown>>;
28
- trialEligible?: boolean;
29
- };
30
-
31
- export type PreviewUrlBuilder = (surface: StudioSurface, overrides: PreviewOverrides) => string;
32
-
33
- export type StudioActionName = "push" | "promote" | "publish";
34
-
35
- export type CompareTarget = { type: "live" } | { type: "surface"; surface: StudioSurface };
36
-
37
- export type StudioActionResult =
38
- | { ok: true; version: number; live: boolean }
39
- | { ok: false; error: string };
40
-
41
- export type StudioStepState = "pending" | "active" | "done" | "failed";
42
-
43
- export type StudioActionStep = "link" | "build" | "assets" | "push" | "source" | "promote";
44
-
45
- export const ACTION_STEPS: Record<StudioActionName, StudioActionStep[]> = {
46
- push: ["link", "build", "assets", "push", "source"],
47
- publish: ["link", "build", "assets", "push", "source", "promote"],
48
- promote: ["link", "promote"],
49
- };
50
-
51
- export const STEP_LABELS: Record<StudioActionStep, string> = {
52
- link: "Find paywall",
53
- build: "Build snapshot",
54
- assets: "Sync assets",
55
- push: "Push version",
56
- source: "Push source",
57
- promote: "Promote to live",
58
- };
59
-
60
- export type StudioStatus = {
61
- paywallId?: string;
62
- liveUrl?: string;
63
- active?: boolean;
64
- updatedAt?: string;
65
- /** Why the live version couldn't be read, when it couldn't. */
66
- unreachable?: string;
67
- };
68
-
69
- export type StudioSource = {
70
- scheme?: string;
71
- title: string;
72
- surfaces: StudioSurface[];
73
- diagnostics?: string[];
74
- samples?: SampleDefaults;
75
- previewUrl: PreviewUrlBuilder;
76
- capabilities?: { actions: boolean };
77
- compareHint?: string;
78
- };
79
-
80
- export type Samples = {
81
- device?: Record<string, unknown>;
82
- user?: Record<string, unknown>;
83
- products?: Record<string, Record<string, unknown>>;
84
- live?: { device: boolean; user: boolean };
85
- /** Why samples couldn't be fetched, when they couldn't. */
86
- unreachable?: string;
87
- };