@devalon.dev/credits 1.0.1 → 1.0.2

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
@@ -1,6 +1,6 @@
1
1
  # @devalon.dev/credits
2
2
 
3
- Add Devalon technology-partner attribution to a Next.js, React or Vite site. JSON-LD by default, with an optional visible credit link, server headers and generated `llms.txt` / `humans.txt`. No client-side JavaScript, no hydration cost.
3
+ Add Devalon technology-partner attribution to a Next.js, React or Vite site. JSON-LD by default, with an optional visible credit link, server headers and generated `llms.txt` / `humans.txt`. No client-side JavaScript, no hydration cost. The optional `/signals` entry is a separate client-side tracker loader for the tracking tools Devalon delivers.
4
4
 
5
5
  ## Install
6
6
 
@@ -20,6 +20,7 @@ yarn add @devalon.dev/credits
20
20
  | `@devalon.dev/credits/next` | Next.js Server Components + `Metadata` helper |
21
21
  | `@devalon.dev/credits/react` | React components, server HTML helpers, headers, agent files |
22
22
  | `@devalon.dev/credits/vite` | Build-time injection for CSR apps |
23
+ | `@devalon.dev/credits/signals` | Client-side tracker loader (Meta Pixel first, CAPI dedup) |
23
24
 
24
25
  Maintainers: the release guide lives in the repository at `docs/publishing.md` (not included in the npm tarball). Put `NPM_TOKEN=npm_xxx...` in `./.env` (gitignored), then `make` builds, dry-runs, publishes and verifies in one step (`make release` is an alias).
25
26
 
@@ -136,6 +137,25 @@ The rule is the same as for Next.js: **the credit must be in the HTML the server
136
137
 
137
138
  Both guide sets cover how to use the package in Next.js or React/Vite. They do not explain the internal Schema.org graph, the service catalog, or the library architecture.
138
139
 
140
+ ## Signals (tracking loaders)
141
+
142
+ The credit metadata above is server-rendered and JavaScript-free. **Signals is
143
+ the deliberate exception**: it loads the tracking tools Devalon installs.
144
+ Meta Pixel is the first one available.
145
+
146
+ ```tsx
147
+ import { DevalonSignal, signal } from "@devalon.dev/credits/signals";
148
+
149
+ // Load the pixel once, in your layout:
150
+ <DevalonSignal pixelId="1683475309995701" />
151
+
152
+ // Track any action:
153
+ signal("HeroCtaClick", { button_id: "hero" }, { debug: true });
154
+ ```
155
+
156
+ Setup for Next.js, React, Vite, event names, debug logs, CAPI deduplication and
157
+ tips are all in one guide: [Signals — Meta Pixel usage](docs/signals/01-meta-pixel.md).
158
+
139
159
  ## Two rules that matter most
140
160
 
141
161
  1. `site_url` is the canonical site root and stays the same for every language. `page_url` is the localized page URL.
@@ -0,0 +1 @@
1
+ function r(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}export{r as a};
@@ -1,16 +1,16 @@
1
- import{a as d,b as g,e as h,i as v,j as f,m as y,r as k}from"./chunk-SHIXBOQB.mjs";function u(e){let n;try{n=new URL(e)}catch{throw new TypeError("site_url must be an absolute HTTP(S) URL.")}if(n.protocol!=="https:"&&n.protocol!=="http:")throw new TypeError("site_url must be an absolute HTTP(S) URL.");return n.hash="",n.search="",n.pathname=n.pathname.replace(/\/+$/,"")||"/",n.toString().replace(/\/$/,"")}var E="<!-- devalon:start -->",L="<!-- devalon:end -->",x="/* devalon:start */",m="/* devalon:end */";function w(e){return new Response(e,{headers:{"Content-Type":"text/plain; charset=utf-8"}})}function N(e){let n=f,t=new Set;for(let r of e){let o=n[r]??r,i=v[o];if(!i)throw new TypeError(`Unknown Devalon service: ${String(r)}`);t.add(i.name)}return[...t]}function T(e){let n=N(e.services??[]),t=[E,"## Credits","",`Built and maintained by [Devalon](${d}), an AI & software development studio.`];return n.length>0&&t.push(`Services: ${n.join(", ")}.`),t.push(L),t.join(`
2
- `)}function b(e){let n=e.site_name.trim();if(!n)throw new TypeError("site_name must not be empty.");let t=e.description?.trim()??`Official website of ${n}.`;return[`# ${n}`,"",`> ${t}`,"",`- Canonical: ${u(e.site_url)}`,"",T(e),""].join(`
1
+ import{a as d,b as g,e as h,i as v,j as f,m as y,r as k}from"./chunk-SHIXBOQB.mjs";import{a as E}from"./chunk-IJASKDEW.mjs";function u(e){let n;try{n=new URL(e)}catch{throw new TypeError("site_url must be an absolute HTTP(S) URL.")}if(n.protocol!=="https:"&&n.protocol!=="http:")throw new TypeError("site_url must be an absolute HTTP(S) URL.");return n.hash="",n.search="",n.pathname=n.pathname.replace(/\/+$/,"")||"/",n.toString().replace(/\/$/,"")}var L="<!-- devalon:start -->",w="<!-- devalon:end -->",x="/* devalon:start */",m="/* devalon:end */";function T(e){return new Response(e,{headers:{"Content-Type":"text/plain; charset=utf-8"}})}function N(e){let n=f,t=new Set;for(let r of e){let o=n[r]??r,i=v[o];if(!i)throw new TypeError(`Unknown Devalon service: ${String(r)}`);t.add(i.name)}return[...t]}function b(e){let n=N(e.services??[]),t=[L,"## Credits","",`Built and maintained by [Devalon](${d}), an AI & software development studio.`];return n.length>0&&t.push(`Services: ${n.join(", ")}.`),t.push(w),t.join(`
2
+ `)}function R(e){let n=e.site_name.trim();if(!n)throw new TypeError("site_name must not be empty.");let t=e.description?.trim()??`Official website of ${n}.`;return[`# ${n}`,"",`> ${t}`,"",`- Canonical: ${u(e.site_url)}`,"",b(e),""].join(`
3
3
  `)}function I(e,n,t,r){let o=e.indexOf(n),i=e.indexOf(t);if(o!==-1&&i!==-1&&i>o)return e.slice(0,o)+r+e.slice(i+t.length);let s=e.trimEnd();return s?`${s}
4
4
 
5
5
  ${r}
6
6
  `:`${r}
7
- `}function R(e,n){return I(e,E,L,T(n))}function Q(e){return w(e.source?.trim()?R(e.source,e):b(e))}function D(e){return[x,"Developer: Devalon",`URL: ${d}`,m].join(`
8
- `)}function S(e){let n=e.site_name.trim();if(!n)throw new TypeError("site_name must not be empty.");return["/* TEAM */",D(e),"","/* SITE */",`Name: ${n}`,`URL: ${u(e.site_url)}`,""].join(`
9
- `)}function H(e,n){let t=D(n),r=e.indexOf(x),o=e.indexOf(m);if(r!==-1&&o!==-1&&o>r)return e.slice(0,r)+t+e.slice(o+m.length);let i="/* TEAM */",s=e.indexOf(i);if(s!==-1){let l=s+i.length,a=e.indexOf("/*",l),_=a===-1?e.length:a,p=e.slice(0,_).trimEnd(),O=e.slice(_);return`${p}
7
+ `}function D(e,n){return I(e,L,w,b(n))}function Q(e){return T(e.source?.trim()?D(e.source,e):R(e))}function S(e){return[x,"Developer: Devalon",`URL: ${d}`,m].join(`
8
+ `)}function A(e){let n=e.site_name.trim();if(!n)throw new TypeError("site_name must not be empty.");return["/* TEAM */",S(e),"","/* SITE */",`Name: ${n}`,`URL: ${u(e.site_url)}`,""].join(`
9
+ `)}function H(e,n){let t=S(n),r=e.indexOf(x),o=e.indexOf(m);if(r!==-1&&o!==-1&&o>r)return e.slice(0,r)+t+e.slice(o+m.length);let i="/* TEAM */",s=e.indexOf(i);if(s!==-1){let l=s+i.length,a=e.indexOf("/*",l),_=a===-1?e.length:a,p=e.slice(0,_).trimEnd(),O=e.slice(_);return`${p}
10
10
  ${t}
11
11
 
12
12
  ${O.trimStart()}`}let c=e.trimEnd();return c?`${c}
13
13
 
14
14
  ${t}
15
15
  `:`${t}
16
- `}function W(e){return w(e.source?.trim()?H(e.source,e):S(e))}function Z(e){return{"llms.txt":e.source?.trim()?R(e.source,e):b(e),"humans.txt":S(e)}}var A={en:"Designed and built by",ro:"Proiectat \u0219i realizat de",ru:"\u0414\u0438\u0437\u0430\u0439\u043D \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u043E\u0442",de:"Entworfen und entwickelt von",da:"Designet og udviklet af",fr:"Con\xE7u et d\xE9velopp\xE9 par",es:"Dise\xF1ado y desarrollado por"},V="Devalon",j=["NEXT_PUBLIC_SITE_URL","SITE_URL","VITE_SITE_URL","VERCEL_PROJECT_PRODUCTION_URL","CF_PAGES_URL","VERCEL_URL"];function P(){return globalThis.process?.env??{}}function z(e){if(!e)return;let n=e.trim();if(!n)return;let t=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;try{let r=new URL(t);return r.protocol!=="https:"&&r.protocol!=="http:"||!r.hostname?void 0:`${r.protocol}//${r.hostname}`}catch{return}}function X(e){for(let n of j){let t=z(e[n]);if(t)return t}}function B(e){let n;try{n=new URL(e)}catch{throw new TypeError("site_url must be an absolute HTTP(S) URL.")}if(n.protocol!=="https:"&&n.protocol!=="http:")throw new TypeError("site_url must be an absolute HTTP(S) URL.");return n.hostname.replace(/^www\./,"")}function $(e){let{site_url:n,locale:t="en",sentence:r,anchor:o=V,utm:i=!0}=e;if(!(t in A))throw new TypeError(`Unsupported Devalon backlink locale: ${String(t)}`);let s=(r??A[t]).trim(),c=o.trim();if(!s)throw new TypeError("sentence must not be empty.");if(!c)throw new TypeError("anchor must not be empty.");let l=d;if(i&&n){let a=B(n);l=`${d}/?utm_source=${encodeURIComponent(a)}&utm_medium=credit&utm_campaign=devalon-credits`}return{text:s,link_text:c,href:l}}function te(e,n=P()){if(e.site_url)return $(e);let t=X(n);return $(t?{...e,site_url:t}:e)}function M(e){let t=f[e]??e;if(!(t in v))throw new TypeError(`Unknown Devalon service: ${String(e)}`);return t}function G(e){let n=new Set;for(let t of e){let r=y[t];if(!r)throw new TypeError(`Unknown Devalon contribution: ${String(t)}`);n.add(r.relationship)}return[...n]}function C(e){let{site_url:n,services:t=[],contributions:r=["development","engineering"],locale:o}=e,i=u(n),s=[...new Set(t.map(M))],c=G(r);if(o!==void 0&&!h.includes(o))throw new TypeError(`Unsupported Devalon locale: ${String(o)}`);let l=[{key:"X-Devalon-Creator",value:"Devalon"},{key:"X-Devalon-Creator-Url",value:d},{key:"X-Devalon-Creator-Id",value:g},{key:"X-Devalon-Project",value:i},{key:"X-Built-By",value:`Devalon (${d})`},{key:"Link",value:`<${d}>; rel="author"`}];s.length>0&&l.push({key:"X-Devalon-Services",value:s.join(", ")});let a=[...new Set(r)];return a.length>0&&l.push({key:"X-Devalon-Contributions",value:a.join(", ")}),c.length>0&&l.push({key:"X-Devalon-Relationships",value:c.join(", ")}),o&&l.push({key:"X-Devalon-Locale",value:o}),l}function se(e){return(n,t,r)=>{let{localeFromPath:o,...i}=e,s=i.locale;if(!s&&o?.length){let a=(n.url?.split("?")[0]??"").split("/")[1];a&&o.includes(a)&&(s=a)}let c=C(s?{...i,locale:s}:i);for(let{key:l,value:a}of c){if(l.toLowerCase()==="link"){let _=t.getHeader("Link")??t.getHeader("link"),p=Array.isArray(_)?_.join(", "):typeof _=="string"?_:"";t.setHeader("Link",p?`${p.replace(/,\s*$/,"")}, ${a}`:a);continue}t.setHeader(l,a)}r()}}function ae(e,n){for(let{key:t,value:r}of C(n)){if(t.toLowerCase()==="link"){let o=e.headers.get("link");e.headers.set("link",o?`${o.replace(/,\s*$/,"")}, ${r}`:r);continue}e.headers.set(t,r)}return e}function U(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function F(e){let n=JSON.stringify(e);if(n===void 0)throw new TypeError("Devalon JSON-LD could not be serialized.");return n.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function K(e){return F(k(e))}function ue(e){let{nonce:n,...t}=e;return`<script type="application/ld+json"${n?` nonce="${U(n)}"`:""}>${K(t)}</script>`}export{T as a,b,R as c,Q as d,D as e,S as f,H as g,W as h,Z as i,A as j,V as k,P as l,X as m,$ as n,te as o,C as p,se as q,ae as r,U as s,K as t,ue as u};
16
+ `}function W(e){return T(e.source?.trim()?H(e.source,e):A(e))}function Z(e){return{"llms.txt":e.source?.trim()?D(e.source,e):R(e),"humans.txt":A(e)}}var $={en:"Designed and built by",ro:"Proiectat \u0219i realizat de",ru:"\u0414\u0438\u0437\u0430\u0439\u043D \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u043E\u0442",de:"Entworfen und entwickelt von",da:"Designet og udviklet af",fr:"Con\xE7u et d\xE9velopp\xE9 par",es:"Dise\xF1ado y desarrollado por"},V="Devalon",j=["NEXT_PUBLIC_SITE_URL","SITE_URL","VITE_SITE_URL","VERCEL_PROJECT_PRODUCTION_URL","CF_PAGES_URL","VERCEL_URL"];function P(){return globalThis.process?.env??{}}function z(e){if(!e)return;let n=e.trim();if(!n)return;let t=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;try{let r=new URL(t);return r.protocol!=="https:"&&r.protocol!=="http:"||!r.hostname?void 0:`${r.protocol}//${r.hostname}`}catch{return}}function X(e){for(let n of j){let t=z(e[n]);if(t)return t}}function B(e){let n;try{n=new URL(e)}catch{throw new TypeError("site_url must be an absolute HTTP(S) URL.")}if(n.protocol!=="https:"&&n.protocol!=="http:")throw new TypeError("site_url must be an absolute HTTP(S) URL.");return n.hostname.replace(/^www\./,"")}function C(e){let{site_url:n,locale:t="en",sentence:r,anchor:o=V,utm:i=!0}=e;if(!(t in $))throw new TypeError(`Unsupported Devalon backlink locale: ${String(t)}`);let s=(r??$[t]).trim(),c=o.trim();if(!s)throw new TypeError("sentence must not be empty.");if(!c)throw new TypeError("anchor must not be empty.");let l=d;if(i&&n){let a=B(n);l=`${d}/?utm_source=${encodeURIComponent(a)}&utm_medium=credit&utm_campaign=devalon-credits`}return{text:s,link_text:c,href:l}}function te(e,n=P()){if(e.site_url)return C(e);let t=X(n);return C(t?{...e,site_url:t}:e)}function M(e){let t=f[e]??e;if(!(t in v))throw new TypeError(`Unknown Devalon service: ${String(e)}`);return t}function G(e){let n=new Set;for(let t of e){let r=y[t];if(!r)throw new TypeError(`Unknown Devalon contribution: ${String(t)}`);n.add(r.relationship)}return[...n]}function U(e){let{site_url:n,services:t=[],contributions:r=["development","engineering"],locale:o}=e,i=u(n),s=[...new Set(t.map(M))],c=G(r);if(o!==void 0&&!h.includes(o))throw new TypeError(`Unsupported Devalon locale: ${String(o)}`);let l=[{key:"X-Devalon-Creator",value:"Devalon"},{key:"X-Devalon-Creator-Url",value:d},{key:"X-Devalon-Creator-Id",value:g},{key:"X-Devalon-Project",value:i},{key:"X-Built-By",value:`Devalon (${d})`},{key:"Link",value:`<${d}>; rel="author"`}];s.length>0&&l.push({key:"X-Devalon-Services",value:s.join(", ")});let a=[...new Set(r)];return a.length>0&&l.push({key:"X-Devalon-Contributions",value:a.join(", ")}),c.length>0&&l.push({key:"X-Devalon-Relationships",value:c.join(", ")}),o&&l.push({key:"X-Devalon-Locale",value:o}),l}function se(e){return(n,t,r)=>{let{localeFromPath:o,...i}=e,s=i.locale;if(!s&&o?.length){let a=(n.url?.split("?")[0]??"").split("/")[1];a&&o.includes(a)&&(s=a)}let c=U(s?{...i,locale:s}:i);for(let{key:l,value:a}of c){if(l.toLowerCase()==="link"){let _=t.getHeader("Link")??t.getHeader("link"),p=Array.isArray(_)?_.join(", "):typeof _=="string"?_:"";t.setHeader("Link",p?`${p.replace(/,\s*$/,"")}, ${a}`:a);continue}t.setHeader(l,a)}r()}}function ae(e,n){for(let{key:t,value:r}of U(n)){if(t.toLowerCase()==="link"){let o=e.headers.get("link");e.headers.set("link",o?`${o.replace(/,\s*$/,"")}, ${r}`:r);continue}e.headers.set(t,r)}return e}function F(e){let n=JSON.stringify(e);if(n===void 0)throw new TypeError("Devalon JSON-LD could not be serialized.");return n.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function K(e){return F(k(e))}function _e(e){let{nonce:n,...t}=e;return`<script type="application/ld+json"${n?` nonce="${E(n)}"`:""}>${K(t)}</script>`}export{b as a,R as b,D as c,Q as d,S as e,A as f,H as g,W as h,Z as i,$ as j,V as k,P as l,X as m,C as n,te as o,U as p,se as q,ae as r,K as s,_e as t};
@@ -1,4 +1,4 @@
1
- import{l as f,o as k,s as l,u as p}from"./chunk-NG7NWZWD.mjs";import{q as d}from"./chunk-SHIXBOQB.mjs";var i="<!-- devalon:head:start -->",s="<!-- devalon:head:end -->",c="<!-- devalon:backlink:start -->",_="<!-- devalon:backlink:end -->";function $(e){let{canonical:o,languages:a}=d(e),n=[`<link rel="canonical" href="${l(o)}" />`];for(let[t,r]of Object.entries(a))r&&n.push(`<link rel="alternate" hreflang="${l(t)}" href="${l(r)}" />`);return n.join(`
1
+ import{l as f,o as k,t as p}from"./chunk-PYZQVHOF.mjs";import{q as d}from"./chunk-SHIXBOQB.mjs";import{a as l}from"./chunk-IJASKDEW.mjs";var i="<!-- devalon:head:start -->",s="<!-- devalon:head:end -->",c="<!-- devalon:backlink:start -->",_="<!-- devalon:backlink:end -->";function $(e){let{canonical:o,languages:a}=d(e),n=[`<link rel="canonical" href="${l(o)}" />`];for(let[t,r]of Object.entries(a))r&&n.push(`<link rel="alternate" hreflang="${l(t)}" href="${l(r)}" />`);return n.join(`
2
2
  `)}function b(e){let{alternates:o,...a}=e,n=[p(a)];return o&&n.push($(o)),n.join(`
3
3
  `)}function x(e){let{text:o,link_text:a,href:n}=k(e,f()),t=e.className?.trim();return`<span${t?` class="${l(t)}"`:""}>${l(o)} <a href="${l(n)}" target="_blank" rel="noopener" referrerpolicy="origin">${l(a)}</a></span>`}function g(e,o,a){let n=e.indexOf(o),t=e.indexOf(a);return n!==-1&&t!==-1&&t>n}function v(e,o,a,n){let t=e.indexOf(o),r=e.indexOf(a);return e.slice(0,t)+n+e.slice(r+a.length)}function H(e,o){let a=`${i}
4
4
  ${b(o)}
@@ -1 +1 @@
1
- import{a as i,b as p,c as _,d as m,e as f,f as c,g as v,h as u,j as T,k as h,l as a,m as L,n as b,o as l,p as k,r as x,t as g}from"../chunk-NG7NWZWD.mjs";import{a as U,b as j,c as C,d as S,e as I,f as A,g as F,h as $,i as M,j as P,k as J,l as K,m as X,n as O,o as q,p as z,q as d,r as G}from"../chunk-SHIXBOQB.mjs";function H(e){return d(e)}import{jsx as R,jsxs as B}from"react/jsx-runtime";function E(e){let o={NEXT_PUBLIC_SITE_URL:a().NEXT_PUBLIC_SITE_URL},{text:n,link_text:r,href:t}=l(e,o);return B("span",{className:e.className,children:[n," ",R("a",{href:t,target:"_blank",rel:"noopener",referrerPolicy:"origin",children:r})]})}function s(e){return e&&e.split(",")[0]?.trim()||void 0}function D(e){if(!e||typeof e.get!="function")return;let o=s(e.get("x-forwarded-host"))??s(e.get("host"));if(!o)return;let n=s(e.get("x-forwarded-proto")),r=n==="http"||n==="https"?n:"https";try{let t=new URL(`${r}://${o}`);if(!t.hostname)return;let y=t.hostname.replace(/^www\./,"");return`${t.protocol}//${y}`}catch{return}}import{jsx as N}from"react/jsx-runtime";function w({nonce:e,...o}){return N("script",{type:"application/ld+json",nonce:e,dangerouslySetInnerHTML:{__html:g(o)}})}export{T as BACKLINK_SENTENCES,h as DEFAULT_ANCHOR,X as DEVALON_CONTRIBUTION_CATALOG,S as DEVALON_EXPERTISE,F as DEVALON_EXPERTISE_I18N,C as DEVALON_FOUNDER_ID,I as DEVALON_LOCALES,j as DEVALON_ORG_ID,A as DEVALON_REGIONS,O as DEVALON_REGION_LABELS,q as DEVALON_SEARCH_TEMPLATES,P as DEVALON_SERVICE_ALIASES,M as DEVALON_SERVICE_CATALOG,$ as DEVALON_SERVICE_GROUPS,J as DEVALON_SERVICE_I18N,K as DEVALON_SERVICE_SEARCH_TERMS,U as DEVALON_URL,E as DevalonBacklink,w as DevalonJsonLd,d as build_devalon_alternates,H as build_devalon_alternates_metadata,G as build_devalon_json_ld,L as detect_site_url,D as devalonBacklinkSiteUrlFromHeaders,k as devalonHeadersConfig,f as devalonHumansBlock,c as devalonHumansTxt,u as devalonHumansTxtResponse,i as devalonLlmsBlock,p as devalonLlmsTxt,m as devalonLlmsTxtResponse,z as get_devalon_search_terms,v as mergeDevalonHumansTxt,_ as mergeDevalonLlmsTxt,b as resolve_backlink,l as resolve_backlink_auto,a as runtime_env,x as withDevalonHeaders};
1
+ import{a as i,b as p,c as _,d as m,e as f,f as c,g as v,h as u,j as T,k as h,l as a,m as L,n as b,o as l,p as k,r as x,s as g}from"../chunk-PYZQVHOF.mjs";import{a as U,b as j,c as C,d as S,e as I,f as A,g as F,h as $,i as M,j as P,k as J,l as K,m as X,n as O,o as q,p as z,q as d,r as G}from"../chunk-SHIXBOQB.mjs";import"../chunk-IJASKDEW.mjs";function H(e){return d(e)}import{jsx as R,jsxs as B}from"react/jsx-runtime";function E(e){let o={NEXT_PUBLIC_SITE_URL:a().NEXT_PUBLIC_SITE_URL},{text:n,link_text:r,href:t}=l(e,o);return B("span",{className:e.className,children:[n," ",R("a",{href:t,target:"_blank",rel:"noopener",referrerPolicy:"origin",children:r})]})}function s(e){return e&&e.split(",")[0]?.trim()||void 0}function D(e){if(!e||typeof e.get!="function")return;let o=s(e.get("x-forwarded-host"))??s(e.get("host"));if(!o)return;let n=s(e.get("x-forwarded-proto")),r=n==="http"||n==="https"?n:"https";try{let t=new URL(`${r}://${o}`);if(!t.hostname)return;let y=t.hostname.replace(/^www\./,"");return`${t.protocol}//${y}`}catch{return}}import{jsx as N}from"react/jsx-runtime";function w({nonce:e,...o}){return N("script",{type:"application/ld+json",nonce:e,dangerouslySetInnerHTML:{__html:g(o)}})}export{T as BACKLINK_SENTENCES,h as DEFAULT_ANCHOR,X as DEVALON_CONTRIBUTION_CATALOG,S as DEVALON_EXPERTISE,F as DEVALON_EXPERTISE_I18N,C as DEVALON_FOUNDER_ID,I as DEVALON_LOCALES,j as DEVALON_ORG_ID,A as DEVALON_REGIONS,O as DEVALON_REGION_LABELS,q as DEVALON_SEARCH_TEMPLATES,P as DEVALON_SERVICE_ALIASES,M as DEVALON_SERVICE_CATALOG,$ as DEVALON_SERVICE_GROUPS,J as DEVALON_SERVICE_I18N,K as DEVALON_SERVICE_SEARCH_TERMS,U as DEVALON_URL,E as DevalonBacklink,w as DevalonJsonLd,d as build_devalon_alternates,H as build_devalon_alternates_metadata,G as build_devalon_json_ld,L as detect_site_url,D as devalonBacklinkSiteUrlFromHeaders,k as devalonHeadersConfig,f as devalonHumansBlock,c as devalonHumansTxt,u as devalonHumansTxtResponse,i as devalonLlmsBlock,p as devalonLlmsTxt,m as devalonLlmsTxtResponse,z as get_devalon_search_terms,v as mergeDevalonHumansTxt,_ as mergeDevalonLlmsTxt,b as resolve_backlink,l as resolve_backlink_auto,a as runtime_env,x as withDevalonHeaders};
@@ -1 +1 @@
1
- import{a as T,b as h,c as b,d as N,e as R,f as j,g as B,h as C}from"../chunk-YBXS4SND.mjs";import{a as d,b as m,c,d as i,e as v,f,g as k,h as x,i as y,j as H,k as L,l as a,m as D,n as E,o as l,p as g,q as u,r as A,t as p}from"../chunk-NG7NWZWD.mjs";import{a as J,b as q,c as P,d as U,e as z,f as G,g as Q,h as W,i as X,j as Y,k as Z,l as $,m as ee,n as oe,o as ne,p as re,q as _,r as ae}from"../chunk-SHIXBOQB.mjs";import{Fragment as M,jsx as s,jsxs as O}from"react/jsx-runtime";function K(e){let{canonical:o,languages:r}=_(e);return O(M,{children:[s("link",{rel:"canonical",href:o}),Object.entries(r).map(([n,t])=>t?s("link",{rel:"alternate",hrefLang:n,href:t},n):null)]})}import{jsx as S,jsxs as w}from"react/jsx-runtime";function I(e){let{text:o,link_text:r,href:n}=l(e,a());return w("span",{className:e.className,children:[o," ",S("a",{href:n,target:"_blank",rel:"noopener",referrerPolicy:"origin",children:r})]})}import{jsx as F}from"react/jsx-runtime";function V({nonce:e,...o}){return F("script",{type:"application/ld+json",nonce:e,dangerouslySetInnerHTML:{__html:p(o)}})}export{H as BACKLINK_SENTENCES,L as DEFAULT_ANCHOR,ee as DEVALON_CONTRIBUTION_CATALOG,U as DEVALON_EXPERTISE,Q as DEVALON_EXPERTISE_I18N,P as DEVALON_FOUNDER_ID,N as DEVALON_HTML_BACKLINK_END,b as DEVALON_HTML_BACKLINK_START,h as DEVALON_HTML_HEAD_END,T as DEVALON_HTML_HEAD_START,z as DEVALON_LOCALES,q as DEVALON_ORG_ID,G as DEVALON_REGIONS,oe as DEVALON_REGION_LABELS,ne as DEVALON_SEARCH_TEMPLATES,Y as DEVALON_SERVICE_ALIASES,X as DEVALON_SERVICE_CATALOG,W as DEVALON_SERVICE_GROUPS,Z as DEVALON_SERVICE_I18N,$ as DEVALON_SERVICE_SEARCH_TERMS,J as DEVALON_URL,K as DevalonAlternates,I as DevalonBacklink,V as DevalonJsonLd,_ as build_devalon_alternates,ae as build_devalon_json_ld,D as detect_site_url,y as devalonAgentFiles,R as devalonAlternatesHtml,B as devalonBacklinkHtml,j as devalonHeadHtml,g as devalonHeadersConfig,u as devalonHeadersMiddleware,v as devalonHumansBlock,f as devalonHumansTxt,x as devalonHumansTxtResponse,C as devalonInjectHtml,d as devalonLlmsBlock,m as devalonLlmsTxt,i as devalonLlmsTxtResponse,re as get_devalon_search_terms,k as mergeDevalonHumansTxt,c as mergeDevalonLlmsTxt,E as resolve_backlink,l as resolve_backlink_auto,a as runtime_env,A as withDevalonHeaders};
1
+ import{a as T,b as h,c as b,d as N,e as R,f as j,g as B,h as C}from"../chunk-RZ4S6JFB.mjs";import{a as d,b as m,c,d as i,e as v,f,g as k,h as x,i as y,j as H,k as L,l as a,m as D,n as E,o as l,p as g,q as u,r as A,s as p}from"../chunk-PYZQVHOF.mjs";import{a as J,b as q,c as P,d as U,e as z,f as G,g as Q,h as W,i as X,j as Y,k as Z,l as $,m as ee,n as oe,o as ne,p as re,q as _,r as ae}from"../chunk-SHIXBOQB.mjs";import"../chunk-IJASKDEW.mjs";import{Fragment as M,jsx as s,jsxs as O}from"react/jsx-runtime";function K(e){let{canonical:o,languages:r}=_(e);return O(M,{children:[s("link",{rel:"canonical",href:o}),Object.entries(r).map(([n,t])=>t?s("link",{rel:"alternate",hrefLang:n,href:t},n):null)]})}import{jsx as S,jsxs as w}from"react/jsx-runtime";function I(e){let{text:o,link_text:r,href:n}=l(e,a());return w("span",{className:e.className,children:[o," ",S("a",{href:n,target:"_blank",rel:"noopener",referrerPolicy:"origin",children:r})]})}import{jsx as F}from"react/jsx-runtime";function V({nonce:e,...o}){return F("script",{type:"application/ld+json",nonce:e,dangerouslySetInnerHTML:{__html:p(o)}})}export{H as BACKLINK_SENTENCES,L as DEFAULT_ANCHOR,ee as DEVALON_CONTRIBUTION_CATALOG,U as DEVALON_EXPERTISE,Q as DEVALON_EXPERTISE_I18N,P as DEVALON_FOUNDER_ID,N as DEVALON_HTML_BACKLINK_END,b as DEVALON_HTML_BACKLINK_START,h as DEVALON_HTML_HEAD_END,T as DEVALON_HTML_HEAD_START,z as DEVALON_LOCALES,q as DEVALON_ORG_ID,G as DEVALON_REGIONS,oe as DEVALON_REGION_LABELS,ne as DEVALON_SEARCH_TEMPLATES,Y as DEVALON_SERVICE_ALIASES,X as DEVALON_SERVICE_CATALOG,W as DEVALON_SERVICE_GROUPS,Z as DEVALON_SERVICE_I18N,$ as DEVALON_SERVICE_SEARCH_TERMS,J as DEVALON_URL,K as DevalonAlternates,I as DevalonBacklink,V as DevalonJsonLd,_ as build_devalon_alternates,ae as build_devalon_json_ld,D as detect_site_url,y as devalonAgentFiles,R as devalonAlternatesHtml,B as devalonBacklinkHtml,j as devalonHeadHtml,g as devalonHeadersConfig,u as devalonHeadersMiddleware,v as devalonHumansBlock,f as devalonHumansTxt,x as devalonHumansTxtResponse,C as devalonInjectHtml,d as devalonLlmsBlock,m as devalonLlmsTxt,i as devalonLlmsTxtResponse,re as get_devalon_search_terms,k as mergeDevalonHumansTxt,c as mergeDevalonLlmsTxt,E as resolve_backlink,l as resolve_backlink_auto,a as runtime_env,A as withDevalonHeaders};
@@ -0,0 +1,16 @@
1
+ import type { devalon_signal_props } from "./types";
2
+ /**
3
+ * Renders the canonical Meta Pixel snippet into server HTML. There is no
4
+ * client-side code here: Next.js treats this as a Server Component, so the
5
+ * script tag is in the initial HTML and Meta's bootstrap runs in the browser
6
+ * while the page loads.
7
+ *
8
+ * The small first script is a bridge: it tells browser-side `signal()` which
9
+ * of possibly several initialized Meta Pixels belongs to Devalon, so events
10
+ * can be isolated with `fbq('trackSingle', …)`. It does not modify the
11
+ * canonical Meta snippet.
12
+ *
13
+ * For pure client-rendered apps (Vite), use `loadMetaPixel()` instead — React
14
+ * does not execute scripts inserted through innerHTML.
15
+ */
16
+ export declare function DevalonSignal({ pixelId, nonce }: devalon_signal_props): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ export interface devalon_signals_global {
2
+ __DEVALON_SIGNAL_PIXEL_ID?: string | undefined;
3
+ }
4
+ /** Called by `DevalonSignal` and `loadMetaPixel` with Devalon's own pixel ID. */
5
+ export declare function set_signal_pixel_id(pixel_id: string): void;
6
+ /** Clears the in-memory id, for tests and for reconfiguration. */
7
+ export declare function reset_signal_pixel_id(): void;
8
+ /** Resolves Devalon's pixel ID from in-memory state or the server-rendered bridge. */
9
+ export declare function get_signal_pixel_id(): string | undefined;
@@ -0,0 +1,24 @@
1
+ /** Minimal shape of the global installed by the canonical Pixel bootstrap. */
2
+ export interface devalon_meta_fbq {
3
+ (...args: unknown[]): void;
4
+ callMethod?: (...args: unknown[]) => void;
5
+ queue?: unknown[][];
6
+ loaded?: boolean;
7
+ version?: string;
8
+ }
9
+ export type devalon_pixel_status = "sent" | "blocked" | "missing";
10
+ export type devalon_pixel_reason = "fbq_missing" | "fbevents_not_loaded";
11
+ export interface devalon_pixel_state {
12
+ status: devalon_pixel_status;
13
+ reason?: devalon_pixel_reason | undefined;
14
+ }
15
+ export declare function meta_fbq(): devalon_meta_fbq | undefined;
16
+ /**
17
+ * The inline snippet creates a stub with `queue`, but only the real
18
+ * `fbevents.js` library defines `callMethod`. A stub without it means the
19
+ * script was blocked (ad blocker, CSP, network failure).
20
+ */
21
+ export declare function pixel_sdk_ready(): boolean;
22
+ /** How long to wait before deciding the Pixel SDK is never going to load. */
23
+ export declare const PIXEL_READY_CHECK_DELAY_MS = 800;
24
+ export declare function check_pixel_after_delay(delay_ms?: number): Promise<devalon_pixel_state>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Vendor-neutral event envelope. The browser Pixel and a future server-side
3
+ * CAPI endpoint use the same `event_id` so Meta can deduplicate them.
4
+ */
5
+ export interface devalon_signal_event {
6
+ event_name: string;
7
+ event_id: string;
8
+ params: Record<string, unknown>;
9
+ emitted_at: string;
10
+ }
11
+ /** UUID v4 when available, with a deterministic-free fallback for old browsers. */
12
+ export declare function create_signal_event_id(): string;
13
+ export declare function create_signal_event(event_name: string, params?: Record<string, unknown>, event_id?: string): devalon_signal_event;
@@ -0,0 +1,7 @@
1
+ export { DevalonSignal } from "./component";
2
+ export { signal } from "./signal";
3
+ export { DEVALON_CUSTOM_EVENT_NAMES, META_PIXEL_NOSCRIPT_BASE_URL, META_PIXEL_SCRIPT_URL, META_REQUIRED_EVENT_PARAMS, META_STANDARD_EVENT_NAMES, devalon_meta_pixel_html, devalon_meta_pixel_noscript, devalon_meta_pixel_script, loadMetaPixel, } from "./meta";
4
+ export { get_signal_pixel_id, reset_signal_pixel_id, set_signal_pixel_id, } from "./config";
5
+ export { create_signal_event, create_signal_event_id } from "./event";
6
+ export { PIXEL_READY_CHECK_DELAY_MS, check_pixel_after_delay, meta_fbq, pixel_sdk_ready, } from "./detect";
7
+ export type { devalon_custom_event_name, devalon_meta_event_name, devalon_signal_event_name, devalon_meta_fbq, devalon_meta_pixel_result, devalon_pixel_reason, devalon_pixel_state, devalon_pixel_status, devalon_signal_event, devalon_signal_options, devalon_signal_props, devalon_signals_config, } from "./types";
@@ -0,0 +1,17 @@
1
+ "use strict";var A=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},W=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of F(t))!X.call(e,i)&&i!==n&&A(e,i,{get:()=>t[i],enumerable:!(o=B(t,i))||o.enumerable});return e};var G=e=>W(A({},"__esModule",{value:!0}),e);var Y={};H(Y,{DEVALON_CUSTOM_EVENT_NAMES:()=>D,DevalonSignal:()=>L,META_PIXEL_NOSCRIPT_BASE_URL:()=>x,META_PIXEL_SCRIPT_URL:()=>E,META_REQUIRED_EVENT_PARAMS:()=>m,META_STANDARD_EVENT_NAMES:()=>u,PIXEL_READY_CHECK_DELAY_MS:()=>T,check_pixel_after_delay:()=>C,create_signal_event:()=>b,create_signal_event_id:()=>p,devalon_meta_pixel_html:()=>P,devalon_meta_pixel_noscript:()=>s,devalon_meta_pixel_script:()=>l,get_signal_pixel_id:()=>v,loadMetaPixel:()=>h,meta_fbq:()=>d,pixel_sdk_ready:()=>c,reset_signal_pixel_id:()=>N,set_signal_pixel_id:()=>g,signal:()=>$});module.exports=G(Y);function R(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var f;function g(e){f=e.trim()}function N(){f=void 0}function v(){if(f)return f;let t=globalThis.__DEVALON_SIGNAL_PIXEL_ID;return typeof t=="string"&&/^\d+$/.test(t)?t:void 0}var E="https://connect.facebook.net/en_US/fbevents.js",x="https://www.facebook.com/tr";function y(e){let t=e.trim();if(!/^\d+$/.test(t))throw new TypeError("pixelId must be a numeric Meta Pixel ID.");return t}function z(e){if(e!==void 0){if(!/^[A-Za-z0-9+/_=-]+$/.test(e))throw new TypeError("nonce contains unsupported characters.");return e}}function l(e){let t=y(e);return`!function(f,b,e,v,n,t,s)
2
+ {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
3
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};
4
+ if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
5
+ n.queue=[];t=b.createElement(e);t.async=!0;
6
+ t.src=v;s=b.getElementsByTagName(e)[0];
7
+ s.parentNode.insertBefore(t,s)}(window, document,'script',
8
+ '${E}');
9
+ fbq('init', '${t}');
10
+ fbq('track', 'PageView');`}function s(e){let t=y(e);return`<img height="1" width="1" style="display:none"
11
+ src="${x}?id=${t}&ev=PageView&noscript=1"
12
+ />`}var S=new Set;function h(e){let t=y(e);if(g(t),S.has(t))return;let n=globalThis.fbq;if(typeof n=="function"){n("init",t),S.add(t);return}let o=globalThis.document;if(!o)return;let i=`devalon-meta-pixel-${t}`;if(o.getElementById(i)){S.add(t);return}let r=o.createElement("script");r.id=i,r.textContent=l(t),o.head.appendChild(r),S.add(t)}function P(e,t){let n=l(e),o=s(e),i=z(t),r=i?` nonce="${R(i)}"`:"";return{script:n,noscript:o,html:`<!-- Meta Pixel Code -->
13
+ <script${r}>
14
+ ${n}
15
+ </script>
16
+ <noscript>${o}</noscript>
17
+ <!-- End Meta Pixel Code -->`}}var a=require("react/jsx-runtime");function L({pixelId:e,nonce:t}){let n=e.trim(),o=l(n),i=s(n),r=`window.__DEVALON_SIGNAL_PIXEL_ID=${JSON.stringify(n)};`;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("script",{dangerouslySetInnerHTML:{__html:r},nonce:t}),(0,a.jsx)("script",{dangerouslySetInnerHTML:{__html:o},nonce:t}),(0,a.jsx)("noscript",{dangerouslySetInnerHTML:{__html:i}})]})}function d(){let e=globalThis;return typeof e.fbq=="function"?e.fbq:void 0}function c(){let e=d();return!!(e&&typeof e.callMethod=="function")}var T=800;function C(e=T){return new Promise(t=>{setTimeout(()=>{t(c()?{status:"sent"}:{status:"blocked",reason:"fbevents_not_loaded"})},e)})}function p(){let e=globalThis;return typeof e.crypto?.randomUUID=="function"?e.crypto.randomUUID():`evt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function b(e,t={},n=p()){return{event_name:e,event_id:n,params:t,emitted_at:new Date().toISOString()}}var u=["PageView","ViewContent","Search","AddToCart","AddToWishlist","InitiateCheckout","AddPaymentInfo","Purchase","Lead","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","Schedule","StartTrial","SubmitApplication","Subscribe"],D=["ButtonClick","CtaClick","HeroCtaClick","PricingButtonClick","NavClick","MenuOpen","MenuClose","TabClick","AccordionToggle","CarouselNext","CarouselPrev","ModalOpen","ModalClose","DropdownSelect","SliderChange","ScrollDepth","ExitIntent","BackToTopClick","StickyBarClick","ToastDismiss","FormStart","FormSubmit","FormAbandon","FormStepComplete","FormValidationError","ContactFormSubmit","LeadFormSubmit","QuoteRequest","DemoRequest","CallbackRequest","NewsletterSignup","NewsletterUnsubscribe","WaitlistJoin","SurveyStart","SurveyComplete","FeedbackSubmit","NpsSubmit","RatingSubmit","ProductView","ProductListView","CategoryView","ProductCompare","RemoveFromCart","CartView","CheckoutStart","CheckoutStepComplete","ShippingSelect","PaymentSelect","OrderConfirm","OrderCancel","RefundRequest","ReviewSubmit","WishlistAdd","WishlistRemove","SearchNoResults","FilterApply","SortChange","StockAlertSubscribe","PromoCodeApply","GiftCardApply","ArticleView","BlogPostView","VideoPlay","VideoPause","VideoComplete","VideoProgress25","VideoProgress50","VideoProgress75","PodcastPlay","DocumentView","PdfView","GalleryOpen","ShareClick","CopyLink","OutboundClick","SocialClick","EmailClick","PhoneClick","WhatsAppClick","MapsClick","DirectionsClick","AppointmentClick","CalendarBook","BookingConfirm","ChatOpen","ChatMessageSent","ChatClose","SignUpStart","SignUpComplete","LoginSuccess","LoginFailure","Logout","OnboardingStart","OnboardingComplete","DashboardView","FeatureUse","SettingsChange","IntegrationConnect","ApiKeyCreate","InviteTeamMember","ReportExport","DataExport","SearchPerformed","NotificationEnable","PasswordReset","JsError","ApiError","PaymentError","CheckoutError","FormError","PageLoadError","RateLimitHit","FeatureUnavailable","PopupView","PopupClick","PopupClose","ExitPopupView","CampaignLandingView","AdClick","AffiliateClick","ReferralClick","BannerClick","CookieAccept","CookieReject"],m={ViewContent:["content_ids","value","currency"],Search:["search_string"],AddToCart:["value","currency"],AddToWishlist:["value","currency"],InitiateCheckout:["value","currency"],AddPaymentInfo:["value","currency"],Purchase:["value","currency"],Donate:["value","currency"],StartTrial:["value","currency"],Subscribe:["value","currency"]};var V=new Set(u);function q(e,t,n){typeof console<"u"&&typeof console.info=="function"&&console.info(`[Devalon Signal] ${e} \u2192 Pixel ${t} \u2713 (event_id=${n})`)}function O(e,t,n,o){if(typeof console>"u"||typeof console.warn!="function")return;console.warn(`[Devalon Signal] ${e} \u2192 Pixel ${t} ${o==="fbq_missing"?"MISSING":"BLOCKED"} \u2717 \u2014 send via CAPI with event_id=${n} (reason: ${o})`)}function Q(e,t){typeof console>"u"||typeof console.warn!="function"||console.warn(`[Devalon Signal] ${e} \u26A0 \u2014 missing recommended params: ${t.join(", ")}`)}function K(e,t){typeof console>"u"||typeof console.warn!="function"||console.warn(`[Devalon Signal] ${e} \u2717 \u2014 no Devalon pixel id configured (render <DevalonSignal/> or pass { pixelId }); event_id=${t}`)}function $(e,t={},n={}){let o=n.eventId??p(),i=b(e,t,o),r=n.pixelId??v(),k=d(),_=n.debug===!0;if(!r)return _&&K(e,o),i;if(!k)return _&&O(e,r,o,"fbq_missing"),i;if(_&&V.has(e)){let w=(m[e]??[]).filter(M=>!(M in t)||t[M]===void 0);w.length>0&&Q(e,w)}let U=V.has(e)?"trackSingle":"trackSingleCustom";return k(U,r,e,t,{eventID:o}),c()?(_&&q(e,r,o),i):(C().then(I=>{_&&(I.status==="sent"?q(e,r,o):O(e,r,o,"fbevents_not_loaded"))}),i)}0&&(module.exports={DEVALON_CUSTOM_EVENT_NAMES,DevalonSignal,META_PIXEL_NOSCRIPT_BASE_URL,META_PIXEL_SCRIPT_URL,META_REQUIRED_EVENT_PARAMS,META_STANDARD_EVENT_NAMES,PIXEL_READY_CHECK_DELAY_MS,check_pixel_after_delay,create_signal_event,create_signal_event_id,devalon_meta_pixel_html,devalon_meta_pixel_noscript,devalon_meta_pixel_script,get_signal_pixel_id,loadMetaPixel,meta_fbq,pixel_sdk_ready,reset_signal_pixel_id,set_signal_pixel_id,signal});
@@ -0,0 +1,17 @@
1
+ import{a as D}from"../chunk-IJASKDEW.mjs";var _;function g(e){_=e.trim()}function q(){_=void 0}function v(){if(_)return _;let t=globalThis.__DEVALON_SIGNAL_PIXEL_ID;return typeof t=="string"&&/^\d+$/.test(t)?t:void 0}var S="https://connect.facebook.net/en_US/fbevents.js",E="https://www.facebook.com/tr";function x(e){let t=e.trim();if(!/^\d+$/.test(t))throw new TypeError("pixelId must be a numeric Meta Pixel ID.");return t}function O(e){if(e!==void 0){if(!/^[A-Za-z0-9+/_=-]+$/.test(e))throw new TypeError("nonce contains unsupported characters.");return e}}function a(e){let t=x(e);return`!function(f,b,e,v,n,t,s)
2
+ {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
3
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};
4
+ if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
5
+ n.queue=[];t=b.createElement(e);t.async=!0;
6
+ t.src=v;s=b.getElementsByTagName(e)[0];
7
+ s.parentNode.insertBefore(t,s)}(window, document,'script',
8
+ '${S}');
9
+ fbq('init', '${t}');
10
+ fbq('track', 'PageView');`}function s(e){let t=x(e);return`<img height="1" width="1" style="display:none"
11
+ src="${E}?id=${t}&ev=PageView&noscript=1"
12
+ />`}var d=new Set;function k(e){let t=x(e);if(g(t),d.has(t))return;let o=globalThis.fbq;if(typeof o=="function"){o("init",t),d.add(t);return}let n=globalThis.document;if(!n)return;let r=`devalon-meta-pixel-${t}`;if(n.getElementById(r)){d.add(t);return}let i=n.createElement("script");i.id=r,i.textContent=a(t),n.head.appendChild(i),d.add(t)}function I(e,t){let o=a(e),n=s(e),r=O(t),i=r?` nonce="${D(r)}"`:"";return{script:o,noscript:n,html:`<!-- Meta Pixel Code -->
13
+ <script${i}>
14
+ ${o}
15
+ </script>
16
+ <noscript>${n}</noscript>
17
+ <!-- End Meta Pixel Code -->`}}import{Fragment as U,jsx as C,jsxs as B}from"react/jsx-runtime";function $({pixelId:e,nonce:t}){let o=e.trim(),n=a(o),r=s(o),i=`window.__DEVALON_SIGNAL_PIXEL_ID=${JSON.stringify(o)};`;return B(U,{children:[C("script",{dangerouslySetInnerHTML:{__html:i},nonce:t}),C("script",{dangerouslySetInnerHTML:{__html:n},nonce:t}),C("noscript",{dangerouslySetInnerHTML:{__html:r}})]})}function c(){let e=globalThis;return typeof e.fbq=="function"?e.fbq:void 0}function p(){let e=c();return!!(e&&typeof e.callMethod=="function")}var w=800;function b(e=w){return new Promise(t=>{setTimeout(()=>{t(p()?{status:"sent"}:{status:"blocked",reason:"fbevents_not_loaded"})},e)})}function u(){let e=globalThis;return typeof e.crypto?.randomUUID=="function"?e.crypto.randomUUID():`evt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function A(e,t={},o=u()){return{event_name:e,event_id:o,params:t,emitted_at:new Date().toISOString()}}var m=["PageView","ViewContent","Search","AddToCart","AddToWishlist","InitiateCheckout","AddPaymentInfo","Purchase","Lead","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","Schedule","StartTrial","SubmitApplication","Subscribe"],M=["ButtonClick","CtaClick","HeroCtaClick","PricingButtonClick","NavClick","MenuOpen","MenuClose","TabClick","AccordionToggle","CarouselNext","CarouselPrev","ModalOpen","ModalClose","DropdownSelect","SliderChange","ScrollDepth","ExitIntent","BackToTopClick","StickyBarClick","ToastDismiss","FormStart","FormSubmit","FormAbandon","FormStepComplete","FormValidationError","ContactFormSubmit","LeadFormSubmit","QuoteRequest","DemoRequest","CallbackRequest","NewsletterSignup","NewsletterUnsubscribe","WaitlistJoin","SurveyStart","SurveyComplete","FeedbackSubmit","NpsSubmit","RatingSubmit","ProductView","ProductListView","CategoryView","ProductCompare","RemoveFromCart","CartView","CheckoutStart","CheckoutStepComplete","ShippingSelect","PaymentSelect","OrderConfirm","OrderCancel","RefundRequest","ReviewSubmit","WishlistAdd","WishlistRemove","SearchNoResults","FilterApply","SortChange","StockAlertSubscribe","PromoCodeApply","GiftCardApply","ArticleView","BlogPostView","VideoPlay","VideoPause","VideoComplete","VideoProgress25","VideoProgress50","VideoProgress75","PodcastPlay","DocumentView","PdfView","GalleryOpen","ShareClick","CopyLink","OutboundClick","SocialClick","EmailClick","PhoneClick","WhatsAppClick","MapsClick","DirectionsClick","AppointmentClick","CalendarBook","BookingConfirm","ChatOpen","ChatMessageSent","ChatClose","SignUpStart","SignUpComplete","LoginSuccess","LoginFailure","Logout","OnboardingStart","OnboardingComplete","DashboardView","FeatureUse","SettingsChange","IntegrationConnect","ApiKeyCreate","InviteTeamMember","ReportExport","DataExport","SearchPerformed","NotificationEnable","PasswordReset","JsError","ApiError","PaymentError","CheckoutError","FormError","PageLoadError","RateLimitHit","FeatureUnavailable","PopupView","PopupClick","PopupClose","ExitPopupView","CampaignLandingView","AdClick","AffiliateClick","ReferralClick","BannerClick","CookieAccept","CookieReject"],f={ViewContent:["content_ids","value","currency"],Search:["search_string"],AddToCart:["value","currency"],AddToWishlist:["value","currency"],InitiateCheckout:["value","currency"],AddPaymentInfo:["value","currency"],Purchase:["value","currency"],Donate:["value","currency"],StartTrial:["value","currency"],Subscribe:["value","currency"]};var R=new Set(m);function N(e,t,o){typeof console<"u"&&typeof console.info=="function"&&console.info(`[Devalon Signal] ${e} \u2192 Pixel ${t} \u2713 (event_id=${o})`)}function L(e,t,o,n){if(typeof console>"u"||typeof console.warn!="function")return;console.warn(`[Devalon Signal] ${e} \u2192 Pixel ${t} ${n==="fbq_missing"?"MISSING":"BLOCKED"} \u2717 \u2014 send via CAPI with event_id=${o} (reason: ${n})`)}function F(e,t){typeof console>"u"||typeof console.warn!="function"||console.warn(`[Devalon Signal] ${e} \u26A0 \u2014 missing recommended params: ${t.join(", ")}`)}function X(e,t){typeof console>"u"||typeof console.warn!="function"||console.warn(`[Devalon Signal] ${e} \u2717 \u2014 no Devalon pixel id configured (render <DevalonSignal/> or pass { pixelId }); event_id=${t}`)}function H(e,t={},o={}){let n=o.eventId??u(),r=A(e,t,n),i=o.pixelId??v(),y=c(),l=o.debug===!0;if(!i)return l&&X(e,n),r;if(!y)return l&&L(e,i,n,"fbq_missing"),r;if(l&&R.has(e)){let P=(f[e]??[]).filter(T=>!(T in t)||t[T]===void 0);P.length>0&&F(e,P)}let V=R.has(e)?"trackSingle":"trackSingleCustom";return y(V,i,e,t,{eventID:n}),p()?(l&&N(e,i,n),r):(b().then(h=>{l&&(h.status==="sent"?N(e,i,n):L(e,i,n,"fbevents_not_loaded"))}),r)}export{M as DEVALON_CUSTOM_EVENT_NAMES,$ as DevalonSignal,E as META_PIXEL_NOSCRIPT_BASE_URL,S as META_PIXEL_SCRIPT_URL,f as META_REQUIRED_EVENT_PARAMS,m as META_STANDARD_EVENT_NAMES,w as PIXEL_READY_CHECK_DELAY_MS,b as check_pixel_after_delay,A as create_signal_event,u as create_signal_event_id,I as devalon_meta_pixel_html,s as devalon_meta_pixel_noscript,a as devalon_meta_pixel_script,v as get_signal_pixel_id,k as loadMetaPixel,c as meta_fbq,p as pixel_sdk_ready,q as reset_signal_pixel_id,g as set_signal_pixel_id,H as signal};
@@ -0,0 +1,3 @@
1
+ export { META_PIXEL_NOSCRIPT_BASE_URL, META_PIXEL_SCRIPT_URL, devalon_meta_pixel_html, devalon_meta_pixel_noscript, devalon_meta_pixel_script, loadMetaPixel, } from "./pixel";
2
+ export { DEVALON_CUSTOM_EVENT_NAMES, META_REQUIRED_EVENT_PARAMS, META_STANDARD_EVENT_NAMES, } from "./types";
3
+ export type { devalon_custom_event_name, devalon_meta_event_name, devalon_meta_pixel_result, devalon_signal_event_name, } from "./types";
@@ -0,0 +1,18 @@
1
+ import type { devalon_meta_pixel_result } from "./types";
2
+ export declare const META_PIXEL_SCRIPT_URL = "https://connect.facebook.net/en_US/fbevents.js";
3
+ export declare const META_PIXEL_NOSCRIPT_BASE_URL = "https://www.facebook.com/tr";
4
+ /**
5
+ * The canonical Meta Pixel bootstrap, byte-for-byte identical to the snippet
6
+ * from Events Manager. The pixel ID is the only variable.
7
+ */
8
+ export declare function devalon_meta_pixel_script(pixel_id: string): string;
9
+ /** The canonical noscript fallback image, with the pixel ID interpolated. */
10
+ export declare function devalon_meta_pixel_noscript(pixel_id: string): string;
11
+ /**
12
+ * Client-rendered counterpart of `DevalonSignal`, for Vite-style SPAs where
13
+ * there is no server HTML. Creates the script as a DOM node so the browser
14
+ * actually executes it, or registers our ID on an `fbq` instance that another
15
+ * Meta Pixel already installed. Safe to call more than once.
16
+ */
17
+ export declare function loadMetaPixel(pixel_id: string): void;
18
+ export declare function devalon_meta_pixel_html(pixel_id: string, nonce?: string | undefined): devalon_meta_pixel_result;
@@ -0,0 +1,21 @@
1
+ /** Meta's standard Pixel events. Custom names are accepted by the trackers. */
2
+ export type devalon_meta_event_name = "PageView" | "ViewContent" | "Search" | "AddToCart" | "AddToWishlist" | "InitiateCheckout" | "AddPaymentInfo" | "Purchase" | "Lead" | "CompleteRegistration" | "Contact" | "CustomizeProduct" | "Donate" | "FindLocation" | "Schedule" | "StartTrial" | "SubmitApplication" | "Subscribe";
3
+ /** Meta's standard events. Anything else is sent via `fbq('trackCustom', …)`. */
4
+ export declare const META_STANDARD_EVENT_NAMES: readonly devalon_meta_event_name[];
5
+ /**
6
+ * Common custom events used across Devalon projects. This is a convenience
7
+ * catalog, not a restriction: `signal()` still accepts any other string.
8
+ */
9
+ export declare const DEVALON_CUSTOM_EVENT_NAMES: readonly ["ButtonClick", "CtaClick", "HeroCtaClick", "PricingButtonClick", "NavClick", "MenuOpen", "MenuClose", "TabClick", "AccordionToggle", "CarouselNext", "CarouselPrev", "ModalOpen", "ModalClose", "DropdownSelect", "SliderChange", "ScrollDepth", "ExitIntent", "BackToTopClick", "StickyBarClick", "ToastDismiss", "FormStart", "FormSubmit", "FormAbandon", "FormStepComplete", "FormValidationError", "ContactFormSubmit", "LeadFormSubmit", "QuoteRequest", "DemoRequest", "CallbackRequest", "NewsletterSignup", "NewsletterUnsubscribe", "WaitlistJoin", "SurveyStart", "SurveyComplete", "FeedbackSubmit", "NpsSubmit", "RatingSubmit", "ProductView", "ProductListView", "CategoryView", "ProductCompare", "RemoveFromCart", "CartView", "CheckoutStart", "CheckoutStepComplete", "ShippingSelect", "PaymentSelect", "OrderConfirm", "OrderCancel", "RefundRequest", "ReviewSubmit", "WishlistAdd", "WishlistRemove", "SearchNoResults", "FilterApply", "SortChange", "StockAlertSubscribe", "PromoCodeApply", "GiftCardApply", "ArticleView", "BlogPostView", "VideoPlay", "VideoPause", "VideoComplete", "VideoProgress25", "VideoProgress50", "VideoProgress75", "PodcastPlay", "DocumentView", "PdfView", "GalleryOpen", "ShareClick", "CopyLink", "OutboundClick", "SocialClick", "EmailClick", "PhoneClick", "WhatsAppClick", "MapsClick", "DirectionsClick", "AppointmentClick", "CalendarBook", "BookingConfirm", "ChatOpen", "ChatMessageSent", "ChatClose", "SignUpStart", "SignUpComplete", "LoginSuccess", "LoginFailure", "Logout", "OnboardingStart", "OnboardingComplete", "DashboardView", "FeatureUse", "SettingsChange", "IntegrationConnect", "ApiKeyCreate", "InviteTeamMember", "ReportExport", "DataExport", "SearchPerformed", "NotificationEnable", "PasswordReset", "JsError", "ApiError", "PaymentError", "CheckoutError", "FormError", "PageLoadError", "RateLimitHit", "FeatureUnavailable", "PopupView", "PopupClick", "PopupClose", "ExitPopupView", "CampaignLandingView", "AdClick", "AffiliateClick", "ReferralClick", "BannerClick", "CookieAccept", "CookieReject"];
10
+ export type devalon_custom_event_name = (typeof DEVALON_CUSTOM_EVENT_NAMES)[number];
11
+ export type devalon_signal_event_name = devalon_meta_event_name | devalon_custom_event_name | (string & {});
12
+ /** Parameters Meta expects for each standard event. Used for debug warnings. */
13
+ export declare const META_REQUIRED_EVENT_PARAMS: Partial<Record<devalon_meta_event_name, readonly string[]>>;
14
+ export interface devalon_meta_pixel_result {
15
+ /** The canonical inline bootstrap script, without the <script> tag. */
16
+ script: string;
17
+ /** The canonical noscript fallback, without the <noscript> tag. */
18
+ noscript: string;
19
+ /** Full Meta Pixel snippet, ready to inject into server-rendered HTML. */
20
+ html: string;
21
+ }
@@ -0,0 +1,9 @@
1
+ import type { devalon_signal_event } from "./event";
2
+ import type { devalon_signal_event_name } from "./meta/types";
3
+ import type { devalon_signal_options } from "./types";
4
+ /**
5
+ * Sends one event to Devalon's Pixel only, even when other Meta Pixels are
6
+ * initialized on the page. Uses `trackSingle` / `trackSingleCustom` so events
7
+ * are not broadcast to the other Pixels' ad accounts.
8
+ */
9
+ export declare function signal(name: devalon_signal_event_name, params?: Record<string, unknown>, options?: devalon_signal_options): devalon_signal_event;
@@ -0,0 +1,26 @@
1
+ export interface devalon_signal_options {
2
+ /** Log success/failure (including the CAPI fallback hint) to the console. */
3
+ debug?: boolean | undefined;
4
+ /** Reuse an existing id to deduplicate this event with a server CAPI event. */
5
+ eventId?: string | undefined;
6
+ /** Override Devalon's pixel ID (normally provided by `DevalonSignal`). */
7
+ pixelId?: string | undefined;
8
+ }
9
+ export interface devalon_signal_props {
10
+ /** Numeric Meta Pixel ID from Events Manager. */
11
+ pixelId: string;
12
+ /** Optional CSP nonce applied to the inline <script> tag. */
13
+ nonce?: string | undefined;
14
+ }
15
+ /**
16
+ * Config shape reserved for future vendor modules. Today only `meta` is
17
+ * consumed; Google and other vendors can be added without a breaking change.
18
+ */
19
+ export interface devalon_signals_config {
20
+ meta?: {
21
+ pixelId: string;
22
+ } | undefined;
23
+ }
24
+ export type { devalon_signal_event } from "./event";
25
+ export type { devalon_meta_fbq, devalon_pixel_reason, devalon_pixel_state, devalon_pixel_status, } from "./detect";
26
+ export type { devalon_custom_event_name, devalon_meta_event_name, devalon_meta_pixel_result, devalon_signal_event_name, } from "./meta/types";
@@ -1,4 +1,4 @@
1
- import{h as S}from"../chunk-YBXS4SND.mjs";import{g as w,i as b,l as k,m as x,p as j,q as F}from"../chunk-NG7NWZWD.mjs";import"../chunk-SHIXBOQB.mjs";import{mkdir as D,readFile as A,writeFile as u}from"fs/promises";import{join as f,resolve as N}from"path";var E="# devalon:start",v="# devalon:end";function $(n,o){let e={site_url:n.site_url};n.services&&(e.services=n.services),n.contributions&&(e.contributions=n.contributions);let a=o&&typeof o=="object"&&o.locale?o.locale:n.in_language;return a&&(e.locale=a),e}function C(n,o){let e={site_url:n.site_url};if(n.services&&(e.services=n.services),n.contributions&&(e.contributions=n.contributions),o&&typeof o=="object"&&o.localeFromPath?.length)e.localeFromPath=o.localeFromPath;else{let a=o&&typeof o=="object"&&o.locale?o.locale:n.in_language;a&&(e.locale=a)}return e}function P(n){return typeof n=="object"&&n!==null&&"code"in n&&n.code==="ENOENT"}function R(n){return[E,"/*",...n.map(({key:o,value:e})=>` ${o}: ${e}`),v].join(`
1
+ import{h as S}from"../chunk-RZ4S6JFB.mjs";import{g as w,i as b,l as k,m as x,p as j,q as F}from"../chunk-PYZQVHOF.mjs";import"../chunk-SHIXBOQB.mjs";import"../chunk-IJASKDEW.mjs";import{mkdir as D,readFile as A,writeFile as u}from"fs/promises";import{join as f,resolve as N}from"path";var E="# devalon:start",v="# devalon:end";function $(n,o){let e={site_url:n.site_url};n.services&&(e.services=n.services),n.contributions&&(e.contributions=n.contributions);let a=o&&typeof o=="object"&&o.locale?o.locale:n.in_language;return a&&(e.locale=a),e}function C(n,o){let e={site_url:n.site_url};if(n.services&&(e.services=n.services),n.contributions&&(e.contributions=n.contributions),o&&typeof o=="object"&&o.localeFromPath?.length)e.localeFromPath=o.localeFromPath;else{let a=o&&typeof o=="object"&&o.locale?o.locale:n.in_language;a&&(e.locale=a)}return e}function P(n){return typeof n=="object"&&n!==null&&"code"in n&&n.code==="ENOENT"}function R(n){return[E,"/*",...n.map(({key:o,value:e})=>` ${o}: ${e}`),v].join(`
2
2
  `)}async function T(n,o){let e="";try{e=await A(n,"utf8")}catch(i){if(!P(i))throw i}let a=e.indexOf(E),l=e.indexOf(v),r;if(a!==-1&&l!==-1&&l>a)r=e.slice(0,a)+o+e.slice(l+v.length);else{let i=e.trimEnd();r=i?`${i}
3
3
 
4
4
  ${o}
@@ -0,0 +1,203 @@
1
+ # Signals — Meta Pixel usage guide
2
+
3
+ `@devalon.dev/credits/signals` loads the Meta Pixel into a website and lets you
4
+ track user actions with one function. It works in Next.js, React and Vite.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @devalon.dev/credits
10
+ ```
11
+
12
+ ## 1. Load the pixel once
13
+
14
+ Get the numeric Pixel ID from **Meta Events Manager → Data Sources → your Pixel
15
+ → Settings** (for example `1683475309995701`).
16
+
17
+ ### Next.js App Router
18
+
19
+ Put it once in the root layout:
20
+
21
+ ```tsx
22
+ // app/layout.tsx
23
+ import { DevalonSignal } from "@devalon.dev/credits/signals";
24
+
25
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
26
+ return (
27
+ <html lang="en">
28
+ <body>
29
+ {children}
30
+ <DevalonSignal pixelId="1683475309995701" />
31
+ </body>
32
+ </html>
33
+ );
34
+ }
35
+ ```
36
+
37
+ No `"use client"` needed here. The initial `PageView` is sent automatically.
38
+
39
+ ### Next.js Pages Router
40
+
41
+ ```tsx
42
+ // pages/_app.tsx
43
+ import { DevalonSignal } from "@devalon.dev/credits/signals";
44
+
45
+ export default function App({ Component, pageProps }) {
46
+ return (
47
+ <>
48
+ <Component {...pageProps} />
49
+ <DevalonSignal pixelId="1683475309995701" />
50
+ </>
51
+ );
52
+ }
53
+ ```
54
+
55
+ ### React with SSR
56
+
57
+ Render `<DevalonSignal pixelId="1683475309995701" />` once in your document
58
+ template.
59
+
60
+ ### Vite (client-only)
61
+
62
+ ```ts
63
+ // src/main.tsx
64
+ import { loadMetaPixel } from "@devalon.dev/credits/signals";
65
+
66
+ loadMetaPixel("1683475309995701");
67
+ ```
68
+
69
+ Call it once before rendering the app.
70
+
71
+ ### Strict CSP
72
+
73
+ Pass the same nonce you use for other inline scripts:
74
+
75
+ ```tsx
76
+ <DevalonSignal pixelId="1683475309995701" nonce={nonce} />
77
+ ```
78
+
79
+ ## 2. Track actions
80
+
81
+ ```tsx
82
+ "use client";
83
+ import { signal } from "@devalon.dev/credits/signals";
84
+
85
+ export function TrackButton() {
86
+ return (
87
+ <button onClick={() => signal("HeroCtaClick", { button_id: "hero" }, { debug: true })}>
88
+ Try it free
89
+ </button>
90
+ );
91
+ }
92
+ ```
93
+
94
+ Other common uses:
95
+
96
+ ```ts
97
+ signal("Lead", { source: "contact-form" }); // form submit
98
+ signal("Purchase", { value: 29.99, currency: "USD", content_ids: ["sku_1"] });
99
+ signal("VideoPlay", { video_id: "intro" }); // custom event
100
+ ```
101
+
102
+ `signal()` returns an object you can use for server-side tracking:
103
+
104
+ ```ts
105
+ { event_name: "Purchase", event_id: "…", params: { … }, emitted_at: "…" }
106
+ ```
107
+
108
+ ### Options (third argument)
109
+
110
+ ```ts
111
+ signal("Purchase", { value: 29.99 }, {
112
+ debug: true, // console logs — use in development
113
+ eventId: "saved-id", // reuse an id (e.g. after a redirect)
114
+ pixelId: "1683475309995701", // override the configured pixel
115
+ });
116
+ ```
117
+
118
+ ## 3. Event names
119
+
120
+ **Meta standard events** (use these for conversion reporting):
121
+
122
+ `PageView`, `ViewContent`, `Search`, `AddToCart`, `AddToWishlist`,
123
+ `InitiateCheckout`, `AddPaymentInfo`, `Purchase`, `Lead`,
124
+ `CompleteRegistration`, `Contact`, `CustomizeProduct`, `Donate`, `FindLocation`,
125
+ `Schedule`, `StartTrial`, `SubmitApplication`, `Subscribe`.
126
+
127
+ For `Purchase`, `AddToCart`, `Donate`, `Subscribe`, `StartTrial` and similar,
128
+ always send `value` and `currency` together. `ViewContent` expects
129
+ `content_ids`; `Search` expects `search_string`.
130
+
131
+ **Custom events** — use the shared catalog for common names:
132
+
133
+ `HeroCtaClick`, `ButtonClick`, `FormSubmit`, `DemoRequest`, `NewsletterSignup`,
134
+ `ProductView`, `VideoPlay`, `PhoneClick`, `EmailClick`, `LoginSuccess`,
135
+ `ApiError`, `PopupView`, and 110+ more in `DEVALON_CUSTOM_EVENT_NAMES`.
136
+
137
+ Any other string works too — you are not limited to the catalog:
138
+
139
+ ```ts
140
+ signal("MyNewAction", { step: 1 });
141
+ ```
142
+
143
+ ## 4. Debug logs
144
+
145
+ Add `{ debug: true }` while developing. Each event logs one of these:
146
+
147
+ | Log | Meaning | What to do |
148
+ | --- | --- | --- |
149
+ | `✓ Pixel <id>` | Event accepted by Meta | Nothing |
150
+ | `BLOCKED ✗ … send via CAPI` | Pixel script blocked (ad blocker, filter) | Send the reported `event_id` through CAPI |
151
+ | `MISSING ✗ … send via CAPI` | Pixel not loaded at all | Check the setup above and CSP |
152
+ | `no Devalon pixel id configured` | Pixel ID unknown in the browser | Render `DevalonSignal` or call `loadMetaPixel()` first |
153
+ | `⚠ missing recommended params` | Standard event lacks `value`/`currency` etc. (event is still sent) | Add the expected params |
154
+
155
+ Without `debug: true`, `signal()` is silent.
156
+
157
+ ## 5. CAPI deduplication (quick version)
158
+
159
+ If you also send the event from your server, use the **same `event_name` and
160
+ `event_id`** in both places — Meta then counts one conversion, not two.
161
+
162
+ ```tsx
163
+ "use client";
164
+ import { signal } from "@devalon.dev/credits/signals";
165
+
166
+ async function onPurchase() {
167
+ const event = signal("Purchase", { value: 29.99, currency: "USD" }, { debug: true });
168
+
169
+ await fetch("/api/capi", {
170
+ method: "POST",
171
+ headers: { "content-type": "application/json" },
172
+ body: JSON.stringify(event), // forward event_id to your server
173
+ });
174
+ }
175
+ ```
176
+
177
+ Your endpoint posts to Meta with `event_name: event.event_name`,
178
+ `event_id: event.event_id`, `event_time`, `action_source: "website"` and hashed
179
+ `user_data`. Never put the CAPI access token in browser code.
180
+
181
+ ## 6. Tips and common mistakes
182
+
183
+ - Mount the loader **once per page load**. Two mounts send two `PageView`s.
184
+ - Do **not** also install the same Pixel through GTM or another tag manager.
185
+ - Calls to `signal()` belong in event handlers, effects or Client Components —
186
+ never in a Server Component.
187
+ - Use `pixelId` only when overriding; normally the ID is already configured.
188
+ - Events are scoped to Devalon's Pixel, even when other Meta Pixels are on the
189
+ page — do not add manual `fbq('track', …)` calls for the same actions.
190
+ - If the Pixel is blocked for a user, the debug log gives you the `event_id` to
191
+ send through CAPI — keep that path in place for conversions that matter.
192
+ - Verify with **Meta Events Manager → Test Events** before going live.
193
+
194
+ ## Quick reference
195
+
196
+ ```ts
197
+ import {
198
+ DevalonSignal, // loader component (server-rendered)
199
+ loadMetaPixel, // loader for Vite CSR
200
+ signal, // send an event
201
+ DEVALON_CUSTOM_EVENT_NAMES, // custom event name list
202
+ } from "@devalon.dev/credits/signals";
203
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devalon.dev/credits",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Devalon technology-partner attribution for Next.js, React and Vite",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -27,6 +27,11 @@
27
27
  "types": "./dist/vite/index.d.ts",
28
28
  "import": "./dist/vite/index.mjs",
29
29
  "require": "./dist/vite/index.js"
30
+ },
31
+ "./signals": {
32
+ "types": "./dist/signals/index.d.ts",
33
+ "import": "./dist/signals/index.mjs",
34
+ "require": "./dist/signals/index.js"
30
35
  }
31
36
  },
32
37
  "files": [
@@ -34,6 +39,7 @@
34
39
  "README.md",
35
40
  "docs/nextjs",
36
41
  "docs/react",
42
+ "docs/signals",
37
43
  "scripts",
38
44
  "!.env",
39
45
  "!.env.*"
@@ -42,8 +48,8 @@
42
48
  "devalon-check": "scripts/check-devalon-credits.mjs"
43
49
  },
44
50
  "scripts": {
45
- "build": "tsup src/index.ts src/next/index.ts src/react/index.ts src/vite/index.ts --format esm,cjs --clean --minify && tsc --emitDeclarationOnly --declarationMap false --outDir dist && rm -rf dist/src",
46
- "dev": "tsup src/index.ts src/next/index.ts src/react/index.ts src/vite/index.ts --format esm,cjs --watch",
51
+ "build": "tsup src/index.ts src/next/index.ts src/react/index.ts src/vite/index.ts src/signals/index.ts --format esm,cjs --clean --minify && tsc --emitDeclarationOnly --declarationMap false --outDir dist && rm -rf dist/src",
52
+ "dev": "tsup src/index.ts src/next/index.ts src/react/index.ts src/vite/index.ts src/signals/index.ts --format esm,cjs --watch",
47
53
  "check:credits": "node scripts/check-devalon-credits.mjs",
48
54
  "test": "yarn build && node --test scripts/*.test.mjs",
49
55
  "prepublishOnly": "yarn build"
@@ -0,0 +1,459 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+
4
+ import {
5
+ DEVALON_CUSTOM_EVENT_NAMES,
6
+ META_REQUIRED_EVENT_PARAMS,
7
+ DevalonSignal,
8
+ PIXEL_READY_CHECK_DELAY_MS,
9
+ create_signal_event,
10
+ create_signal_event_id,
11
+ devalon_meta_pixel_html,
12
+ devalon_meta_pixel_noscript,
13
+ devalon_meta_pixel_script,
14
+ loadMetaPixel,
15
+ pixel_sdk_ready,
16
+ reset_signal_pixel_id,
17
+ set_signal_pixel_id,
18
+ signal as sendSignal,
19
+ } from "../dist/signals/index.mjs";
20
+
21
+ const PIXEL_ID = "1683475309995701";
22
+ const OTHER_PIXEL_ID = "999999999999999";
23
+
24
+ const CANONICAL_SCRIPT = `!function(f,b,e,v,n,t,s)
25
+ {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
26
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};
27
+ if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
28
+ n.queue=[];t=b.createElement(e);t.async=!0;
29
+ t.src=v;s=b.getElementsByTagName(e)[0];
30
+ s.parentNode.insertBefore(t,s)}(window, document,'script',
31
+ 'https://connect.facebook.net/en_US/fbevents.js');
32
+ fbq('init', '${PIXEL_ID}');
33
+ fbq('track', 'PageView');`;
34
+
35
+ function stub_fbq({ ready = true } = {}) {
36
+ const calls = [];
37
+ const fbq = (...args) => calls.push(args);
38
+ if (ready) fbq.callMethod = () => {};
39
+ globalThis.fbq = fbq;
40
+ return calls;
41
+ }
42
+
43
+ function capture_logs() {
44
+ const info = [];
45
+ const warn = [];
46
+ const original_info = console.info;
47
+ const original_warn = console.warn;
48
+
49
+ console.info = (...args) => info.push(args.join(" "));
50
+ console.warn = (...args) => warn.push(args.join(" "));
51
+
52
+ return {
53
+ info,
54
+ warn,
55
+ restore() {
56
+ console.info = original_info;
57
+ console.warn = original_warn;
58
+ },
59
+ };
60
+ }
61
+
62
+ function clear_pixel_config() {
63
+ reset_signal_pixel_id();
64
+ delete globalThis.__DEVALON_SIGNAL_PIXEL_ID;
65
+ }
66
+
67
+ describe("meta pixel snippet", () => {
68
+ it("reproduces the Events Manager script byte-for-byte", () => {
69
+ assert.equal(devalon_meta_pixel_script(PIXEL_ID), CANONICAL_SCRIPT);
70
+ });
71
+
72
+ it("changes only the pixel id between two IDs", () => {
73
+ assert.equal(
74
+ devalon_meta_pixel_script("123456789"),
75
+ CANONICAL_SCRIPT.replaceAll(PIXEL_ID, "123456789"),
76
+ );
77
+ });
78
+
79
+ it("interpolates the id into the noscript fallback URL", () => {
80
+ assert.equal(
81
+ devalon_meta_pixel_noscript(PIXEL_ID),
82
+ `<img height="1" width="1" style="display:none"\n` +
83
+ `src="https://www.facebook.com/tr?id=${PIXEL_ID}&ev=PageView&noscript=1"\n` +
84
+ `/>`,
85
+ );
86
+ });
87
+
88
+ it("assembles the full snippet with markers and the pixel id twice", () => {
89
+ const { script, noscript, html } = devalon_meta_pixel_html(PIXEL_ID);
90
+
91
+ assert.equal(script, CANONICAL_SCRIPT);
92
+ assert.match(html, /^<!-- Meta Pixel Code -->\n<script>\n/);
93
+ assert.match(html, /\n<\/script>\n<noscript>/);
94
+ assert.match(html, /<!-- End Meta Pixel Code -->$/);
95
+ assert.equal(html.match(new RegExp(PIXEL_ID, "g"))?.length, 2);
96
+ assert.equal(html.includes(noscript), true);
97
+ });
98
+
99
+ it("puts a nonce on the script tag only", () => {
100
+ const { html } = devalon_meta_pixel_html(PIXEL_ID, "abc123");
101
+ assert.match(html, /<script nonce="abc123">/);
102
+ assert.doesNotMatch(html, /<img[^>]*nonce/);
103
+ });
104
+
105
+ it("rejects invalid pixel IDs and nonces", () => {
106
+ assert.throws(() => devalon_meta_pixel_script("not-a-number"), TypeError);
107
+ assert.throws(() => devalon_meta_pixel_noscript(""), TypeError);
108
+ assert.throws(() => devalon_meta_pixel_html(PIXEL_ID, 'x" onload="'), TypeError);
109
+ });
110
+ });
111
+
112
+ describe("signals component", () => {
113
+ it("renders the bridge, the canonical snippet and the noscript", () => {
114
+ const [bridge, script, noscript] = DevalonSignal({
115
+ pixelId: PIXEL_ID,
116
+ }).props.children;
117
+
118
+ assert.equal(bridge.type, "script");
119
+ assert.equal(
120
+ bridge.props.dangerouslySetInnerHTML.__html,
121
+ `window.__DEVALON_SIGNAL_PIXEL_ID="${PIXEL_ID}";`,
122
+ );
123
+ assert.equal(script.type, "script");
124
+ assert.equal(script.props.dangerouslySetInnerHTML.__html, CANONICAL_SCRIPT);
125
+ assert.equal(noscript.type, "noscript");
126
+ assert.equal(
127
+ noscript.props.dangerouslySetInnerHTML.__html,
128
+ devalon_meta_pixel_noscript(PIXEL_ID),
129
+ );
130
+ });
131
+
132
+ it("forwards the CSP nonce to both script tags", () => {
133
+ const [bridge, script, noscript] = DevalonSignal({
134
+ pixelId: PIXEL_ID,
135
+ nonce: "abc123",
136
+ }).props.children;
137
+
138
+ assert.equal(bridge.props.nonce, "abc123");
139
+ assert.equal(script.props.nonce, "abc123");
140
+ assert.equal(noscript.props.nonce, undefined);
141
+ });
142
+ });
143
+
144
+ describe("client-side loader", () => {
145
+ function stub_document() {
146
+ const appended = [];
147
+ const by_id = new Map();
148
+
149
+ globalThis.document = {
150
+ createElement(tag) {
151
+ return { tag, id: "", textContent: "" };
152
+ },
153
+ getElementById(id) {
154
+ return by_id.get(id) ?? null;
155
+ },
156
+ head: {
157
+ appendChild(node) {
158
+ appended.push(node);
159
+ by_id.set(node.id, node);
160
+ },
161
+ },
162
+ };
163
+
164
+ return appended;
165
+ }
166
+
167
+ it("injects the canonical script once per pixel id", () => {
168
+ const appended = stub_document();
169
+ const id = "111111111111111";
170
+
171
+ try {
172
+ loadMetaPixel(id);
173
+ loadMetaPixel(id);
174
+
175
+ assert.equal(appended.length, 1);
176
+ assert.equal(appended[0].tag, "script");
177
+ assert.equal(
178
+ appended[0].textContent,
179
+ CANONICAL_SCRIPT.replaceAll(PIXEL_ID, id),
180
+ );
181
+ } finally {
182
+ delete globalThis.document;
183
+ clear_pixel_config();
184
+ }
185
+ });
186
+
187
+ it("registers our id on an fbq installed by another pixel", () => {
188
+ const calls = stub_fbq();
189
+ const appended = stub_document();
190
+
191
+ try {
192
+ loadMetaPixel("333333333333333");
193
+
194
+ assert.deepEqual(calls, [["init", "333333333333333"]]);
195
+ assert.equal(appended.length, 0);
196
+ } finally {
197
+ delete globalThis.fbq;
198
+ delete globalThis.document;
199
+ clear_pixel_config();
200
+ }
201
+ });
202
+
203
+ it("does nothing without a DOM", () => {
204
+ try {
205
+ assert.doesNotThrow(() => loadMetaPixel("222222222222222"));
206
+ } finally {
207
+ delete globalThis.fbq;
208
+ clear_pixel_config();
209
+ }
210
+ });
211
+ });
212
+
213
+ describe("signal() with multiple Meta Pixels", () => {
214
+ it("sends standard events only to Devalon's pixel with a dedup id", () => {
215
+ const calls = stub_fbq();
216
+ const logs = capture_logs();
217
+ set_signal_pixel_id(PIXEL_ID);
218
+
219
+ try {
220
+ // Simulate two other pixels initialized in the same shared queue.
221
+ globalThis.fbq("init", OTHER_PIXEL_ID);
222
+
223
+ const event = sendSignal(
224
+ "Purchase",
225
+ { value: 10, currency: "USD" },
226
+ { debug: true },
227
+ );
228
+
229
+ assert.deepEqual(calls.at(-1), [
230
+ "trackSingle",
231
+ PIXEL_ID,
232
+ "Purchase",
233
+ { value: 10, currency: "USD" },
234
+ { eventID: event.event_id },
235
+ ]);
236
+ assert.equal(
237
+ calls.some((call) => call[0] === "track" || call[0] === "trackCustom"),
238
+ false,
239
+ );
240
+ assert.match(logs.info[0], new RegExp(`Pixel ${PIXEL_ID} ✓`));
241
+ } finally {
242
+ logs.restore();
243
+ delete globalThis.fbq;
244
+ clear_pixel_config();
245
+ }
246
+ });
247
+
248
+ it("uses trackSingleCustom for names outside the standard catalog", () => {
249
+ const calls = stub_fbq();
250
+ set_signal_pixel_id(PIXEL_ID);
251
+
252
+ try {
253
+ const event = sendSignal("DevalonCredit", { form: "footer" });
254
+ assert.deepEqual(calls, [
255
+ [
256
+ "trackSingleCustom",
257
+ PIXEL_ID,
258
+ "DevalonCredit",
259
+ { form: "footer" },
260
+ { eventID: event.event_id },
261
+ ],
262
+ ]);
263
+ } finally {
264
+ delete globalThis.fbq;
265
+ clear_pixel_config();
266
+ }
267
+ });
268
+
269
+ it("reads the pixel id from the server-rendered bridge", () => {
270
+ const calls = stub_fbq();
271
+ globalThis.__DEVALON_SIGNAL_PIXEL_ID = PIXEL_ID;
272
+
273
+ try {
274
+ const event = sendSignal("Lead", {}, { eventId: "shared-id" });
275
+ assert.equal(calls[0][1], PIXEL_ID);
276
+ assert.equal(event.event_id, "shared-id");
277
+ } finally {
278
+ delete globalThis.fbq;
279
+ clear_pixel_config();
280
+ }
281
+ });
282
+
283
+ it("reports when no Devalon pixel id is known and sends nothing", () => {
284
+ const calls = stub_fbq();
285
+ const logs = capture_logs();
286
+ clear_pixel_config();
287
+
288
+ try {
289
+ const event = sendSignal("Purchase", {}, { debug: true });
290
+ assert.equal(calls.length, 0);
291
+ assert.match(logs.warn[0], /no Devalon pixel id configured/);
292
+ assert.match(logs.warn[0], new RegExp(event.event_id));
293
+ } finally {
294
+ logs.restore();
295
+ delete globalThis.fbq;
296
+ }
297
+ });
298
+
299
+ it("stays silent without the debug flag", () => {
300
+ stub_fbq();
301
+ set_signal_pixel_id(PIXEL_ID);
302
+ const logs = capture_logs();
303
+
304
+ try {
305
+ sendSignal("Purchase", { value: 1 });
306
+ assert.equal(logs.info.length, 0);
307
+ assert.equal(logs.warn.length, 0);
308
+ } finally {
309
+ logs.restore();
310
+ delete globalThis.fbq;
311
+ clear_pixel_config();
312
+ }
313
+ });
314
+
315
+ it("reports a missing fbq and tells the caller to use CAPI", () => {
316
+ set_signal_pixel_id(PIXEL_ID);
317
+ const logs = capture_logs();
318
+
319
+ try {
320
+ const event = sendSignal("Lead", {}, { debug: true });
321
+ assert.equal(logs.warn.length, 1);
322
+ assert.match(logs.warn[0], /MISSING/);
323
+ assert.match(logs.warn[0], /send via CAPI/);
324
+ assert.match(logs.warn[0], new RegExp(PIXEL_ID));
325
+ assert.match(logs.warn[0], new RegExp(event.event_id));
326
+ } finally {
327
+ logs.restore();
328
+ delete globalThis.fbq;
329
+ clear_pixel_config();
330
+ }
331
+ });
332
+
333
+ it("reports a blocked Pixel when only the stub is present", async () => {
334
+ const calls = stub_fbq({ ready: false });
335
+ const logs = capture_logs();
336
+ set_signal_pixel_id(PIXEL_ID);
337
+
338
+ try {
339
+ const event = sendSignal(
340
+ "Purchase",
341
+ { value: 5, currency: "USD" },
342
+ { debug: true },
343
+ );
344
+
345
+ assert.equal(calls.length, 1);
346
+ assert.equal(pixel_sdk_ready(), false);
347
+ await new Promise((resolve) =>
348
+ setTimeout(resolve, PIXEL_READY_CHECK_DELAY_MS + 50),
349
+ );
350
+
351
+ assert.match(logs.warn[0], /BLOCKED/);
352
+ assert.match(logs.warn[0], /fbevents_not_loaded/);
353
+ assert.match(logs.warn[0], /send via CAPI/);
354
+ assert.match(logs.warn[0], new RegExp(PIXEL_ID));
355
+ assert.match(logs.warn[0], new RegExp(event.event_id));
356
+ } finally {
357
+ logs.restore();
358
+ delete globalThis.fbq;
359
+ clear_pixel_config();
360
+ }
361
+ });
362
+ });
363
+
364
+ describe("event catalog", () => {
365
+ it("exposes a broad, duplicate-free custom catalog", () => {
366
+ assert.ok(DEVALON_CUSTOM_EVENT_NAMES.length > 100);
367
+ assert.equal(
368
+ new Set(DEVALON_CUSTOM_EVENT_NAMES).size,
369
+ DEVALON_CUSTOM_EVENT_NAMES.length,
370
+ );
371
+ for (const name of ["HeroCtaClick", "NewsletterSignup", "PaymentError"]) {
372
+ assert.ok(DEVALON_CUSTOM_EVENT_NAMES.includes(name));
373
+ }
374
+ });
375
+
376
+ it("maps the expected params for standard events", () => {
377
+ assert.deepEqual(META_REQUIRED_EVENT_PARAMS.Purchase, [
378
+ "value",
379
+ "currency",
380
+ ]);
381
+ assert.deepEqual(META_REQUIRED_EVENT_PARAMS.Search, ["search_string"]);
382
+ });
383
+
384
+ it("warns about missing standard params in debug but still sends", () => {
385
+ const calls = stub_fbq();
386
+ const logs = capture_logs();
387
+ set_signal_pixel_id(PIXEL_ID);
388
+
389
+ try {
390
+ const event = sendSignal("Purchase", {}, { debug: true });
391
+
392
+ assert.equal(calls.length, 1);
393
+ assert.match(logs.warn[0], /missing recommended params: value, currency/);
394
+ assert.equal(logs.info.length, 1);
395
+ assert.ok(event.event_id);
396
+ } finally {
397
+ logs.restore();
398
+ delete globalThis.fbq;
399
+ clear_pixel_config();
400
+ }
401
+ });
402
+
403
+ it("stays silent when all required params are present", () => {
404
+ stub_fbq();
405
+ set_signal_pixel_id(PIXEL_ID);
406
+ const logs = capture_logs();
407
+
408
+ try {
409
+ sendSignal(
410
+ "Purchase",
411
+ { value: 10, currency: "USD" },
412
+ { debug: true },
413
+ );
414
+ assert.equal(logs.warn.length, 0);
415
+ } finally {
416
+ logs.restore();
417
+ delete globalThis.fbq;
418
+ clear_pixel_config();
419
+ }
420
+ });
421
+
422
+ it("does not validate custom events or reject unknown names", () => {
423
+ const calls = stub_fbq();
424
+ set_signal_pixel_id(PIXEL_ID);
425
+ const logs = capture_logs();
426
+
427
+ try {
428
+ sendSignal("HeroCtaClick", {}, { debug: true });
429
+ sendSignal("BrandNewEvent123", {}, { debug: true });
430
+
431
+ assert.deepEqual(
432
+ calls.map((call) => call[0]),
433
+ ["trackSingleCustom", "trackSingleCustom"],
434
+ );
435
+ assert.equal(logs.warn.length, 0);
436
+ } finally {
437
+ logs.restore();
438
+ delete globalThis.fbq;
439
+ clear_pixel_config();
440
+ }
441
+ });
442
+ });
443
+
444
+ describe("event envelope", () => {
445
+ it("generates unique event ids", () => {
446
+ assert.notEqual(create_signal_event_id(), create_signal_event_id());
447
+ });
448
+
449
+ it("builds a vendor-neutral envelope", () => {
450
+ const event = create_signal_event("Purchase", { value: 10 }, "fixed-id");
451
+ assert.deepEqual(event, {
452
+ event_name: "Purchase",
453
+ event_id: "fixed-id",
454
+ params: { value: 10 },
455
+ emitted_at: event.emitted_at,
456
+ });
457
+ assert.equal(Number.isNaN(Date.parse(event.emitted_at)), false);
458
+ });
459
+ });