ferst-core 0.10.2 → 0.10.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.
@@ -29,9 +29,11 @@ const { policyHref = '/cookie-policy/' } = Astro.props;
29
29
 
30
30
  <script>
31
31
  import { isDecided, setConsent } from '../lib/consent-client';
32
+ import { inPreviewFrame } from '../lib/preview-frame';
32
33
 
33
34
  const banner = document.getElementById('cookie-banner');
34
- if (banner && !isDecided()) {
35
+ // A preview in the portal isn't a visit: the banner stays out of its way (lib/preview-frame).
36
+ if (banner && !isDecided() && !inPreviewFrame()) {
35
37
  banner.hidden = false;
36
38
  // Next frame so the entry transition runs.
37
39
  requestAnimationFrame(() => banner.classList.add('visible'));
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Is this page being shown as a preview inside the portal (Make it yours, the Design tab)? It is
3
+ * when it's framed and was opened with `?preview` or is already in a preview session (links
4
+ * clicked inside the frame drop the query). The live theme listener and the cookie banner both ask:
5
+ * the banner stays out of the way of a preview, where nobody is visiting the site.
6
+ */
7
+ export function inPreviewFrame(win: Pick<Window, 'parent' | 'location' | 'sessionStorage'> = window): boolean {
8
+ try {
9
+ if (win.parent === (win as unknown)) return false;
10
+ } catch {
11
+ return false;
12
+ }
13
+ if (new URLSearchParams(win.location.search).has('preview')) return true;
14
+ try {
15
+ return win.sessionStorage.getItem('ferst-preview-on') === '1';
16
+ } catch {
17
+ return false; // sessionStorage blocked: only the ?preview query counts
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferst-core",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "type": "module",
5
5
  "description": "Ferst Core — the shared, brand-agnostic client-site system: Astro components, layouts, content schemas, the layered config resolver, and a neutral styling architecture that every client overrides.",
6
6
  "license": "BUSL-1.1",