@superwall/studio 1.1.1 → 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 (78) hide show
  1. package/README.md +61 -11
  2. package/dist/assets/index-DyLb5fiB.js +11 -0
  3. package/dist/assets/index-_HCp6gCi.css +1 -0
  4. package/dist/index.html +2 -2
  5. package/dist/lib/StudioApp.d.ts +6 -0
  6. package/dist/lib/components/OpenInApp.d.ts +5 -0
  7. package/dist/lib/components/PaywallToasts.d.ts +8 -0
  8. package/dist/lib/components/SurfaceCard.d.ts +11 -0
  9. package/dist/lib/components/chrome/StudioShell.d.ts +4 -0
  10. package/dist/lib/components/chrome/Toolbar.d.ts +6 -0
  11. package/dist/lib/components/chrome/TopBar.d.ts +8 -0
  12. package/dist/lib/components/controls.d.ts +24 -0
  13. package/dist/lib/components/icons.d.ts +18 -0
  14. package/dist/lib/components/menus/ActionMenu.d.ts +14 -0
  15. package/dist/lib/components/menus/CompareMenu.d.ts +13 -0
  16. package/dist/lib/components/panels/MissingProducts.d.ts +8 -0
  17. package/dist/lib/components/panels/SidePanel.d.ts +6 -0
  18. package/dist/lib/components/panels/VariablesPanel.d.ts +13 -0
  19. package/dist/lib/components/preview/DeviceChrome.d.ts +12 -0
  20. package/dist/lib/components/preview/DeviceFrame.d.ts +21 -0
  21. package/dist/lib/components/preview/HostedIframe.d.ts +7 -0
  22. package/dist/lib/icon.svg +5 -0
  23. package/dist/lib/index.d.ts +20 -0
  24. package/dist/lib/index.js +2268 -0
  25. package/dist/lib/lib/actions.d.ts +4 -0
  26. package/dist/lib/lib/contract.d.ts +33 -0
  27. package/dist/lib/lib/devices.d.ts +26 -0
  28. package/dist/lib/lib/host.d.ts +15 -0
  29. package/dist/lib/lib/notices.d.ts +9 -0
  30. package/dist/lib/lib/preview.d.ts +5 -0
  31. package/dist/lib/lib/products.d.ts +16 -0
  32. package/dist/lib/lib/project.d.ts +13 -0
  33. package/dist/lib/lib/steps.d.ts +5 -0
  34. package/dist/lib/lib/surfaces.d.ts +35 -0
  35. package/dist/lib/lib/time.d.ts +1 -0
  36. package/dist/lib/lib/variables.d.ts +12 -0
  37. package/dist/lib/products.js +65 -0
  38. package/dist/lib/screens/SurfaceEditor.d.ts +9 -0
  39. package/dist/lib/screens/SurfaceList.d.ts +7 -0
  40. package/dist/lib/studio.css +1 -0
  41. package/package.json +19 -4
  42. package/src/StudioApp.tsx +8 -11
  43. package/src/components/PaywallToasts.tsx +162 -85
  44. package/src/components/SurfaceCard.tsx +9 -2
  45. package/src/components/chrome/StudioShell.tsx +12 -0
  46. package/src/components/icons.tsx +0 -13
  47. package/src/components/{ActionMenu.tsx → menus/ActionMenu.tsx} +4 -4
  48. package/src/components/{CompareMenu.tsx → menus/CompareMenu.tsx} +3 -3
  49. package/src/components/{SidePanel.tsx → panels/SidePanel.tsx} +1 -1
  50. package/src/components/{VariablesPanel.tsx → panels/VariablesPanel.tsx} +4 -4
  51. package/src/components/{DeviceChrome.tsx → preview/DeviceChrome.tsx} +1 -1
  52. package/src/components/{DeviceFrame.tsx → preview/DeviceFrame.tsx} +14 -55
  53. package/src/components/preview/HostedIframe.tsx +46 -0
  54. package/src/index.ts +26 -6
  55. package/src/lib/actions.ts +1 -1
  56. package/src/lib/contract.ts +30 -0
  57. package/src/lib/devices.ts +5 -4
  58. package/src/lib/host.ts +80 -0
  59. package/src/lib/notices.ts +63 -0
  60. package/src/lib/preview.ts +11 -33
  61. package/src/lib/products.ts +116 -0
  62. package/src/lib/project.ts +2 -1
  63. package/src/lib/steps.ts +20 -0
  64. package/src/lib/surfaces.ts +41 -0
  65. package/src/lib/time.ts +1 -2
  66. package/src/lib/variables.ts +13 -0
  67. package/src/main.tsx +3 -3
  68. package/src/screens/SurfaceEditor.tsx +97 -67
  69. package/src/screens/SurfaceList.tsx +17 -7
  70. package/src/styles.css +8 -6
  71. package/src/vite-env.d.ts +1 -0
  72. package/dist/assets/index-CVKGrx00.js +0 -11
  73. package/dist/assets/index-D4RIpSbg.css +0 -1
  74. package/src/lib/events.ts +0 -77
  75. package/src/lib/types.ts +0 -85
  76. /package/src/components/{Toolbar.tsx → chrome/Toolbar.tsx} +0 -0
  77. /package/src/components/{TopBar.tsx → chrome/TopBar.tsx} +0 -0
  78. /package/src/components/{MissingProducts.tsx → panels/MissingProducts.tsx} +0 -0
package/README.md CHANGED
@@ -25,8 +25,10 @@ app that is also a component library — one codebase, two hosts:
25
25
 
26
26
  - **`superwall dev`** serves the BUILT app (`dist/`, assets under
27
27
  `/__studio/`) plus the data endpoint and preview mounts — the local studio.
28
- - **The hosted dashboard** either embeds the built app (the way it embeds the
29
- editor) or imports the components directly over platform data.
28
+ - **The hosted studio** in the dashboard imports the component library
29
+ (`dist/lib/`, the package's `.` export, plus the compiled
30
+ `@superwall/studio/studio.css`) and renders `SurfaceEditor` over published
31
+ snapshots and platform data. See [Hosting](#hosting).
30
32
 
31
33
  ## Package layout
32
34
 
@@ -34,19 +36,22 @@ app that is also a component library — one codebase, two hosts:
34
36
  packages/studio/
35
37
  ├── index.html the app shell (fonts, favicon)
36
38
  ├── vite.config.ts vite + react + tailwind; /__studio/ base for builds
39
+ ├── vite.lib.config.ts the library build: dist/lib/index.js + studio.css
40
+ ├── tsconfig.lib.json declarations for the library build
37
41
  ├── src/
38
42
  │ ├── main.tsx entry: fetch /__studio/project.json → <StudioApp/>
39
43
  │ ├── index.ts the component-library barrel a hosted studio imports
40
44
  │ ├── StudioApp.tsx URL-driven router (list ⇄ editor)
41
45
  │ ├── screens/ SurfaceList, SurfaceEditor
42
- │ ├── components/ TopBar, Toolbar, DeviceFrame, VariablesPanel,
46
+ │ ├── components/ StudioShell, TopBar, Toolbar, DeviceFrame, VariablesPanel,
43
47
  │ │ ActionMenu, CompareMenu, SidePanel, controls, icons, …
44
48
  │ ├── lib/ project.ts (wire-format parser, untrusted JSON,
45
49
  │ │ cast-free), preview.ts (preview URL builder),
46
50
  │ │ devices.ts (viewport + mock-device catalog),
47
51
  │ │ actions.ts, events.ts, time.ts, types.ts
48
52
  │ └── styles.css tailwind @theme tokens + stateful primitives
49
- └── dist/ built by the workspace postinstall
53
+ └── dist/ built by the workspace postinstall: the app, and
54
+ the library under dist/lib/
50
55
  ```
51
56
 
52
57
  ## Data seam
@@ -55,12 +60,57 @@ Everything renders from a `StudioSource` — `{ title, surfaces, diagnostics?,
55
60
  samples?, previewUrl, capabilities? }`. Locally that's
56
61
  `/__studio/project.json` (the dev server evaluates configs server-side and
57
62
  ships sample device/user/params/product data alongside). A hosted studio
58
- swaps the fetch, nothing else. `previewUrl(surface, overrides)` decides what
59
- the preview iframes load: `/preview/<kind>/<id>` mounts locally, published
60
- snapshot URLs in the dashboard. Overrides travel as query params (`theme`,
61
- `locale`, `sw_device`, `sw_user`, `sw_params`, `sw_products`, `sw_trial`) —
62
- the same channel published snapshots accept, so preview behavior is
63
- identical in both hosts.
63
+ swaps the fetch, nothing else. `previewUrl(surface)` decides what the preview
64
+ iframes load: `/preview/<kind>/<id>` mounts locally, published snapshot URLs
65
+ in the dashboard. Both carry `?transport=editor`, which makes the paywall
66
+ talk to its parent window, and the studio is that parent.
67
+
68
+ The studio is a paywall host in the SDK's sense, through `@superwall/host`.
69
+ Each `DeviceFrame` answers its paywall's `ping` with the same burst the web
70
+ host sends (`template_variables`, `experiment`, `products`,
71
+ `template_substitutions_prefix`, `paywall_open`), built from the host state
72
+ `SurfaceEditor` assembles: the API's device and user samples (or the host
73
+ package's defaults), the selected device frame's `platform`/`deviceModel`/
74
+ `osVersion`, the theme as `interfaceStyle`, the chosen locale as
75
+ `deviceLocale`, one product per slot with the catalogue's variables (or the
76
+ visual editor's example prices for a slot the catalogue cannot price), and
77
+ whatever the Variables panel edits on top. Every edit re-sends only what
78
+ changed; nothing reloads. Purchases, restores, permissions and callbacks come
79
+ back as prompts in the toasts and are answered with the messages the iOS SDK
80
+ sends. Nothing about this is specific to the studio: the paywall cannot tell
81
+ it from a device.
82
+
83
+ ## Hosting
84
+
85
+ The dashboard opens a code-first paywall in this studio instead of the visual
86
+ editor. What the library gives a host:
87
+
88
+ - `snapshotPreviewUrl(urlOf)` — a `previewUrl` that resolves each surface to
89
+ its published snapshot URL and adds `transport=editor`. Set
90
+ `paywallId`, `paywallIdentifier`, `products` and `locales` on each
91
+ `StudioSurface` from the paywall and version records; the studio hosts the
92
+ snapshot from them. `hostStateFor` and `hostPatch` are exported for a host
93
+ that wants to drive a `DeviceFrame` itself.
94
+ - One `StudioSurface` per version, told apart by `label` (`"v12 · live"`);
95
+ `StudioSource.compareHint` names what the compare menu offers, and
96
+ `SurfaceEditor`'s `actions` slot takes the host's own controls (a version
97
+ switcher, say). With no `capabilities`, there is no push/promote UI.
98
+ - `StudioShell` (`position="absolute"` when the host owns the viewport) is
99
+ the ink stage every screen expects, and it carries the `sw-studio` class
100
+ the stylesheet scopes its base rules to.
101
+ - `@superwall/studio/studio.css` is compiled Tailwind v4 output including a
102
+ preflight. Mount it in a shadow root (or an iframe) rather than beside
103
+ another design system — the dashboard does exactly that, and re-registers
104
+ the sheet's `@property` rules at document level, where browsers expect them.
105
+ - `@superwall/studio/products` is the pure mapping from a dashboard product
106
+ (the v2 API shape) to the variables a paywall reads (`price`, `periodly`,
107
+ `trialPeriodDays`, …). The CLI and the hosted studio share it, so the
108
+ Variables panel shows the same numbers in both.
109
+ - `@superwall/studio/contract` is a types-only entry: the action, status,
110
+ samples and app-scheme shapes the CLI implements for the framework's
111
+ preview server, importable from node without DOM types.
112
+ `@superwall/studio/styles.css` is the Tailwind source for hosts that run
113
+ their own v4 pipeline.
64
114
 
65
115
  ## Screens
66
116
 
@@ -104,7 +154,7 @@ bun install
104
154
  bun dev # the studio alone on port 6200, proxied to a running
105
155
  # `superwall dev` (port 6100) in any project — HMR against
106
156
  # real paywalls
107
- bun run build # dist/, what `superwall dev` serves
157
+ bun run build # dist/ (what `superwall dev` serves) and dist/lib/ (the library)
108
158
  bun run test
109
159
  bun run typecheck
110
160
  ```