@seatlayer/js 0.23.0 → 0.25.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 CHANGED
@@ -101,8 +101,19 @@ designer.setDesignerUrl(nextSession.designerUrl);
101
101
  designer.destroy();
102
102
  ```
103
103
 
104
- Give the container a height, for example `min-height: 760px`. Keep the default
105
- `referrerPolicy: 'origin'`; the Designer uses it to verify the parent origin.
104
+ The default `height: 'fill'` is **container-aware**. On mount the SDK probes the
105
+ container: if you gave it a definite height a fixed-height block, `height` /
106
+ `max-height`, a `flex:1; min-h-0` child, a resolved `%` — the iframe fills 100% of
107
+ that block and tracks its size live via a `ResizeObserver`. If the container is
108
+ content-sized (it collapses to whatever the iframe measures — typical full-page
109
+ usage), the iframe instead grows so its bottom edge meets the bottom of the
110
+ viewport. Either way the result is clamped to `minHeight` (default `480`), and the
111
+ verdict is re-probed on resize so a responsive layout can flip between the two. So
112
+ you can either drop the Designer into a sized block (it fills the block) or give it
113
+ `min-height: 760px` for full-page use (it fills the viewport). Every SDK-managed
114
+ height is written with `!important`, so a host theme's `iframe { height: … }` rule
115
+ can't override it. Keep the default `referrerPolicy: 'origin'`; the Designer uses
116
+ it to verify the parent origin.
106
117
 
107
118
  ### Built-in loading, error, and expiry states
108
119
 
@@ -117,11 +128,51 @@ CSS files or external assets.
117
128
  | --- | --- | --- | --- |
118
129
  | `showLoadingState` | `boolean` | `true` | Render the built-in skeleton and error card. Set `false` when you draw your own chrome. |
119
130
  | `loadingTimeoutMs` | `number` | `20000` | If `ready` never arrives within this window, show the error card with a timeout message. |
120
- | `onRequestRelaunch` | `() => void` | — | Called by **"Try again"**. Mint a fresh session and call `setDesignerUrl()`; the iframe recreates and returns to loading. When omitted, "Try again" reloads the current URL in place. |
131
+ | `onRequestRelaunch` | `() => void` | — | Called by **"Try again"** _and_ by automatic renewal (below). Mint a fresh session and call `setDesignerUrl()`; the iframe recreates and returns to loading. When omitted, "Try again" reloads the current URL in place. |
132
+ | `autoRenewSession` | `boolean` | `true`¹ | Silently renew the session before it expires and auto-recover once if an expiry error slips through. ¹Defaults `true` only when `onRequestRelaunch` is provided; a no-op without it. Set `false` for fully manual "Try again". |
121
133
 
122
134
  `setDesignerUrl()` always returns the host to the loading state, so a relaunch
123
135
  flow needs no extra bookkeeping.
124
136
 
137
+ ### Session lifecycle
138
+
139
+ Designer sessions are **short-lived by design**: your backend mints a `dse_`
140
+ token (default 1 hour, up to 4 hours via `expiresInSeconds`) and bakes it into
141
+ `designerUrl`. Pick a TTL that fits how long organizers actually edit — longer is
142
+ not automatically better; the renewal below keeps even a multi-hour session alive.
143
+
144
+ Provide `onRequestRelaunch` returning (or awaiting) a freshly minted session, and
145
+ the SDK turns expiry into a non-event:
146
+
147
+ - **Silent proactive renewal.** From each `ready` message's `expiresAt` the SDK
148
+ schedules an automatic relaunch shortly before the session lapses — ~3 minutes
149
+ ahead, or, for a TTL under 15 minutes, after 80% of the remaining life (never
150
+ sooner than 30s after `ready`). Your `onRequestRelaunch` mints a fresh session
151
+ and swaps `designerUrl`, so editing continues with no expiry card. The timer
152
+ re-arms from every `ready`.
153
+ - **Automatic expiry recovery.** If an expiry error still arrives (a laptop that
154
+ slept past the renewal window, say), the SDK makes **one** automatic relaunch
155
+ attempt before showing the "Try again" card, and only falls back to the card if
156
+ that attempt also fails.
157
+
158
+ Relaunching is safe: **in-progress work is autosaved server-side**, so a fresh
159
+ iframe restores the organizer's chart where they left off.
160
+
161
+ ```js
162
+ const designer = new EmbeddedDesigner({
163
+ container: '#venue-designer',
164
+ designerUrl: session.designerUrl,
165
+ expectedChartId: session.chartId,
166
+ // Mint a fresh session on renewal, expiry recovery, or "Try again":
167
+ onRequestRelaunch: async () => {
168
+ const next = await mintDesignerSession(session.chartId); // your backend, up to 4h TTL
169
+ designer.setDesignerUrl(next.designerUrl); // recreates the iframe
170
+ },
171
+ // autoRenewSession defaults to true because onRequestRelaunch is present.
172
+ });
173
+ designer.mount();
174
+ ```
175
+
125
176
  ## API
126
177
 
127
178
  `new SeatingChart(options)` — options: `container` (selector or element, required),