@hubpav/hwio-web-runtime 0.10.7 → 0.10.8

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/dist/consent.d.ts CHANGED
@@ -19,7 +19,9 @@ declare global {
19
19
  }
20
20
  /**
21
21
  * Consent runtime. Markup contract (rendered by HWioCookieConsent):
22
- * [data-hwio-consent data-version data-gtm? data-locale] banner root (hidden attr toggles it)
22
+ * [data-hwio-consent data-version data-gtm? data-locale] banner root (hidden attr toggles it; the inline
23
+ * consentReveal bootstrap lifts it before paint
24
+ * on a visit without a stored choice)
23
25
  * [data-hwio-consent-modal] settings dialog wrapper (hidden)
24
26
  * [data-hwio-consent-accept|reject|customize|save|close] buttons (may appear several times)
25
27
  * [data-hwio-consent-toggle="preferences|statistics|marketing"] checkboxes
package/dist/consent.js CHANGED
@@ -3,7 +3,9 @@ import { HWIO_CONSENT_COOKIE, LEGACY_CONSENT_COOKIE, hwioBaseCategories, hwioCon
3
3
  const ATTRIBUTION_KEYS = ['hwio_attribution', 'hw_attribution']; // legacy-ok
4
4
  /**
5
5
  * Consent runtime. Markup contract (rendered by HWioCookieConsent):
6
- * [data-hwio-consent data-version data-gtm? data-locale] banner root (hidden attr toggles it)
6
+ * [data-hwio-consent data-version data-gtm? data-locale] banner root (hidden attr toggles it; the inline
7
+ * consentReveal bootstrap lifts it before paint
8
+ * on a visit without a stored choice)
7
9
  * [data-hwio-consent-modal] settings dialog wrapper (hidden)
8
10
  * [data-hwio-consent-accept|reject|customize|save|close] buttons (may appear several times)
9
11
  * [data-hwio-consent-toggle="preferences|statistics|marketing"] checkboxes
@@ -191,6 +193,15 @@ export function hwioConsentRuntime() {
191
193
  }
192
194
  render();
193
195
  }
196
+ // A view-transition swap brings a new banner in its markup state (hidden). Give it the known
197
+ // state before it is shown, so an undecided visitor's banner does not blink on every navigation.
198
+ document.addEventListener('astro:before-swap', (event) => {
199
+ if (!resolved)
200
+ return;
201
+ const incoming = event.newDocument?.querySelector('[data-hwio-consent]');
202
+ if (incoming)
203
+ incoming.hidden = !!current;
204
+ });
194
205
  window.hwioConsent = api;
195
206
  window.hwConsent = api; // legacy-ok
196
207
  hwioMount('consent', { bind, cleanup });
package/dist/inline.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface HWioInlineScript {
3
3
  hash: string;
4
4
  }
5
5
  export declare const consentDefaults: HWioInlineScript;
6
+ export declare const consentReveal: HWioInlineScript;
6
7
  export declare const fontGate: HWioInlineScript;
7
8
  export declare const themeBootstrap: HWioInlineScript;
8
9
  export declare const hwioInlineHashes: string[];
package/dist/inline.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export const consentDefaults = { "code": "(function(){window.dataLayer=window.dataLayer||[];window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};window.gtag('consent','default',{ad_storage:'denied',ad_user_data:'denied',ad_personalization:'denied',analytics_storage:'denied',functionality_storage:'denied',personalization_storage:'denied',security_storage:'granted'})})();", "hash": "sha256-8ypBBYlrPDUYAWyidrG8ZMBi91IYR2VYNNXABFu2aI8=" };
2
- export const fontGate = { "code": "(function(){var h=document.documentElement,d=h.dataset,fam=d.hwioFontFamily;if(!fam||!('fonts' in document)){h.classList.remove('fonts-loading');h.classList.add('fonts-ready');return}var T=5000;function load(s){return new Promise(function(res,rej){var id=setTimeout(function(){rej(new Error('font timeout'))},T);document.fonts.load('400 1em \"'+fam+'\"',s).then(function(f){clearTimeout(id);res(f)},function(e){clearTimeout(id);rej(e)})})}if(!window.__hwioFontGate){window.__hwioFontGate={state:'loading',ready:Promise.all([load(d.hwioFontSample||'HARDWARIO'),load(d.hwioFontSampleExt||'Řešení Vývojáři Odwiedź')])};document.addEventListener('astro:before-swap',function(ev){var n=ev.newDocument.documentElement;n.classList.add('js');n.classList.remove('fonts-loading');n.classList.toggle('fonts-failed',window.__hwioFontGate.state==='failed');n.classList.add('fonts-ready');var cur=h.getAttribute('data-theme');if(cur)n.setAttribute('data-theme',cur);else n.removeAttribute('data-theme')})}window.__hwioFontGate.ready.then(function(){window.__hwioFontGate.state='ready';h.classList.remove('fonts-loading');h.classList.add('fonts-ready')},function(){window.__hwioFontGate.state='failed';h.classList.remove('fonts-loading');h.classList.add('fonts-failed','fonts-ready')})})();", "hash": "sha256-yZ5zwDTjvBj25m7DRmqzRrznrnc2PqP3T7FWx0ftKO8=" };
2
+ export const consentReveal = { "code": "(function(){var s=document.currentScript,r=s&&s.previousElementSibling;if(r&&r.hasAttribute('data-hwio-consent')&&!/(?:^|; )(?:hwio|hw)_cookie_consent=/.test(document.cookie))r.hidden=false})();", "hash": "sha256-QCI9nRyWdvu7ZyaVc2IolCVQ2K02Onz9OHkjMJZc0l0=" };
3
+ export const fontGate = { "code": "(function(){var h=document.documentElement,d=h.dataset,fam=d.hwioFontFamily;if(!fam||!('fonts' in document)){h.classList.remove('fonts-loading');h.classList.add('fonts-ready');return}var T=5000;function declared(){var ok=false;document.fonts.forEach(function(f){if(f.family.replace(/[\"']/g,'')===fam)ok=true});return ok}function faces(){return new Promise(function(res){(function poll(){if(declared()||document.readyState==='complete')res();else setTimeout(poll,16)})()})}function weights(){var w={};document.fonts.forEach(function(f){if(f.family.replace(/[\"']/g,'')===fam)w[/^\\d+$/.test(f.weight)?f.weight:'400']=1});var k=Object.keys(w);return k.length?k:['400']}function load(w,s){return document.fonts.load(w+' 1em \"'+fam+'\"',s)}if(!window.__hwioFontGate){window.__hwioFontGate={state:'loading',ready:Promise.race([new Promise(function(res,rej){setTimeout(function(){rej(new Error('font timeout'))},T)}),faces().then(function(){var a=d.hwioFontSample||'HARDWARIO',b=d.hwioFontSampleExt||'Řešení Vývojáři Odwiedź';return Promise.all(weights().reduce(function(l,w){return l.concat([load(w,a),load(w,b)])},[]))})])};document.addEventListener('astro:before-swap',function(ev){var n=ev.newDocument.documentElement;n.classList.add('js');n.classList.remove('fonts-loading');n.classList.toggle('fonts-failed',window.__hwioFontGate.state==='failed');n.classList.add('fonts-ready');var cur=h.getAttribute('data-theme');if(cur)n.setAttribute('data-theme',cur);else n.removeAttribute('data-theme')})}window.__hwioFontGate.ready.then(function(){window.__hwioFontGate.state='ready';h.classList.remove('fonts-loading');h.classList.add('fonts-ready')},function(){window.__hwioFontGate.state='failed';h.classList.remove('fonts-loading');h.classList.add('fonts-failed','fonts-ready')})})();", "hash": "sha256-IYK+S3IpixwsVrpLMkfog8p0CD/YmuBDiJhxuJp+L5k=" };
3
4
  export const themeBootstrap = { "code": "(function(){var h=document.documentElement,d=h.dataset;h.classList.add('js');var t=null;try{if(d.hwioThemeCookieDomain){var m=document.cookie.match(/(?:^|; )hwio_theme=(dark|light)/);if(m)t=m[1]}if(!t)t=localStorage.getItem('hwio_theme')||localStorage.getItem('theme')}catch(e){}if(!h.getAttribute('data-theme')&&d.hwioThemeLight){h.setAttribute('data-theme',t==='dark'&&d.hwioThemeDark?d.hwioThemeDark:d.hwioThemeLight)}})();", "hash": "sha256-N+PCgo10dW74h2jKsCZVedLAmTLJeWIaNkhmjfY8r1Q=" };
4
- export const hwioInlineHashes = [consentDefaults.hash, fontGate.hash, themeBootstrap.hash];
5
+ export const hwioInlineHashes = [consentDefaults.hash, consentReveal.hash, fontGate.hash, themeBootstrap.hash];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubpav/hwio-web-runtime",
3
- "version": "0.10.7",
3
+ "version": "0.10.8",
4
4
  "description": "Framework-free browser runtime for the HARDWARIO websites: consent (Consent Mode v2 + GTM), HubSpot forms with Turnstile, attribution, theme, CTA tracking and small behaviours. View-transition safe.",
5
5
  "license": "MIT",
6
6
  "type": "module",