@hsfx/attr 2.0.3 → 2.0.5

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
@@ -10,21 +10,46 @@ Auto-initializing JavaScript library for Webflow sites with animations, accessib
10
10
 
11
11
  ```html
12
12
  <script type="module" src="https://cdn.jsdelivr.net/npm/@hsfx/attr@2/dist/main.js"></script>
13
- <script>!function t(){window.hsfx?.ready?window.hsfx.ready(()=>{window.hsfxReady=!0,dispatchEvent(new Event('hsfx:ready'))}):setTimeout(t,50)}()</script>
13
+ <script>!function(){let e=[];window.hsfx||(window.hsfx={ready:t=>e.push(t)});!function t(){window.hsfx.loaded?e.forEach(e=>{try{e()}catch{}}):window.hsfx.ready&&Array.isArray(window.hsfx)?e.forEach(e=>window.hsfx.ready(e)):setTimeout(t,50)}()}()</script>
14
14
  ```
15
15
 
16
- **Local Development:**
16
+ ### Next.js Installation
17
+
18
+ ```tsx
19
+ <Script src="https://cdn.jsdelivr.net/npm/@hsfx/attr@2/dist/main.js" strategy="afterInteractive" data-hs-wf-off />
20
+ <Script id="hsfx-helper" strategy="afterInteractive">{`!function(){let e=[];window.hsfx||(window.hsfx={ready:t=>e.push(t)});!function t(){window.hsfx.loaded?e.forEach(e=>{try{e()}catch{}}):window.hsfx.ready&&Array.isArray(window.hsfx)?e.forEach(e=>window.hsfx.ready(e)):setTimeout(t,50)}()}()`}</Script>
21
+ ```
22
+
23
+ ### Local Development
17
24
 
18
25
  ```html
19
26
  <!-- Local testing (run: npm run dev) -->
20
27
  <script type="module" src="http://localhost:5173/index.ts"></script>
21
- <script>!function t(){window.hsfx?.ready?window.hsfx.ready(()=>{window.hsfxReady=!0,dispatchEvent(new Event('hsfx:ready'))}):setTimeout(t,50)}()</script>
28
+ <script>!function(){let e=[];window.hsfx||(window.hsfx={ready:t=>e.push(t)});!function t(){window.hsfx.loaded?e.forEach(e=>{try{e()}catch{}}):window.hsfx.ready&&Array.isArray(window.hsfx)?e.forEach(e=>window.hsfx.ready(e)):setTimeout(t,50)}()}()</script>
22
29
  ```
23
- **SPA Mode (Barba.js, Swup, etc.): Add data-hs-spa="true" to the module loader**
30
+
31
+ ### Inline Helper Script
32
+
33
+ The inline script ensures `window.hsfx` is available for external scripts:
34
+
35
+ ```html
36
+ <script>!function(){let e=[];window.hsfx||(window.hsfx={ready:t=>e.push(t)});!function t(){window.hsfx.loaded?e.forEach(e=>{try{e()}catch{}}):window.hsfx.ready&&Array.isArray(window.hsfx)?e.forEach(e=>window.hsfx.ready(e)):setTimeout(t,50)}()}()</script>
37
+ ```
38
+
39
+ **What it does:**
40
+ - Creates a temporary `window.hsfx.ready()` shim immediately
41
+ - Queues callbacks from external scripts before hsfx loads
42
+ - Polls for real hsfx to load
43
+ - Flushes queued callbacks to real hsfx when ready
44
+ - Guarantees external scripts can use `window.hsfx.ready()` safely
45
+
46
+ ### SPA Mode
47
+
48
+ **For Barba.js, Swup, etc.:** Add `data-hs-spa="true"` to the module loader
24
49
 
25
50
  ```html
26
51
  <script type="module" src="https://cdn.jsdelivr.net/npm/@hsfx/attr@2/dist/main.js" data-hs-spa="true"></script>
27
- <script>!function t(){window.hsfx?.ready?window.hsfx.ready(()=>{window.hsfxReady=!0,dispatchEvent(new Event('hsfx:ready'))}):setTimeout(t,50)}()</script>
52
+ <script>!function(){let e=[];window.hsfx||(window.hsfx={ready:t=>e.push(t)});!function t(){window.hsfx.loaded?e.forEach(e=>{try{e()}catch{}}):window.hsfx.ready&&Array.isArray(window.hsfx)?e.forEach(e=>window.hsfx.ready(e)):setTimeout(t,50)}()}()</script>
28
53
  ```
29
54
 
30
55
  ## Configuration
@@ -52,18 +77,15 @@ When using external scripts & libraries (Barba.js, GSAP ScrollTrigger, etc.) tha
52
77
 
53
78
  ```html
54
79
  <script>
55
- window.hsfx?.ready(() => {
56
- // Your code here
80
+ window.hsfx.ready(() => {
81
+ // Your code here - guaranteed to run when hsfx is fully loaded
57
82
  });
58
83
  </script>
59
84
  ```
60
85
 
61
- </script>
62
- ```
63
-
64
86
  **Why this works:**
65
87
 
66
- The inline helper script (included in standard installation) polls for `window.hsfx` to exist and calls `ready()` once initialization completes. This guarantees that by the time your external script runs, `window.hsfx` exists and `ready()` will fire either immediately (if already ready) or when initialization completes.
88
+ The inline helper script creates a temporary `window.hsfx.ready()` shim immediately, so external scripts can safely call it even before the real hsfx library loads. Callbacks are queued and then flushed to the real hsfx when initialization completes.
67
89
 
68
90
  ### Cleanup
69
91
 
@@ -1 +1 @@
1
- import{q as e,a as t,g as n,b as r,c as o}from"./hsfxutilsCYt-q_3u.js";function s(){return function(){const e=window.location.origin,t=e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.textContent?.trim()||""},n=t("company"),r=t("phone"),o=t("email"),s=t("city"),i=t("state"),a=t("zipcode"),c={"@context":"https://schema.org","@type":"LocalBusiness",name:n,url:e,telephone:r,email:o},l=document.querySelector('[data-hs-replace="business-logo"] img');l&&l.src&&(c.image=l.src);const d={"@type":"PostalAddress",addressLocality:s,addressRegion:i,postalCode:a,addressCountry:"US"},u=t("street-address");u&&(d.streetAddress=u),c.address=d;const m=t("business-latitude"),p=t("business-longitude");m&&p&&(c.geo={"@type":"GeoCoordinates",latitude:m,longitude:p});const h=["facebook","instagram","linkedin","pinterest","tiktok","x","youtube"].map(e=>(e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.href||""})(e)).filter(e=>e&&""!==e.trim()&&!e.includes("placeholder"));h.length>0&&(c.sameAs=h);const f=document.querySelector('[data-hs-schema="services"]');if(f){const e=f.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>e.textContent?.trim()).filter(e=>e&&""!==e);t.length>0&&(c.serviceType=t)}const y=document.querySelector('[data-hs-schema="areas"]');if(y){const e=y.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>({"@type":"City",name:e.textContent?.trim()||""})).filter(e=>e.name&&""!==e.name);t.length>0&&(c.areaServed=t)}const g=document.createElement("script");g.type="application/ld+json",g.text=JSON.stringify(c),document.head.appendChild(g);const b=document.querySelector('[data-hs-schema="breadcrumb"]')?.textContent?.trim()||"",A=window.location.pathname.split("/").filter(e=>""!==e);if(A.length>0){const t={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:e}]},n=A[0],r=n.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.itemListElement.push({"@type":"ListItem",position:2,name:r,item:e+"/"+n}),b&&t.itemListElement.push({"@type":"ListItem",position:3,name:b,item:window.location.href});const o=document.createElement("script");o.type="application/ld+json",o.text=JSON.stringify(t),document.head.appendChild(o)}if(document.querySelector('[data-hs-accordion-type="faq"]')){const e=[];if(document.querySelectorAll('[data-hs-accordion="list"]').forEach(t=>{t.querySelectorAll('[data-hs-accordion-type="faq"]').forEach(t=>{const n=t.querySelector('[data-hs-accordion="toggle"]'),r=t.querySelector('[data-hs-accordion="content"]');if(n&&r){const t=n.textContent?.trim(),o=r.innerHTML.trim();e.push({"@type":"Question",name:t,acceptedAnswer:{"@type":"Answer",text:o}})}})}),e.length>0){const t={"@context":"https://schema.org","@type":"FAQPage",mainEntity:e},n=document.createElement("script");n.type="application/ld+json",n.text=JSON.stringify(t),document.head.appendChild(n)}}const x=document.querySelector('[data-hs-schema-service="name"]'),S=document.querySelector('[data-hs-schema-service="description"]');if(x&&S){const e=x.textContent?.trim()||"",t=S.textContent?.trim()||"";if(e&&t){const n={"@context":"https://schema.org","@type":"Service",name:e,description:t},r=document.createElement("script");r.type="application/ld+json",r.text=JSON.stringify(n),document.head.appendChild(r)}}else(x||S)&&console.warn('[schema] Service page schema requires both "name" and "description" elements');const q=document.querySelector('[data-hs-schema-faq="question"]'),C=document.querySelector('[data-hs-schema-faq="answer"]'),E=document.querySelector('[data-hs-schema-faq="published"]'),w=document.querySelector('[data-hs-schema-faq="modified"]');if(q&&C&&E&&w){const e=q.textContent?.trim()||"",t=C.innerHTML.trim(),n=E.textContent?.trim()||"",r=w.textContent?.trim()||"";if(e&&t&&n&&r){const o={"@context":"https://schema.org","@type":"QAPage",mainEntity:{"@type":"Question",name:e,text:e,answerCount:1,datePublished:n,dateModified:r,acceptedAnswer:{"@type":"Answer",text:t}}},s=document.createElement("script");s.type="application/ld+json",s.text=JSON.stringify(o),document.head.appendChild(s)}}else if(q||C||E||w){const e=[];q||e.push("question"),C||e.push("answer"),E||e.push("published"),w||e.push("modified"),console.warn(`[schema] FAQ page schema missing required fields: ${e.join(", ")}`)}const v=document.querySelector('[data-hs-schema-blog="name"]'),N=document.querySelector('[data-hs-schema-blog="published"]'),$=document.querySelector('[data-hs-schema-blog="modified"]'),F=document.querySelector('[data-hs-schema-blog="summary"]'),L=document.querySelector('[data-hs-schema-blog="author-name"]'),k=document.querySelector('[data-hs-schema-blog="author-type"]');if(v&&N&&$&&F&&L&&k){const e=v.textContent?.trim()||"",n=N.textContent?.trim()||"",r=$.textContent?.trim()||"",o=F.textContent?.trim()||"",s=L.textContent?.trim()||"",i=k.textContent?.trim()||"Organization",a=document.querySelector('[data-hs-schema-blog="author-role"]'),c=document.querySelector('[data-hs-schema-blog="author-image"]'),l=a?.textContent?.trim()||"",d=c?.src||"",u=t("company"),m=document.querySelector('[data-hs-replace="business-logo"] img'),p=m?m.src:"";let h;"Person"===i?(h={"@type":"Person",name:s},l&&(h.jobTitle=l),d&&(h.image=d)):(h={"@type":"Organization",name:s},p&&(h.logo=p));const f={"@context":"https://schema.org","@type":"BlogPosting",headline:e,description:o,datePublished:n,dateModified:r,author:h,publisher:{"@type":"Organization",name:u||s,logo:{"@type":"ImageObject",url:p}},mainEntityOfPage:{"@type":"WebPage","@id":window.location.href}},y=document.createElement("script");y.type="application/ld+json",y.text=JSON.stringify(f),document.head.appendChild(y)}else if(v||N||$||F||L||k){const e=[];v||e.push("name"),N||e.push("published"),$||e.push("modified"),F||e.push("summary"),L||e.push("author-name"),k||e.push("author-type"),console.warn(`[schema] Blog page schema missing required fields: ${e.join(", ")}`)}}(),{result:"schema initialized",destroy:()=>{}}}function i(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r;for(;r=n.nextNode();)r.nodeValue?.trim()&&t.push(r);return t}function a(e){const t=[];return e.hasAttribute("href")&&t.push(e),t.push(...Array.from(e.querySelectorAll("[href]"))),t}function c(e){if(e.hasAttribute("src")){if(e.getAttribute("src"))return e}const t=e.querySelector("[src]");if(t){if(t.getAttribute("src"))return t}return null}function l(e,t,n){if(function(e,t){const n=t.attributes.properties.syncField;return null!==e.querySelector(`[${n}]`)}(t,n))return void function(e,t,n){const r=n.attributes.properties.syncField;e.querySelectorAll(`[${r}]`).forEach(e=>{const n=e.getAttribute(r),o=t.querySelector(`[${r}="${n}"]`);if(!o)return;const s=c(e),a=c(o);if(s&&a){const e=s.getAttribute("src");e&&a.setAttribute("src",e)}else if(e.hasAttribute("href")&&o.hasAttribute("href")){const t=e.getAttribute("href");t&&o.setAttribute("href",t)}else{const t=i(e),n=t.length>0?t[0].nodeValue:e.textContent.trim();if(n){const e=i(o);e.length>0?e[0].nodeValue=n:o.textContent=n}}})}(e,t,n);const r=i(e),o=r.length>0?r[0].nodeValue:"",s=a(e),l=s.length>0?s[0].getAttribute("href"):"";if(o){i(t).forEach(e=>{e.nodeValue=o})}if(l){a(t).forEach(e=>{e.setAttribute("href",l)})}}const d="hs-dupe-no-transition";let u=!1;async function m(t){!function(){if(u)return;const e=document.createElement("style");e.textContent=`\n .${d},\n .${d} * {\n transition: none !important;\n animation: none !important;\n }\n `,document.head.appendChild(e),u=!0}();const n={processedElements:[]};return e(t,"wrapper").forEach(e=>{const t=e.getAttribute("data-hs-dupe");if(!t||"child"!==t&&"self"!==t)return void console.warn('[dupe] Invalid mode. Use "child" or "self":',e);const r=e.getAttribute("data-hs-dupe-count");let o=r?parseInt(r,10):1;(isNaN(o)||o<1)&&(console.warn("[dupe] Invalid count, using default of 1:",e),o=1),o>20&&(console.warn(`[dupe] Count of ${o} exceeds maximum of 20. Capping at 20.`),o=20);const s={hidden:e.hasAttribute("data-hs-dupe-hidden"),noSelect:e.hasAttribute("data-hs-dupe-no-select")};"child"===t?function(e,t,n,r){const o=e.children[0];if(!o)return;const s=[];for(let i=0;i<t;i++){const t=o.cloneNode(!0);t.classList.add(d),p(t,n),e.appendChild(t),s.push(t),t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}r.processedElements.push({element:e,mode:"child",clones:s})}(e,o,s,n):"self"===t&&function(e,t,n,r){const o=e.parentNode;if(!o)return void console.warn("[dupe] Element has no parent, cannot duplicate self:",e);const s=[];let i=e;for(let a=0;a<t;a++){const t=e.cloneNode(!0);t.classList.add(d),t.removeAttribute("data-hs-dupe"),t.removeAttribute("data-hs-dupe-count"),t.removeAttribute("data-hs-dupe-hidden"),t.removeAttribute("data-hs-dupe-no-select"),p(t,n),i.nextSibling?o.insertBefore(t,i.nextSibling):o.appendChild(t),s.push(t),i=t,t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}r.processedElements.push({element:e,mode:"self",clones:s})}(e,o,s,n)}),{result:`dupe processed ${n.processedElements.length} elements`,destroy:()=>{}}}function p(e,t){if(t.hidden&&e.setAttribute("aria-hidden","true"),t.noSelect){const t=e;t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.msUserSelect="none"}}async function h(){const i={destroyFunctions:[]},a=o.normalize;try{const d=s();d&&"destroy"in d&&"function"==typeof d.destroy&&i.destroyFunctions.push(d.destroy);const u=await async function(){const t={processedWrappers:[]};return e(n.clickable,"wrapper").forEach(e=>{const n=e.querySelector(":scope > button"),r=e.querySelector(":scope > a");if(!n||!r)return;const o=r.getAttribute("href");let s,i;o&&""!==o&&"#"!==o?(s=r,i=n):(s=n,i=r);const a="button"===s.getAttribute("data-hs-clickable");a||s.setAttribute("data-hs-clickable","button"),i.remove(),t.processedWrappers.push({wrapper:e,keptElement:s,wasLink:s===r,addedAttribute:!a})}),{result:`clickable processed ${t.processedWrappers.length} wrappers`,destroy:()=>{}}}();u&&"destroy"in u&&"function"==typeof u.destroy&&i.destroyFunctions.push(u.destroy);const p=(c=o.normalize?.replace,function(){const e=new Map,t=r(c,"element");document.querySelectorAll(t).forEach(t=>{const n=t.cloneNode(!0),o=r(c,"hide");n.querySelectorAll(o).forEach(e=>{const t=c.attributes.elements.hide.primary.match(/data-hs-replace-hide/)[0],n=e.getAttribute(t);n&&n.split(" ").filter(e=>e.trim()).some(t=>e.classList.contains(t))&&e.remove()});const s=c.attributes.elements.element.primary.match(/data-hs-replace/)[0],i=t.getAttribute(s),a=n.textContent?.trim()||null,l=t.getAttribute("href");if(i&&(a||l)){const t={text:a,href:l};if(e.has(i)){const n=e.get(i);Array.isArray(n)?n.push(t):e.set(i,[n,t])}else e.set(i,t)}});const n=(new Date).getFullYear().toString(),o=["January","February","March","April","May","June","July","August","September","October","November","December"][(new Date).getMonth()];if(e.set("year",{text:n,href:null}),e.set("month",{text:o,href:null}),0===e.size)return;const s=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:t=>{const n=t.textContent||"";for(const r of e.keys())if(n.includes(`{{${r}}}`))return NodeFilter.FILTER_ACCEPT;return NodeFilter.FILTER_SKIP}}),i=[];let a;for(;a=s.nextNode();)i.push(a);i.forEach(t=>{let n=t.textContent||"",r=!1;for(const[o,s]of e.entries()){const e=`{{${o}}}`;if(n.includes(e)){let t=null;t=Array.isArray(s)?s.map(e=>e.text||e.href).filter(Boolean).join(", "):s.text||s.href,t&&(n=n.replace(new RegExp(e,"g"),t),r=!0)}}r&&(t.textContent=n)}),document.querySelectorAll("a[href]").forEach(t=>{let n=t.getAttribute("href")||"",r=!1;for(const[o,s]of e.entries()){const e=`{{${o}}}`;if(n.includes(e)){let t=null;if(Array.isArray(s)){const e=s[0];t=e.href||e.text}else{if(s.href){t=s.href,n=s.href,r=!0;break}s.text&&(t=s.text)}t&&!r&&(n=n.replace(new RegExp(e,"g"),t),r=!0)}}r&&t.setAttribute("href",n)});const l=document.querySelector("[data-hs-replace-test]");if(l){const t={};for(const[r,o]of e.entries()){const e=`{{${r}}}`;if(Array.isArray(o)){const n=o.map(e=>e.text||e.href).filter(Boolean).join(", ");t[r]={placeholder:e,value:n,type:`Array (${o.length} items)`,items:o.map(e=>e.text||e.href||"(empty)")}}else{const n=o.text||o.href||"(empty)";t[r]={placeholder:e,value:n,...o.text&&{text:o.text},...o.href&&{href:o.href}}}}const n=document.createElement("pre");n.textContent=JSON.stringify(t,null,2),l.innerHTML="",l.appendChild(document.createTextNode(`Replace Module Debug (${e.size} replacements):`)),l.appendChild(n)}}(),{result:"replace initialized",destroy:()=>{}});p&&"destroy"in p&&"function"==typeof p.destroy&&i.destroyFunctions.push(p.destroy);const h=await async function(n){const r=e(n,"source"),o=new Map,s=new Map;r.forEach(e=>{const t=e.getAttribute(n.attributes.properties.syncId),r=e.getAttribute(n.attributes.properties.syncField);t&&o.set(t,e),r&&s.set(r,e)});const i=e(n,"target");let a=0,c=0;return i.forEach(r=>{const i=r.getAttribute(n.attributes.properties.syncId),d=r.getAttribute(n.attributes.properties.syncField),u=r.getAttribute(n.attributes.properties.syncValue);let m;if(d&&u){if(m=s.get(d),!m)return void c++}else{if(!i)return void c++;if(m=o.get(i),!m)return void c++}const p=t(n,"item",r);if(!p){const e=d||i||"unknown";return void console.warn(`[sync] Target list "${e}" missing item template`)}const h="child"===p.getAttribute(n.attributes.properties.syncMode),f=t(n,"ignore",r);let y,g;if(u){const t=e(n,"item",m),r=Array.from(t).find(e=>e.getAttribute(n.attributes.properties.syncValue)===u);if(!r)return void console.warn(`[sync] No source item found with value "${u}" in field "${d}"`);y=[r]}else if(y=Array.from(e(n,"item",m)),0===y.length)return void console.warn(`[sync] Source list "${i}" has no items`);if(h){const e=p.firstElementChild;if(!e)return void console.warn(`[sync] Target list "${i}" has sync-mode="child" but item wrapper has no children`);g=e.cloneNode(!0)}else g=p.cloneNode(!0),g.removeAttribute(n.attributes.elements.item.primary.split("=")[0]);let b=!1;if(f){let e=f.nextElementSibling;for(;e;){if(e===p){b=!0;break}e=e.nextElementSibling}}if(h){for(;p.firstChild;)p.removeChild(p.firstChild);y.forEach(e=>{const t=g.cloneNode(!0);l(e,t,n),p.appendChild(t)}),p.removeAttribute(n.attributes.elements.item.primary.split("=")[0])}else{Array.from(r.children).forEach(e=>{e!==f&&e.remove()});const e=Array.from(y).map(e=>{const t=g.cloneNode(!0);return l(e,t,n),t});f?b?e.forEach(e=>{r.appendChild(e)}):e.forEach(e=>{r.insertBefore(e,f)}):e.forEach(e=>{r.appendChild(e)})}a++}),{result:`sync initialized (${a} synced, ${c} skipped)`,destroy:()=>{}}}(a.sync);h&&"destroy"in h&&"function"==typeof h.destroy&&i.destroyFunctions.push(h.destroy);const f=await m(a.dupe);return f&&"destroy"in f&&"function"==typeof f.destroy&&i.destroyFunctions.push(f.destroy),{result:"normalize initialized",destroy:()=>{i.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during cleanup:",t)}}),i.destroyFunctions.length=0}}}catch(d){throw console.error("[normalize] Initialization failed:",d),i.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during error cleanup:",t)}}),d}var c}export{h as init};
1
+ import{q as e,a as t,g as n,b as r,c as o}from"./hsfxutilsCYt-q_3u.js";function s(){return function(){const e=window.location.origin,t=e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.textContent?.trim()||""},n=t("company"),r=t("phone"),o=t("email"),s=t("city"),i=t("state"),a=t("zipcode"),c={"@context":"https://schema.org","@type":"LocalBusiness",name:n,url:e,telephone:r,email:o},l=document.querySelector('[data-hs-replace="business-logo"] img');l&&l.src&&(c.image=l.src);const d={"@type":"PostalAddress",addressLocality:s,addressRegion:i,postalCode:a,addressCountry:"US"},u=t("street-address");u&&(d.streetAddress=u),c.address=d;const m=t("business-latitude"),p=t("business-longitude");m&&p&&(c.geo={"@type":"GeoCoordinates",latitude:m,longitude:p});const h=["facebook","instagram","linkedin","pinterest","tiktok","x","youtube"].map(e=>(e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.href||""})(e)).filter(e=>e&&""!==e.trim()&&!e.includes("placeholder"));h.length>0&&(c.sameAs=h);const f=document.querySelector('[data-hs-schema="services"]');if(f){const e=f.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>e.textContent?.trim()).filter(e=>e&&""!==e);t.length>0&&(c.serviceType=t)}const y=document.querySelector('[data-hs-schema="areas"]');if(y){const e=y.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>({"@type":"City",name:e.textContent?.trim()||""})).filter(e=>e.name&&""!==e.name);t.length>0&&(c.areaServed=t)}const g=document.createElement("script");g.type="application/ld+json",g.text=JSON.stringify(c),document.head.appendChild(g);const b=document.querySelector('[data-hs-schema="breadcrumb"]')?.textContent?.trim()||"",A=window.location.pathname.split("/").filter(e=>""!==e);if(A.length>0){const t={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:e}]},n=A[0],r=n.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.itemListElement.push({"@type":"ListItem",position:2,name:r,item:e+"/"+n}),b&&t.itemListElement.push({"@type":"ListItem",position:3,name:b,item:window.location.href});const o=document.createElement("script");o.type="application/ld+json",o.text=JSON.stringify(t),document.head.appendChild(o)}if(document.querySelector('[data-hs-accordion-type="faq"]')){const e=[];if(document.querySelectorAll('[data-hs-accordion="list"]').forEach(t=>{t.querySelectorAll('[data-hs-accordion-type="faq"]').forEach(t=>{const n=t.querySelector('[data-hs-accordion="toggle"]'),r=t.querySelector('[data-hs-accordion="content"]');if(n&&r){const t=n.textContent?.trim(),o=r.innerHTML.trim();e.push({"@type":"Question",name:t,acceptedAnswer:{"@type":"Answer",text:o}})}})}),e.length>0){const t={"@context":"https://schema.org","@type":"FAQPage",mainEntity:e},n=document.createElement("script");n.type="application/ld+json",n.text=JSON.stringify(t),document.head.appendChild(n)}}const x=document.querySelector('[data-hs-schema-service="name"]'),S=document.querySelector('[data-hs-schema-service="description"]');if(x&&S){const e=x.textContent?.trim()||"",t=S.textContent?.trim()||"";if(e&&t){const n={"@context":"https://schema.org","@type":"Service",name:e,description:t},r=document.createElement("script");r.type="application/ld+json",r.text=JSON.stringify(n),document.head.appendChild(r)}}else(x||S)&&console.warn('[schema] Service page schema requires both "name" and "description" elements');const q=document.querySelector('[data-hs-schema-faq="question"]'),C=document.querySelector('[data-hs-schema-faq="answer"]'),E=document.querySelector('[data-hs-schema-faq="published"]'),w=document.querySelector('[data-hs-schema-faq="modified"]');if(q&&C&&E&&w){const e=q.textContent?.trim()||"",t=C.innerHTML.trim(),n=E.textContent?.trim()||"",r=w.textContent?.trim()||"";if(e&&t&&n&&r){const o={"@context":"https://schema.org","@type":"QAPage",mainEntity:{"@type":"Question",name:e,text:e,answerCount:1,datePublished:n,dateModified:r,acceptedAnswer:{"@type":"Answer",text:t}}},s=document.createElement("script");s.type="application/ld+json",s.text=JSON.stringify(o),document.head.appendChild(s)}}else if(q||C||E||w){const e=[];q||e.push("question"),C||e.push("answer"),E||e.push("published"),w||e.push("modified"),console.warn(`[schema] FAQ page schema missing required fields: ${e.join(", ")}`)}const v=document.querySelector('[data-hs-schema-blog="name"]'),N=document.querySelector('[data-hs-schema-blog="published"]'),$=document.querySelector('[data-hs-schema-blog="modified"]'),F=document.querySelector('[data-hs-schema-blog="summary"]'),L=document.querySelector('[data-hs-schema-blog="author-name"]'),k=document.querySelector('[data-hs-schema-blog="author-type"]');if(v&&N&&$&&F&&L&&k){const e=v.textContent?.trim()||"",n=N.textContent?.trim()||"",r=$.textContent?.trim()||"",o=F.textContent?.trim()||"",s=L.textContent?.trim()||"",i=k.textContent?.trim()||"Organization",a=document.querySelector('[data-hs-schema-blog="author-role"]'),c=document.querySelector('[data-hs-schema-blog="author-image"]'),l=a?.textContent?.trim()||"",d=c?.src||"",u=t("company"),m=document.querySelector('[data-hs-replace="business-logo"] img'),p=m?m.src:"";let h;"Person"===i?(h={"@type":"Person",name:s},l&&(h.jobTitle=l),d&&(h.image=d)):(h={"@type":"Organization",name:s},p&&(h.logo=p));const f={"@context":"https://schema.org","@type":"BlogPosting",headline:e,description:o,datePublished:n,dateModified:r,author:h,publisher:{"@type":"Organization",name:u||s,logo:{"@type":"ImageObject",url:p}},mainEntityOfPage:{"@type":"WebPage","@id":window.location.href}},y=document.createElement("script");y.type="application/ld+json",y.text=JSON.stringify(f),document.head.appendChild(y)}else if(v||N||$||F||L||k){const e=[];v||e.push("name"),N||e.push("published"),$||e.push("modified"),F||e.push("summary"),L||e.push("author-name"),k||e.push("author-type"),console.warn(`[schema] Blog page schema missing required fields: ${e.join(", ")}`)}}(),{result:"schema initialized",destroy:()=>{}}}function i(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r;for(;r=n.nextNode();)r.nodeValue?.trim()&&t.push(r);return t}function a(e){const t=[];return e.hasAttribute("href")&&t.push(e),t.push(...Array.from(e.querySelectorAll("[href]"))),t}function c(e){if(e.hasAttribute("src")){if(e.getAttribute("src"))return e}const t=e.querySelector("[src]");if(t){if(t.getAttribute("src"))return t}return null}function l(e,t,n){if(function(e,t){const n=t.attributes.properties.syncField;return null!==e.querySelector(`[${n}]`)}(t,n))return void function(e,t,n){const r=n.attributes.properties.syncField;e.querySelectorAll(`[${r}]`).forEach(e=>{const n=e.getAttribute(r),o=t.querySelector(`[${r}="${n}"]`);if(!o)return;const s=c(e),a=c(o);if(s&&a){const e=s.getAttribute("src");e&&a.setAttribute("src",e)}else if(e.hasAttribute("href")&&o.hasAttribute("href")){const t=e.getAttribute("href");t&&o.setAttribute("href",t)}else{const t=i(e),n=t.length>0?t[0].nodeValue:e.textContent.trim();if(n){const e=i(o);e.length>0?e[0].nodeValue=n:o.textContent=n}}})}(e,t,n);const r=i(e),o=r.length>0?r[0].nodeValue:"",s=a(e),l=s.length>0?s[0].getAttribute("href"):"";if(o){i(t).forEach(e=>{e.nodeValue=o})}if(l){a(t).forEach(e=>{e.setAttribute("href",l)})}}const d="hs-dupe-no-transition";let u=!1;async function m(t){!function(){if(u)return;const e=document.createElement("style");e.textContent=`\n .${d},\n .${d} * {\n transition: none !important;\n animation: none !important;\n }\n `,document.head.appendChild(e),u=!0}();const n={processedElements:[]};return e(t,"wrapper").forEach(e=>{const t=e.getAttribute("data-hs-dupe");if(!t||"child"!==t&&"self"!==t)return void console.warn('[dupe] Invalid mode. Use "child" or "self":',e);const r=e.getAttribute("data-hs-dupe-count");let o=r?parseInt(r,10):1;(isNaN(o)||o<1)&&(console.warn("[dupe] Invalid count, using default of 1:",e),o=1),o>20&&(console.warn(`[dupe] Count of ${o} exceeds maximum of 20. Capping at 20.`),o=20);const s={hidden:e.hasAttribute("data-hs-dupe-hidden"),noSelect:e.hasAttribute("data-hs-dupe-no-select")};"child"===t?function(e,t,n,r){const o=e.children[0];if(!o)return;const s=[];for(let i=0;i<t;i++){const t=o.cloneNode(!0);t.classList.add(d),p(t,n),e.appendChild(t),s.push(t),t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}r.processedElements.push({element:e,mode:"child",clones:s})}(e,o,s,n):"self"===t&&function(e,t,n,r){const o=e.parentNode;if(!o)return void console.warn("[dupe] Element has no parent, cannot duplicate self:",e);const s=[];let i=e;for(let a=0;a<t;a++){const t=e.cloneNode(!0);t.classList.add(d),t.removeAttribute("data-hs-dupe"),t.removeAttribute("data-hs-dupe-count"),t.removeAttribute("data-hs-dupe-hidden"),t.removeAttribute("data-hs-dupe-no-select"),p(t,n),i.nextSibling?o.insertBefore(t,i.nextSibling):o.appendChild(t),s.push(t),i=t,t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}r.processedElements.push({element:e,mode:"self",clones:s})}(e,o,s,n)}),{result:`dupe processed ${n.processedElements.length} elements`,destroy:()=>{}}}function p(e,t){if(t.hidden&&e.setAttribute("aria-hidden","true"),t.noSelect){const t=e;t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.msUserSelect="none"}}async function h(){const i={destroyFunctions:[]},a=o.normalize;try{const d=s();d&&"destroy"in d&&"function"==typeof d.destroy&&i.destroyFunctions.push(d.destroy);const u=(c=o.normalize?.replace,function(){const e=new Map,t=r(c,"element");document.querySelectorAll(t).forEach(t=>{const n=t.cloneNode(!0),o=r(c,"hide");n.querySelectorAll(o).forEach(e=>{const t=c.attributes.elements.hide.primary.match(/data-hs-replace-hide/)[0],n=e.getAttribute(t);n&&n.split(" ").filter(e=>e.trim()).some(t=>e.classList.contains(t))&&e.remove()});const s=c.attributes.elements.element.primary.match(/data-hs-replace/)[0],i=t.getAttribute(s),a=n.textContent?.trim()||null,l=t.getAttribute("href");if(i&&(a||l)){const t={text:a,href:l};if(e.has(i)){const n=e.get(i);Array.isArray(n)?n.push(t):e.set(i,[n,t])}else e.set(i,t)}});const n=(new Date).getFullYear().toString(),o=["January","February","March","April","May","June","July","August","September","October","November","December"][(new Date).getMonth()];if(e.set("year",{text:n,href:null}),e.set("month",{text:o,href:null}),0===e.size)return;const s=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:t=>{const n=t.textContent||"";for(const r of e.keys())if(n.includes(`{{${r}}}`))return NodeFilter.FILTER_ACCEPT;return NodeFilter.FILTER_SKIP}}),i=[];let a;for(;a=s.nextNode();)i.push(a);i.forEach(t=>{let n=t.textContent||"",r=!1;for(const[o,s]of e.entries()){const e=`{{${o}}}`;if(n.includes(e)){let t=null;t=Array.isArray(s)?s.map(e=>e.text||e.href).filter(Boolean).join(", "):s.text||s.href,t&&(n=n.replace(new RegExp(e,"g"),t),r=!0)}}r&&(t.textContent=n)}),document.querySelectorAll("a[href]").forEach(t=>{let n=t.getAttribute("href")||"",r=!1;for(const[o,s]of e.entries()){const e=`{{${o}}}`;if(n.includes(e)){let t=null;if(Array.isArray(s)){const e=s[0];t=e.href||e.text}else{if(s.href){t=s.href,n=s.href,r=!0;break}s.text&&(t=s.text)}t&&!r&&(n=n.replace(new RegExp(e,"g"),t),r=!0)}}r&&t.setAttribute("href",n)});const l=document.querySelector("[data-hs-replace-test]");if(l){const t={};for(const[r,o]of e.entries()){const e=`{{${r}}}`;if(Array.isArray(o)){const n=o.map(e=>e.text||e.href).filter(Boolean).join(", ");t[r]={placeholder:e,value:n,type:`Array (${o.length} items)`,items:o.map(e=>e.text||e.href||"(empty)")}}else{const n=o.text||o.href||"(empty)";t[r]={placeholder:e,value:n,...o.text&&{text:o.text},...o.href&&{href:o.href}}}}const n=document.createElement("pre");n.textContent=JSON.stringify(t,null,2),l.innerHTML="",l.appendChild(document.createTextNode(`Replace Module Debug (${e.size} replacements):`)),l.appendChild(n)}}(),{result:"replace initialized",destroy:()=>{}});u&&"destroy"in u&&"function"==typeof u.destroy&&i.destroyFunctions.push(u.destroy);const p=await async function(n){const r=e(n,"source"),o=new Map,s=new Map;r.forEach(e=>{const t=e.getAttribute(n.attributes.properties.syncId),r=e.getAttribute(n.attributes.properties.syncField);t&&o.set(t,e),r&&s.set(r,e)});const i=e(n,"target");let a=0,c=0;return i.forEach(r=>{const i=r.getAttribute(n.attributes.properties.syncId),d=r.getAttribute(n.attributes.properties.syncField),u=r.getAttribute(n.attributes.properties.syncValue);let m;if(d&&u){if(m=s.get(d),!m)return void c++}else{if(!i)return void c++;if(m=o.get(i),!m)return void c++}const p=t(n,"item",r);if(!p){const e=d||i||"unknown";return void console.warn(`[sync] Target list "${e}" missing item template`)}const h="child"===p.getAttribute(n.attributes.properties.syncMode),f=t(n,"ignore",r);let y,g;if(u){const t=e(n,"item",m),r=Array.from(t).find(e=>e.getAttribute(n.attributes.properties.syncValue)===u);if(!r)return void console.warn(`[sync] No source item found with value "${u}" in field "${d}"`);y=[r]}else if(y=Array.from(e(n,"item",m)),0===y.length)return void console.warn(`[sync] Source list "${i}" has no items`);if(h){const e=p.firstElementChild;if(!e)return void console.warn(`[sync] Target list "${i}" has sync-mode="child" but item wrapper has no children`);g=e.cloneNode(!0)}else g=p.cloneNode(!0),g.removeAttribute(n.attributes.elements.item.primary.split("=")[0]);let b=!1;if(f){let e=f.nextElementSibling;for(;e;){if(e===p){b=!0;break}e=e.nextElementSibling}}if(h){for(;p.firstChild;)p.removeChild(p.firstChild);y.forEach(e=>{const t=g.cloneNode(!0);l(e,t,n),p.appendChild(t)}),p.removeAttribute(n.attributes.elements.item.primary.split("=")[0])}else{Array.from(r.children).forEach(e=>{e!==f&&e.remove()});const e=Array.from(y).map(e=>{const t=g.cloneNode(!0);return l(e,t,n),t});f?b?e.forEach(e=>{r.appendChild(e)}):e.forEach(e=>{r.insertBefore(e,f)}):e.forEach(e=>{r.appendChild(e)})}a++}),{result:`sync initialized (${a} synced, ${c} skipped)`,destroy:()=>{}}}(a.sync);p&&"destroy"in p&&"function"==typeof p.destroy&&i.destroyFunctions.push(p.destroy);const h=await m(a.dupe);h&&"destroy"in h&&"function"==typeof h.destroy&&i.destroyFunctions.push(h.destroy);const f=await async function(){const t={processedWrappers:[]};return e(n.clickable,"wrapper").forEach(e=>{const n=e.querySelector(":scope > button"),r=e.querySelector(":scope > a");if(!n||!r)return;const o=r.getAttribute("href");let s,i;o&&""!==o&&"#"!==o?(s=r,i=n):(s=n,i=r);const a="button"===s.getAttribute("data-hs-clickable");a||s.setAttribute("data-hs-clickable","button"),i.remove(),t.processedWrappers.push({wrapper:e,keptElement:s,wasLink:s===r,addedAttribute:!a})}),{result:`clickable processed ${t.processedWrappers.length} wrappers`,destroy:()=>{}}}();return f&&"destroy"in f&&"function"==typeof f.destroy&&i.destroyFunctions.push(f.destroy),{result:"normalize initialized",destroy:()=>{i.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during cleanup:",t)}}),i.destroyFunctions.length=0}}}catch(d){throw console.error("[normalize] Initialization failed:",d),i.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during error cleanup:",t)}}),d}var c}export{h as init};
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/hsfxnormalizeCNlg71Ja.js","assets/hsfxutilsCYt-q_3u.js","assets/hsfxdefaultUK8R1YLa.js","assets/hsfxanimationsCw1kkPqK.js"])))=>i.map(i=>d[i]);
2
- import{c as e}from"./assets/hsfxutilsCYt-q_3u.js";const t={},s=function(e,s,o){let a=Promise.resolve();if(s&&s.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),r=o?.nonce||o?.getAttribute("nonce");a=e(s.map(e=>{if((e=function(e){return"https://cdn.jsdelivr.net/npm/@hsfx/attr@2.0.2/dist/"+e}(e))in t)return;t[e]=!0;const s=e.endsWith(".css"),o=s?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${o}`))return;const a=document.createElement("link");return a.rel=s?"stylesheet":"modulepreload",s||(a.as="script"),a.crossOrigin="",a.href=e,r&&a.setAttribute("nonce",r),document.head.appendChild(a),s?new Promise((t,s)=>{a.addEventListener("load",t),a.addEventListener("error",()=>s(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function r(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return a.then(t=>{for(const e of t||[])"rejected"===e.status&&r(e.reason);return e().catch(r)})},o=e._global.apiName;(async()=>{if(window[o]&&!Array.isArray(window[o])&&window[o].loaded)return;const t=Array.isArray(window[o])?window[o]:[],a={normalize:()=>s(()=>import("./assets/hsfxnormalizeCNlg71Ja.js"),__vite__mapDeps([0,1])),default:()=>s(()=>import("./assets/hsfxdefaultUK8R1YLa.js"),__vite__mapDeps([2,1])),animations:()=>s(()=>import("./assets/hsfxanimationsCw1kkPqK.js"),__vite__mapDeps([3,1]))};let r=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===r.length&&(r=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,s=import.meta.url,o=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],a=s.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return o&&a&&o.split("@")[0]===a.split("@")[0]}));const n={isSPA:r.some(e=>"true"===e.getAttribute("data-hs-spa"))},i={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default","animations"],parallel:!0}},l=async e=>{const t=window[o];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const s=t.modules[e]||{};let r;t.modules[e]=s,s.loading=new Promise((e,t)=>{s.resolve=e,s.reject=t});try{const{init:o}=await a[e](),n=await o()||{};r=n.destroy;const i=n.result;return s.destroy=()=>{r?.(),t.process.delete(e)},s.restart=()=>{s.destroy?.(),t.load(e)},s.resolve?.(i),delete s.resolve,delete s.reject,i}catch(n){throw r?.(),s.reject?.(n),t.process.delete(e),n}},d=async e=>{const t=i[e];if(t.parallel){const e=t.modules.map(e=>l(e));await Promise.allSettled(e)}else for(const s of t.modules)await l(s)},c=async()=>{await Promise.allSettled([a.normalize(),a.default(),a.animations()]),await d("normalize"),await d("default"),(()=>{const e=new CustomEvent(`${o}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:e}=await s(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCYt-q_3u.js").then(e=>e.r);return{initScrollAnimations:e}},[]);e().catch(e=>{console.error(`[${o}] Scroll animations failed to initialize:`,e)})},u=[];window[o]={scripts:r,settings:n,modules:{},process:new Set,load:l,loaded:!1,push(...e){for(const[t,s]of e)"function"==typeof s?this.modules[t]?.loading?.then(s):this.load(t)},destroy(){for(const e in this.modules)this.modules[e]?.destroy?.()},async reinitialize(){this.loaded=!1,this.destroy(),this.modules={},this.process=new Set,await this.scanForEmbedModules(),await c(),this.loaded=!0},async scanForEmbedModules(){document.querySelectorAll(".w-embed").forEach(e=>{e.querySelectorAll("script[data-hs-module]").forEach(e=>{const t=e.getAttribute("data-hs-module-type"),s=e.getAttribute("data-hs-module");if(t&&s){const e=`data-hs-${t}-${s}`;a[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():u.push(e))},status(e){return e?{loaded:!!this.modules[e],loading:this.process.has(e)}:{loaded:Object.keys(this.modules),loading:[...this.process],phases:i}}};(async()=>{window[o].push(...t),await c(),window[o].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),u.forEach(e=>{try{e()}catch{}}),u.length=0})().catch(()=>{})})();export{s as _};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/hsfxnormalizeCgvVd0bo.js","assets/hsfxutilsCYt-q_3u.js","assets/hsfxdefaultUK8R1YLa.js","assets/hsfxanimationsCw1kkPqK.js"])))=>i.map(i=>d[i]);
2
+ import{c as e}from"./assets/hsfxutilsCYt-q_3u.js";const t={},s=function(e,s,o){let r=Promise.resolve();if(s&&s.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");r=e(s.map(e=>{if((e=function(e){return"https://cdn.jsdelivr.net/npm/@hsfx/attr@2.0.4/dist/"+e}(e))in t)return;t[e]=!0;const s=e.endsWith(".css"),o=s?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${o}`))return;const r=document.createElement("link");return r.rel=s?"stylesheet":"modulepreload",s||(r.as="script"),r.crossOrigin="",r.href=e,a&&r.setAttribute("nonce",a),document.head.appendChild(r),s?new Promise((t,s)=>{r.addEventListener("load",t),r.addEventListener("error",()=>s(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function a(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})},o=e._global.apiName;(async()=>{if(window[o]&&!Array.isArray(window[o])&&window[o].loaded)return;const t=Array.isArray(window[o])?window[o]:[],r={normalize:()=>s(()=>import("./assets/hsfxnormalizeCgvVd0bo.js"),__vite__mapDeps([0,1])),default:()=>s(()=>import("./assets/hsfxdefaultUK8R1YLa.js"),__vite__mapDeps([2,1])),animations:()=>s(()=>import("./assets/hsfxanimationsCw1kkPqK.js"),__vite__mapDeps([3,1]))};let a=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===a.length&&(a=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,s=import.meta.url,o=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],r=s.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return o&&r&&o.split("@")[0]===r.split("@")[0]}));const n={isSPA:a.some(e=>"true"===e.getAttribute("data-hs-spa"))},l={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default"],parallel:!0}},i=async e=>{const t=window[o];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const s=t.modules[e]||{};let a;t.modules[e]=s,s.loading=new Promise((e,t)=>{s.resolve=e,s.reject=t});try{const{init:o}=await r[e](),n=await o()||{};a=n.destroy;const l=n.result;return s.destroy=()=>{a?.(),t.process.delete(e)},s.restart=()=>{s.destroy?.(),t.load(e)},s.resolve?.(l),delete s.resolve,delete s.reject,l}catch(n){throw a?.(),s.reject?.(n),t.process.delete(e),n}},d=async e=>{const t=l[e];if(t.parallel){const e=t.modules.map(e=>i(e));await Promise.allSettled(e)}else for(const s of t.modules)await i(s)},c=async()=>{await Promise.allSettled([r.normalize(),r.default(),r.animations()]),await d("normalize");const e=d("default"),t=i("animations");await e,(()=>{const e=new CustomEvent(`${o}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:a}=await s(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCYt-q_3u.js").then(e=>e.r);return{initScrollAnimations:e}},[]);Promise.all([t,a()]).catch(e=>{console.error(`[${o}] Phase 3 (animations + scroll trigger) failed:`,e)})},u=[];window[o]={scripts:a,settings:n,modules:{},process:new Set,load:i,loaded:!1,push(...e){for(const[t,s]of e)"function"==typeof s?this.modules[t]?.loading?.then(s):this.load(t)},destroy(){for(const e in this.modules)this.modules[e]?.destroy?.()},async reinitialize(){this.loaded=!1,this.destroy(),this.modules={},this.process=new Set,await this.scanForEmbedModules(),await c(),this.loaded=!0},async scanForEmbedModules(){document.querySelectorAll(".w-embed").forEach(e=>{e.querySelectorAll("script[data-hs-module]").forEach(e=>{const t=e.getAttribute("data-hs-module-type"),s=e.getAttribute("data-hs-module");if(t&&s){const e=`data-hs-${t}-${s}`;r[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():u.push(e))},status(e){return e?{loaded:!!this.modules[e],loading:this.process.has(e)}:{loaded:Object.keys(this.modules),loading:[...this.process],phases:l}}};(async()=>{window[o].push(...t),await c(),window[o].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),u.forEach(e=>{try{e()}catch{}}),u.length=0})().catch(()=>{})})();export{s as _};
package/dist/main.js.br CHANGED
Binary file
package/dist/main.js.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsfx/attr",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "license": "UNLICENSED",