@1consent/react 0.1.0-beta.1 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,6 +35,23 @@ instead of becoming consumer dependencies.
35
35
  See the 1Consent developer reference for the complete API and integration
36
36
  guidance.
37
37
 
38
+ ## Execution timing
39
+
40
+ Pass the framework-associated `fastPathVersions` generated by `1c typegen`
41
+ and load the provider before governed resources. With a valid returning-visitor
42
+ mirror, a complete gate activates when its parse-time resolver runs, without
43
+ waiting for the asynchronous CMP runtime. Inline code runs synchronously when
44
+ no ordinary external dependency is pending. Ordinary external classic scripts
45
+ and their following instructions retain dependency order across gates;
46
+ explicit async/defer/module choices keep their nonblocking semantics.
47
+
48
+ This is an execution-order and consent guarantee, not a universal first-paint
49
+ deadline. Streamed content can paint before a later gate arrives, and permitted
50
+ external downloads can finish after paint. The integration does not hold page
51
+ rendering while waiting for vendors. Missing, expired or stale consent remains
52
+ inert until the CMP establishes current permission. SPA gates activate through
53
+ the inline engine's observer after mounting; they have no initial-paint promise.
54
+
38
55
  ## Before publication
39
56
 
40
57
  From this repository's root, pack the reviewed artifact into an existing directory:
package/dist/index.js CHANGED
@@ -366,7 +366,7 @@ function OneConsent(props) {
366
366
  }
367
367
 
368
368
  // ../react-fastpath/dist/generated/engine-source.js
369
- var REACT_FASTPATH_SOURCE = '"use strict";(()=>{(()=>{var re,oe,se,ce,ae,ie,le,ue;let c=window,g=document,I=["data-1c-service","data-1c-service-tag","data-1c-tag"],F="data-1c-category",H="data-1c-resolved",fe="data-1c-once",q="1consent:config",de=33696e6,ge=I.concat(F).map(e=>`template[${e}]:not([${H}])`).join(","),u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),pe=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)},_e=e=>{var r,i;let t=((r=e.services)!=null?r:[]).map(o=>{var l,s,N;return`${o.id}\\0${(l=o.name)!=null?l:""}\\0${(s=o.tag)!=null?s:""}\\0${(N=o.categoryId)!=null?N:""}\\0${o.essential?1:0}${o.catalogServiceKey?`\\0k\\0${o.catalogServiceKey}`:""}${o.usSensitive?"\\x001":""}`}).sort(),n=((i=e.categories)!=null?i:[]).map(o=>`${o.id}\\0${o.name}\\0${o.essential?1:0}`).sort();return pe(`s:${t.join("")}|c:${n.join("")}`)},me=((re=g.currentScript)==null?void 0:re.getAttribute("data-1c-app-id"))||"",ye=((oe=g.currentScript)==null?void 0:oe.getAttribute("data-1c-framework-versions"))||"{}",L={};try{L=JSON.parse(ye)}catch{}let a=c.__1CONSENT_CONFIG__,M=(se=a==null?void 0:a.consentEpoch)!=null?se:0,E=a==null?void 0:a.framework.type,h=a==null?void 0:a.machine,v=(ce=a==null?void 0:a.languages)==null?void 0:ce.primary,C=a!==void 0&&a.appId===me&&(E==="gdpr"||E==="tcf"||E==="us")&&(h==="P"||h==="S"||h==="D")&&typeof v=="string"&&v.length>0&&Number.isSafeInteger(M)&&M>=0,p=C?a:void 0,A=(ae=p==null?void 0:p.appId)!=null?ae:"",m=(ie=p==null?void 0:p.framework.id)!=null?ie:"",R=C&&E!=null?E:"",k=C&&h!=null?h:"",O=C&&v!=null?v:"",B=u(L)?L[m]:void 0,b=typeof B=="string"?B:"",y=C?M:-1,Q=JSON.stringify([A,m,R,k,O,b,y]),$=!1,D=!1,V,j,K,U=!1,X=()=>{var e,t;try{let n=c.__1CONSENT_CONFIG__;return $||D||!n||A.length===0||m.length===0||y<0||n.appId!==A||n.framework.id!==m||n.framework.type!==R||n.machine!==k||((e=n.languages)==null?void 0:e.primary)!==O||((t=n.consentEpoch)!=null?t:0)!==y||b.length===0?!1:((n!==V||n.services!==j||n.categories!==K)&&(V=n,j=n.services,K=n.categories,U=_e(n)===b),U)}catch{return!1}},S=c.__1CONSENT_REACT_FASTPATH__;if(S){try{if(S.runtimeKey===Q&&X()&&typeof S.reconcile=="function"&&S.reconcile())return}catch{}try{typeof S.destroy=="function"&&S.destroy()}catch{}c.__1CONSENT_REACT_FASTPATH__===S&&delete c.__1CONSENT_REACT_FASTPATH__}let f=null,d=null,_,w,x=()=>{},T=()=>$||D?!1:X()?!0:(D=!0,f=null,d=null,_==null||_.disconnect(),x(),c.__1CONSENT_REACT_FASTPATH__===w&&delete c.__1CONSENT_REACT_FASTPATH__,!1),Y=new Set,z=e=>{if(!e||typeof e!="object")return!1;for(let t of Object.values(e))if(typeof t!="boolean")return!1;return!0},Se=()=>navigator.globalPrivacyControl===!0;try{let e=localStorage.getItem("1consent");if(e&&A&&m&&b&&y>=0){let t=Date.now(),n=t+de,r=JSON.parse(e),i=u(r)&&u(r.apps)?r.apps[A]:void 0,o=u(i)?i.frameworks:void 0,l=u(o)?o[m]:void 0,s=u(l)?l.fastPath:void 0,N=u(l)?l.consent:void 0,J=u(l)&&"consentEpoch"in l?l.consentEpoch:0,be=u(l)&&l.type===R&&l.machine===k&&typeof J=="number"&&Number.isSafeInteger(J)&&J>=y&&l.primaryLanguage===O,Ne=(p==null?void 0:p.framework.type)!=="tcf"||u(N)&&typeof N.tcString=="string"&&((ue=(le=c.__1cTcf)==null?void 0:le.tcData)==null?void 0:ue.eventStatus)==="tcloaded"&&c.__1cTcf.tcData.tcString===N.tcString;u(r)&&r.schemaVersion===1&&be&&u(s)&&s.structuralVersion===b&&typeof s.consentEpoch=="number"&&Number.isSafeInteger(s.consentEpoch)&&s.consentEpoch>=y&&Number.isSafeInteger(t)&&t>=0&&Number.isSafeInteger(n)&&typeof s.expiresAt=="number"&&Number.isSafeInteger(s.expiresAt)&&s.expiresAt>=t&&s.expiresAt<=n&&z(s.services)&&Ne&&!(s.gpcRevocable===!0&&Se())&&(f=s.services,d=z(s.categories)?s.categories:{})}}catch{}let Te=e=>{for(let t of I){let n=e.getAttribute(t);if(n!==null)return n}return e.getAttribute(F)},Ee=e=>{for(let n of I){let r=e.getAttribute(n);if(r!==null)return f!==null&&f[r]===!0}let t=e.getAttribute(F);return t!==null?d!==null&&d[t]===!0:!1},he=e=>{let t=g.createElement("script");for(let n of e.attributes)t.setAttribute(n.name,n.value);return e.src?e.hasAttribute("async")||(t.async=!1):t.text=e.text||"",t},P=e=>{if(!T()||e.hasAttribute(H)||!Ee(e))return!1;e.setAttribute(H,"");let t=e.getAttribute(fe);if(t!==null){if(Y.has(t))return!1;Y.add(t)}let n=e.content.cloneNode(!0);if(!(n instanceof DocumentFragment))return!1;for(let r of n.querySelectorAll("script"))r.replaceWith(he(r));return e.parentNode&&e.parentNode.insertBefore(n,e.nextSibling),!0},G=e=>e instanceof HTMLTemplateElement,Z=8,Ae=()=>new Promise(e=>{let t=c.scheduler;t!=null&&t.postTask?t.postTask(e,{priority:"user-visible"}):setTimeout(e,0)}),W=e=>{if(!T())return[];let t=[];for(let i of e.querySelectorAll(ge))G(i)&&t.push(i);let n=[],r=0;for(;r<t.length&&r<Z;r++){let i=t[r];if(i&&P(i)){let o=Te(i);o!==null&&n.push(o)}}return r<t.length&&(async()=>{for(;r<t.length;r++){r%Z===0&&await Ae();let i=t[r];if(i)try{P(i)}catch{}}})(),n},ee=!1,te=()=>T()?g.readyState!=="loading"?W(g):(ee||(ee=!0,g.addEventListener("DOMContentLoaded",()=>W(g),{once:!0})),[]):[];_=new MutationObserver(e=>{if(!(!T()||g.readyState==="loading"||f===null&&d===null))for(let t of e)for(let n of t.addedNodes)G(n)?P(n):n instanceof Element&&W(n)}),_.observe(g.documentElement,{childList:!0,subtree:!0});let ne=()=>{V=void 0,j=void 0,K=void 0,T()};w={appId:A,frameworkId:m,frameworkType:R,machine:k,primaryLanguage:O,structuralVersion:b,consentEpoch:y,runtimeKey:Q,apply(e,t){if(!T())return[];f=f||{},d=d||{};for(let n of Object.keys(e))f[n]=e[n]===!0;if(t)for(let n of Object.keys(t))d[n]=t[n]===!0;return te()},resolve(e){return e!==null&&G(e)?P(e):!1},reconcile:T,destroy:()=>{$=!0,f=null,d=null,_==null||_.disconnect(),x(),c.__1CONSENT_REACT_FASTPATH__===w&&delete c.__1CONSENT_REACT_FASTPATH__}},c.__1CONSENT_REACT_FASTPATH__=w,c.addEventListener(q,ne),x=()=>c.removeEventListener(q,ne),(f!==null||d!==null)&&te()})();})();';
369
+ var REACT_FASTPATH_SOURCE = '"use strict";(()=>{var He=1440*60*1e3;function De(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function Fe(r){return typeof r=="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(r)&&!/^[\\da-f]{8}(-[\\da-f]{4}){3}-[\\da-f]{12}$/i.test(r)}function se(r){return De(r)&&[r.appId,r.frameworkId].every(Fe)}function Oe(){let r=[],c=!1,T=!1,E,h,F=()=>{var p;if(!(c||T)){for(c=!0;!T&&r.length>0;){let d=r.shift();if(!d)break;if(!d.slot.isConnected||!d.allowed())continue;let s=d.recreate(d.source),a=s.hasAttribute("type")?s.type.trim().toLowerCase():s.getAttribute("language")?`text/${(p=s.getAttribute("language"))==null?void 0:p.trim().toLowerCase()}`:"",H=a===""||/^(?:application|text)\\/(?:x-)?(?:java|ecma)script$/.test(a)||/^text\\/(?:javascript1\\.[0-5]|jscript|livescript)$/.test(a);if(s.src&&H&&!s.hasAttribute("async")&&!s.defer&&!s.noModule){let O=new MutationObserver(()=>{s.isConnected||y()}),y=()=>{E===b&&(b(),c=!1,F())},b=()=>{O.disconnect(),s.removeEventListener("load",y),s.removeEventListener("error",y),E=void 0,h=void 0};E=b,h=()=>{(!s.isConnected||!d.allowed())&&(b(),c=!1)},s.addEventListener("load",y),s.addEventListener("error",y),O.observe(d.slot.ownerDocument,{childList:!0,subtree:!0}),d.slot.replaceWith(s),s.isConnected||y();return}d.slot.replaceWith(s)}c=!1}};return{activate(p,d,s,a){let H=Array.from(p.querySelectorAll("script"),y=>{let b=document.createComment("1c-script");return y.replaceWith(b),{source:y,slot:b,allowed:s,recreate:a}}),O=!c;c=!0,r.push(...H);try{d(p)}finally{O&&(c=!1),F()}},setPaused(p){T=p},recheck(){if(!T){h==null||h();for(let p=r.length-1;p>=0;p--){let d=r[p];d&&(!d.slot.isConnected||!d.allowed())&&r.splice(p,1)}}},flush:F,clear(){r.length=0,E==null||E(),c=!1}}}(()=>{var he,be,Te,Ce,Ie,Ne,ve;let r=window,c=document,T=["data-1c-service","data-1c-service-tag","data-1c-tag"],E="data-1c-category",h="data-1c-resolved",F="data-1c-once",p="1consent:config",d=33696e6,s=T.concat(E).map(e=>`template[${e}]:not([${h}])`).join(","),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),H=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)},O=e=>{var o,i;let t=((o=e.services)!=null?o:[]).map(u=>{var m,l,D;return`${u.id}\\0${(m=u.name)!=null?m:""}\\0${(l=u.tag)!=null?l:""}\\0${(D=u.categoryId)!=null?D:""}\\0${u.essential?1:0}${u.catalogServiceKey?`\\0k\\0${u.catalogServiceKey}`:""}${u.usSensitive?"\\x001":""}`}).sort(),n=((i=e.categories)!=null?i:[]).map(u=>`${u.id}\\0${u.name}\\0${u.essential?1:0}`).sort();return H(`s:${t.join("")}|c:${n.join("")}`)},y=((he=c.currentScript)==null?void 0:he.getAttribute("data-1c-app-id"))||"",b=((be=c.currentScript)==null?void 0:be.getAttribute("data-1c-framework-versions"))||"{}",q={};try{q=JSON.parse(b)}catch{}let f=r.__1CONSENT_CONFIG__,j=f==null?void 0:f.publicIdentity,z=(Te=f==null?void 0:f.consentEpoch)!=null?Te:0,R=f==null?void 0:f.framework.type,w=f==null?void 0:f.machine,$=(Ce=f==null?void 0:f.languages)==null?void 0:Ce.primary,N=f!==void 0&&se(j)&&j.appId===y&&(R==="gdpr"||R==="tcf"||R==="us")&&(w==="P"||w==="S"||w==="D")&&typeof $=="string"&&$.length>0&&Number.isSafeInteger(z)&&z>=0,g=N?f:void 0,k=(Ie=g==null?void 0:g.appId)!=null?Ie:"",P=(Ne=g==null?void 0:g.framework.id)!=null?Ne:"",V=N&&R!=null?R:"",G=N&&w!=null?w:"",B=N&&$!=null?$:"",ie=N?j.appId:"",J=N?j.frameworkId:"",ce=a(q)?q[J]:void 0,L=typeof ce=="string"?ce:"",v=N?z:-1,ae=JSON.stringify([k,P,ie,J,V,G,B,L,v]),Y=!1,X=!1,Q,Z,ee,ue=!1,le=()=>{var e,t;try{let n=r.__1CONSENT_CONFIG__;return Y||X||!n||k.length===0||P.length===0||v<0||n.appId!==k||n.framework.id!==P||!se(n.publicIdentity)||n.publicIdentity.appId!==ie||n.publicIdentity.frameworkId!==J||n.framework.type!==V||n.machine!==G||((e=n.languages)==null?void 0:e.primary)!==B||((t=n.consentEpoch)!=null?t:0)!==v||L.length===0?!1:((n!==Q||n.services!==Z||n.categories!==ee)&&(Q=n,Z=n.services,ee=n.categories,ue=O(n)===L),ue)}catch{return!1}},A=r.__1CONSENT_REACT_FASTPATH__;if(A){try{if(A.runtimeKey===ae&&A.supportsPendingConsent===!0&&typeof A.updateConsent=="function"&&typeof A.promote=="function"&&le()&&typeof A.reconcile=="function"&&A.reconcile())return}catch{}try{typeof A.destroy=="function"&&A.destroy()}catch{}r.__1CONSENT_REACT_FASTPATH__===A&&delete r.__1CONSENT_REACT_FASTPATH__}let _=null,S=null,x,de=!1,C,M=Oe(),U,te=()=>{},I=()=>Y||X?!1:le()?!0:(X=!0,M.clear(),_=null,S=null,C==null||C.disconnect(),te(),r.__1CONSENT_REACT_FASTPATH__===U&&delete r.__1CONSENT_REACT_FASTPATH__,!1),fe=new Set,pe=e=>{if(!e||typeof e!="object")return!1;for(let t of Object.values(e))if(typeof t!="boolean")return!1;return!0},Re=()=>navigator.globalPrivacyControl===!0;try{let e=localStorage.getItem("1consent");if(e&&k&&P&&L&&v>=0){let t=Date.now(),n=t+d,o=JSON.parse(e),i=a(o)&&a(o.apps)?o.apps[k]:void 0,u=a(i)?i.frameworks:void 0,m=a(u)?u[P]:void 0,l=a(m)?m.fastPath:void 0,D=a(m)?m.consent:void 0,oe=a(m)&&"consentEpoch"in m?m.consentEpoch:0,xe=a(m)&&m.type===V&&m.machine===G&&typeof oe=="number"&&Number.isSafeInteger(oe)&&oe>=v&&m.primaryLanguage===B,W=(g==null?void 0:g.framework.type)==="tcf"?(ve=r.__1cTcf)==null?void 0:ve.tcData:void 0,Me=(g==null?void 0:g.framework.type)!=="tcf"||a(D)&&typeof D.tcString=="string"&&(W==null?void 0:W.eventStatus)==="tcloaded"&&W.tcString===D.tcString;a(o)&&o.schemaVersion===1&&xe&&a(l)&&l.structuralVersion===L&&typeof l.consentEpoch=="number"&&Number.isSafeInteger(l.consentEpoch)&&l.consentEpoch>=v&&Number.isSafeInteger(t)&&t>=0&&Number.isSafeInteger(n)&&typeof l.expiresAt=="number"&&Number.isSafeInteger(l.expiresAt)&&l.expiresAt>=t&&l.expiresAt<=n&&pe(l.services)&&Me&&!(l.gpcRevocable===!0&&Re())&&(x=l.expiresAt,_=l.services,S=pe(l.categories)?l.categories:{})}}catch{}let we=e=>{for(let t of T){let n=e.getAttribute(t);if(n!==null)return n}return e.getAttribute(E)},me=e=>{if(de||x!==void 0&&Date.now()>x)return!1;for(let n of T){let o=e.getAttribute(n);if(o!==null)return _!==null&&_[o]===!0}let t=e.getAttribute(E);return t!==null?S!==null&&S[t]===!0:!1},ke=e=>{let t=c.createElement("script");for(let n of e.attributes)t.setAttribute(n.name,n.value);return e.src?e.hasAttribute("async")||(t.async=!1):t.text=e.text||"",t},K=e=>{if(!I()||e.hasAttribute(h)||!me(e))return!1;e.setAttribute(h,"");let t=e.getAttribute(F);if(t!==null){if(fe.has(t))return!1;fe.add(t)}let n=e.content.cloneNode(!0);return n instanceof DocumentFragment?(M.activate(n,o=>e.after(o),()=>e.isConnected&&I()&&me(e),ke),!0):!1},ne=e=>e instanceof HTMLTemplateElement,ge=8,Pe=()=>new Promise(e=>{let t=r.scheduler;t!=null&&t.postTask?t.postTask(e,{priority:"user-visible"}):setTimeout(e,0)}),re=e=>{if(!I())return[];let t=[];for(let i of e.querySelectorAll(s))ne(i)&&t.push(i);let n=[],o=0;for(;o<t.length&&o<ge;o++){let i=t[o];if(i&&K(i)){let u=we(i);u!==null&&n.push(u)}}return o<t.length&&(async()=>{for(;o<t.length;o++){o%ge===0&&await Pe();let i=t[o];if(i)try{K(i)}catch{}}})(),n},ye=!1,_e=()=>I()?c.readyState!=="loading"?re(c):(ye||(ye=!0,c.addEventListener("DOMContentLoaded",()=>re(c),{once:!0})),[]):[];C=new MutationObserver(e=>{if(!(!I()||c.readyState==="loading"||_===null&&S===null))for(let t of e)for(let n of t.addedNodes)ne(n)?K(n):n instanceof Element&&re(n)}),C.observe(c.documentElement,{childList:!0,subtree:!0});let Se=()=>{Q=void 0,Z=void 0,ee=void 0,I()},Le=()=>{Y=!0,M.clear(),_=null,S=null,C==null||C.disconnect(),te(),r.__1CONSENT_REACT_FASTPATH__===U&&delete r.__1CONSENT_REACT_FASTPATH__},Ee=(e,t,n,o=!1)=>{if(I()){de=o,M.setPaused(o),x!==void 0&&Date.now()>x&&(_=null,S=null),n!==void 0&&(x=n===0?void 0:n),_=_||{},S=S||{};for(let i of Object.keys(e))_[i]=e[i]===!0;if(t)for(let i of Object.keys(t))S[i]=t[i]===!0;M.recheck()}},Ae=()=>(M.flush(),_e());U={appId:k,frameworkId:P,frameworkType:V,machine:G,primaryLanguage:B,structuralVersion:L,consentEpoch:v,runtimeKey:ae,apply(e,t){return Ee(e,t),Ae()},supportsPendingConsent:!0,updateConsent:Ee,promote:Ae,resolve(e){return e!==null&&ne(e)?K(e):!1},reconcile:I,destroy:Le},r.__1CONSENT_REACT_FASTPATH__=U,r.addEventListener(p,Se),te=()=>r.removeEventListener(p,Se),(_!==null||S!==null)&&_e()})();})();';
370
370
 
371
371
  // src/provider.tsx
372
372
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -16,14 +16,17 @@
16
16
  * React fastpath. React never reconciles inside `dangerouslySetInnerHTML`
17
17
  * content, so the engine can insert promoted nodes there without hydration
18
18
  * mismatches. On the server-rendered page the inline call executes at HTML
19
- * parse time (before first paint); on SPA mounts innerHTML scripts never run
20
- * and the engine's MutationObserver promotes the template instead.
19
+ * parse time when the complete gate is encountered; on SPA mounts innerHTML
20
+ * scripts never run and the engine's MutationObserver promotes the template.
21
+ * Parsing may continue after the browser's first paint. Neither streamed
22
+ * gate arrival nor an external download has a universal before-paint deadline.
21
23
  *
22
24
  * Head placement caveat: the wrapper `<div>` is not valid inside `<head>` —
23
25
  * the HTML parser silently ends `<head>` at the div and reparents it (and
24
26
  * everything after it) into `<body>`, which triggers a dev-mode hydration
25
- * mismatch. Promotion works either way, but top-of-`<body>` placement is
26
- * just as early and keeps the markup valid.
27
+ * mismatch. Use body placement with the bootstrap before governed resources.
28
+ * Earlier gate placement reduces activation latency without promising a
29
+ * first-paint deadline.
27
30
  */
28
31
  import type { ReactNode } from "react";
29
32
  import type { RegisteredCategoryName, RegisteredServiceName } from "./types.js";
@@ -260,7 +260,7 @@ function OneConsent(props) {
260
260
  }
261
261
 
262
262
  // ../react-fastpath/dist/generated/engine-source.js
263
- var REACT_FASTPATH_SOURCE = '"use strict";(()=>{(()=>{var re,oe,se,ce,ae,ie,le,ue;let c=window,g=document,I=["data-1c-service","data-1c-service-tag","data-1c-tag"],F="data-1c-category",H="data-1c-resolved",fe="data-1c-once",q="1consent:config",de=33696e6,ge=I.concat(F).map(e=>`template[${e}]:not([${H}])`).join(","),u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),pe=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)},_e=e=>{var r,i;let t=((r=e.services)!=null?r:[]).map(o=>{var l,s,N;return`${o.id}\\0${(l=o.name)!=null?l:""}\\0${(s=o.tag)!=null?s:""}\\0${(N=o.categoryId)!=null?N:""}\\0${o.essential?1:0}${o.catalogServiceKey?`\\0k\\0${o.catalogServiceKey}`:""}${o.usSensitive?"\\x001":""}`}).sort(),n=((i=e.categories)!=null?i:[]).map(o=>`${o.id}\\0${o.name}\\0${o.essential?1:0}`).sort();return pe(`s:${t.join("")}|c:${n.join("")}`)},me=((re=g.currentScript)==null?void 0:re.getAttribute("data-1c-app-id"))||"",ye=((oe=g.currentScript)==null?void 0:oe.getAttribute("data-1c-framework-versions"))||"{}",L={};try{L=JSON.parse(ye)}catch{}let a=c.__1CONSENT_CONFIG__,M=(se=a==null?void 0:a.consentEpoch)!=null?se:0,E=a==null?void 0:a.framework.type,h=a==null?void 0:a.machine,v=(ce=a==null?void 0:a.languages)==null?void 0:ce.primary,C=a!==void 0&&a.appId===me&&(E==="gdpr"||E==="tcf"||E==="us")&&(h==="P"||h==="S"||h==="D")&&typeof v=="string"&&v.length>0&&Number.isSafeInteger(M)&&M>=0,p=C?a:void 0,A=(ae=p==null?void 0:p.appId)!=null?ae:"",m=(ie=p==null?void 0:p.framework.id)!=null?ie:"",R=C&&E!=null?E:"",k=C&&h!=null?h:"",O=C&&v!=null?v:"",B=u(L)?L[m]:void 0,b=typeof B=="string"?B:"",y=C?M:-1,Q=JSON.stringify([A,m,R,k,O,b,y]),$=!1,D=!1,V,j,K,U=!1,X=()=>{var e,t;try{let n=c.__1CONSENT_CONFIG__;return $||D||!n||A.length===0||m.length===0||y<0||n.appId!==A||n.framework.id!==m||n.framework.type!==R||n.machine!==k||((e=n.languages)==null?void 0:e.primary)!==O||((t=n.consentEpoch)!=null?t:0)!==y||b.length===0?!1:((n!==V||n.services!==j||n.categories!==K)&&(V=n,j=n.services,K=n.categories,U=_e(n)===b),U)}catch{return!1}},S=c.__1CONSENT_REACT_FASTPATH__;if(S){try{if(S.runtimeKey===Q&&X()&&typeof S.reconcile=="function"&&S.reconcile())return}catch{}try{typeof S.destroy=="function"&&S.destroy()}catch{}c.__1CONSENT_REACT_FASTPATH__===S&&delete c.__1CONSENT_REACT_FASTPATH__}let f=null,d=null,_,w,x=()=>{},T=()=>$||D?!1:X()?!0:(D=!0,f=null,d=null,_==null||_.disconnect(),x(),c.__1CONSENT_REACT_FASTPATH__===w&&delete c.__1CONSENT_REACT_FASTPATH__,!1),Y=new Set,z=e=>{if(!e||typeof e!="object")return!1;for(let t of Object.values(e))if(typeof t!="boolean")return!1;return!0},Se=()=>navigator.globalPrivacyControl===!0;try{let e=localStorage.getItem("1consent");if(e&&A&&m&&b&&y>=0){let t=Date.now(),n=t+de,r=JSON.parse(e),i=u(r)&&u(r.apps)?r.apps[A]:void 0,o=u(i)?i.frameworks:void 0,l=u(o)?o[m]:void 0,s=u(l)?l.fastPath:void 0,N=u(l)?l.consent:void 0,J=u(l)&&"consentEpoch"in l?l.consentEpoch:0,be=u(l)&&l.type===R&&l.machine===k&&typeof J=="number"&&Number.isSafeInteger(J)&&J>=y&&l.primaryLanguage===O,Ne=(p==null?void 0:p.framework.type)!=="tcf"||u(N)&&typeof N.tcString=="string"&&((ue=(le=c.__1cTcf)==null?void 0:le.tcData)==null?void 0:ue.eventStatus)==="tcloaded"&&c.__1cTcf.tcData.tcString===N.tcString;u(r)&&r.schemaVersion===1&&be&&u(s)&&s.structuralVersion===b&&typeof s.consentEpoch=="number"&&Number.isSafeInteger(s.consentEpoch)&&s.consentEpoch>=y&&Number.isSafeInteger(t)&&t>=0&&Number.isSafeInteger(n)&&typeof s.expiresAt=="number"&&Number.isSafeInteger(s.expiresAt)&&s.expiresAt>=t&&s.expiresAt<=n&&z(s.services)&&Ne&&!(s.gpcRevocable===!0&&Se())&&(f=s.services,d=z(s.categories)?s.categories:{})}}catch{}let Te=e=>{for(let t of I){let n=e.getAttribute(t);if(n!==null)return n}return e.getAttribute(F)},Ee=e=>{for(let n of I){let r=e.getAttribute(n);if(r!==null)return f!==null&&f[r]===!0}let t=e.getAttribute(F);return t!==null?d!==null&&d[t]===!0:!1},he=e=>{let t=g.createElement("script");for(let n of e.attributes)t.setAttribute(n.name,n.value);return e.src?e.hasAttribute("async")||(t.async=!1):t.text=e.text||"",t},P=e=>{if(!T()||e.hasAttribute(H)||!Ee(e))return!1;e.setAttribute(H,"");let t=e.getAttribute(fe);if(t!==null){if(Y.has(t))return!1;Y.add(t)}let n=e.content.cloneNode(!0);if(!(n instanceof DocumentFragment))return!1;for(let r of n.querySelectorAll("script"))r.replaceWith(he(r));return e.parentNode&&e.parentNode.insertBefore(n,e.nextSibling),!0},G=e=>e instanceof HTMLTemplateElement,Z=8,Ae=()=>new Promise(e=>{let t=c.scheduler;t!=null&&t.postTask?t.postTask(e,{priority:"user-visible"}):setTimeout(e,0)}),W=e=>{if(!T())return[];let t=[];for(let i of e.querySelectorAll(ge))G(i)&&t.push(i);let n=[],r=0;for(;r<t.length&&r<Z;r++){let i=t[r];if(i&&P(i)){let o=Te(i);o!==null&&n.push(o)}}return r<t.length&&(async()=>{for(;r<t.length;r++){r%Z===0&&await Ae();let i=t[r];if(i)try{P(i)}catch{}}})(),n},ee=!1,te=()=>T()?g.readyState!=="loading"?W(g):(ee||(ee=!0,g.addEventListener("DOMContentLoaded",()=>W(g),{once:!0})),[]):[];_=new MutationObserver(e=>{if(!(!T()||g.readyState==="loading"||f===null&&d===null))for(let t of e)for(let n of t.addedNodes)G(n)?P(n):n instanceof Element&&W(n)}),_.observe(g.documentElement,{childList:!0,subtree:!0});let ne=()=>{V=void 0,j=void 0,K=void 0,T()};w={appId:A,frameworkId:m,frameworkType:R,machine:k,primaryLanguage:O,structuralVersion:b,consentEpoch:y,runtimeKey:Q,apply(e,t){if(!T())return[];f=f||{},d=d||{};for(let n of Object.keys(e))f[n]=e[n]===!0;if(t)for(let n of Object.keys(t))d[n]=t[n]===!0;return te()},resolve(e){return e!==null&&G(e)?P(e):!1},reconcile:T,destroy:()=>{$=!0,f=null,d=null,_==null||_.disconnect(),x(),c.__1CONSENT_REACT_FASTPATH__===w&&delete c.__1CONSENT_REACT_FASTPATH__}},c.__1CONSENT_REACT_FASTPATH__=w,c.addEventListener(q,ne),x=()=>c.removeEventListener(q,ne),(f!==null||d!==null)&&te()})();})();';
263
+ var REACT_FASTPATH_SOURCE = '"use strict";(()=>{var He=1440*60*1e3;function De(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function Fe(r){return typeof r=="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(r)&&!/^[\\da-f]{8}(-[\\da-f]{4}){3}-[\\da-f]{12}$/i.test(r)}function se(r){return De(r)&&[r.appId,r.frameworkId].every(Fe)}function Oe(){let r=[],c=!1,T=!1,E,h,F=()=>{var p;if(!(c||T)){for(c=!0;!T&&r.length>0;){let d=r.shift();if(!d)break;if(!d.slot.isConnected||!d.allowed())continue;let s=d.recreate(d.source),a=s.hasAttribute("type")?s.type.trim().toLowerCase():s.getAttribute("language")?`text/${(p=s.getAttribute("language"))==null?void 0:p.trim().toLowerCase()}`:"",H=a===""||/^(?:application|text)\\/(?:x-)?(?:java|ecma)script$/.test(a)||/^text\\/(?:javascript1\\.[0-5]|jscript|livescript)$/.test(a);if(s.src&&H&&!s.hasAttribute("async")&&!s.defer&&!s.noModule){let O=new MutationObserver(()=>{s.isConnected||y()}),y=()=>{E===b&&(b(),c=!1,F())},b=()=>{O.disconnect(),s.removeEventListener("load",y),s.removeEventListener("error",y),E=void 0,h=void 0};E=b,h=()=>{(!s.isConnected||!d.allowed())&&(b(),c=!1)},s.addEventListener("load",y),s.addEventListener("error",y),O.observe(d.slot.ownerDocument,{childList:!0,subtree:!0}),d.slot.replaceWith(s),s.isConnected||y();return}d.slot.replaceWith(s)}c=!1}};return{activate(p,d,s,a){let H=Array.from(p.querySelectorAll("script"),y=>{let b=document.createComment("1c-script");return y.replaceWith(b),{source:y,slot:b,allowed:s,recreate:a}}),O=!c;c=!0,r.push(...H);try{d(p)}finally{O&&(c=!1),F()}},setPaused(p){T=p},recheck(){if(!T){h==null||h();for(let p=r.length-1;p>=0;p--){let d=r[p];d&&(!d.slot.isConnected||!d.allowed())&&r.splice(p,1)}}},flush:F,clear(){r.length=0,E==null||E(),c=!1}}}(()=>{var he,be,Te,Ce,Ie,Ne,ve;let r=window,c=document,T=["data-1c-service","data-1c-service-tag","data-1c-tag"],E="data-1c-category",h="data-1c-resolved",F="data-1c-once",p="1consent:config",d=33696e6,s=T.concat(E).map(e=>`template[${e}]:not([${h}])`).join(","),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),H=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)},O=e=>{var o,i;let t=((o=e.services)!=null?o:[]).map(u=>{var m,l,D;return`${u.id}\\0${(m=u.name)!=null?m:""}\\0${(l=u.tag)!=null?l:""}\\0${(D=u.categoryId)!=null?D:""}\\0${u.essential?1:0}${u.catalogServiceKey?`\\0k\\0${u.catalogServiceKey}`:""}${u.usSensitive?"\\x001":""}`}).sort(),n=((i=e.categories)!=null?i:[]).map(u=>`${u.id}\\0${u.name}\\0${u.essential?1:0}`).sort();return H(`s:${t.join("")}|c:${n.join("")}`)},y=((he=c.currentScript)==null?void 0:he.getAttribute("data-1c-app-id"))||"",b=((be=c.currentScript)==null?void 0:be.getAttribute("data-1c-framework-versions"))||"{}",q={};try{q=JSON.parse(b)}catch{}let f=r.__1CONSENT_CONFIG__,j=f==null?void 0:f.publicIdentity,z=(Te=f==null?void 0:f.consentEpoch)!=null?Te:0,R=f==null?void 0:f.framework.type,w=f==null?void 0:f.machine,$=(Ce=f==null?void 0:f.languages)==null?void 0:Ce.primary,N=f!==void 0&&se(j)&&j.appId===y&&(R==="gdpr"||R==="tcf"||R==="us")&&(w==="P"||w==="S"||w==="D")&&typeof $=="string"&&$.length>0&&Number.isSafeInteger(z)&&z>=0,g=N?f:void 0,k=(Ie=g==null?void 0:g.appId)!=null?Ie:"",P=(Ne=g==null?void 0:g.framework.id)!=null?Ne:"",V=N&&R!=null?R:"",G=N&&w!=null?w:"",B=N&&$!=null?$:"",ie=N?j.appId:"",J=N?j.frameworkId:"",ce=a(q)?q[J]:void 0,L=typeof ce=="string"?ce:"",v=N?z:-1,ae=JSON.stringify([k,P,ie,J,V,G,B,L,v]),Y=!1,X=!1,Q,Z,ee,ue=!1,le=()=>{var e,t;try{let n=r.__1CONSENT_CONFIG__;return Y||X||!n||k.length===0||P.length===0||v<0||n.appId!==k||n.framework.id!==P||!se(n.publicIdentity)||n.publicIdentity.appId!==ie||n.publicIdentity.frameworkId!==J||n.framework.type!==V||n.machine!==G||((e=n.languages)==null?void 0:e.primary)!==B||((t=n.consentEpoch)!=null?t:0)!==v||L.length===0?!1:((n!==Q||n.services!==Z||n.categories!==ee)&&(Q=n,Z=n.services,ee=n.categories,ue=O(n)===L),ue)}catch{return!1}},A=r.__1CONSENT_REACT_FASTPATH__;if(A){try{if(A.runtimeKey===ae&&A.supportsPendingConsent===!0&&typeof A.updateConsent=="function"&&typeof A.promote=="function"&&le()&&typeof A.reconcile=="function"&&A.reconcile())return}catch{}try{typeof A.destroy=="function"&&A.destroy()}catch{}r.__1CONSENT_REACT_FASTPATH__===A&&delete r.__1CONSENT_REACT_FASTPATH__}let _=null,S=null,x,de=!1,C,M=Oe(),U,te=()=>{},I=()=>Y||X?!1:le()?!0:(X=!0,M.clear(),_=null,S=null,C==null||C.disconnect(),te(),r.__1CONSENT_REACT_FASTPATH__===U&&delete r.__1CONSENT_REACT_FASTPATH__,!1),fe=new Set,pe=e=>{if(!e||typeof e!="object")return!1;for(let t of Object.values(e))if(typeof t!="boolean")return!1;return!0},Re=()=>navigator.globalPrivacyControl===!0;try{let e=localStorage.getItem("1consent");if(e&&k&&P&&L&&v>=0){let t=Date.now(),n=t+d,o=JSON.parse(e),i=a(o)&&a(o.apps)?o.apps[k]:void 0,u=a(i)?i.frameworks:void 0,m=a(u)?u[P]:void 0,l=a(m)?m.fastPath:void 0,D=a(m)?m.consent:void 0,oe=a(m)&&"consentEpoch"in m?m.consentEpoch:0,xe=a(m)&&m.type===V&&m.machine===G&&typeof oe=="number"&&Number.isSafeInteger(oe)&&oe>=v&&m.primaryLanguage===B,W=(g==null?void 0:g.framework.type)==="tcf"?(ve=r.__1cTcf)==null?void 0:ve.tcData:void 0,Me=(g==null?void 0:g.framework.type)!=="tcf"||a(D)&&typeof D.tcString=="string"&&(W==null?void 0:W.eventStatus)==="tcloaded"&&W.tcString===D.tcString;a(o)&&o.schemaVersion===1&&xe&&a(l)&&l.structuralVersion===L&&typeof l.consentEpoch=="number"&&Number.isSafeInteger(l.consentEpoch)&&l.consentEpoch>=v&&Number.isSafeInteger(t)&&t>=0&&Number.isSafeInteger(n)&&typeof l.expiresAt=="number"&&Number.isSafeInteger(l.expiresAt)&&l.expiresAt>=t&&l.expiresAt<=n&&pe(l.services)&&Me&&!(l.gpcRevocable===!0&&Re())&&(x=l.expiresAt,_=l.services,S=pe(l.categories)?l.categories:{})}}catch{}let we=e=>{for(let t of T){let n=e.getAttribute(t);if(n!==null)return n}return e.getAttribute(E)},me=e=>{if(de||x!==void 0&&Date.now()>x)return!1;for(let n of T){let o=e.getAttribute(n);if(o!==null)return _!==null&&_[o]===!0}let t=e.getAttribute(E);return t!==null?S!==null&&S[t]===!0:!1},ke=e=>{let t=c.createElement("script");for(let n of e.attributes)t.setAttribute(n.name,n.value);return e.src?e.hasAttribute("async")||(t.async=!1):t.text=e.text||"",t},K=e=>{if(!I()||e.hasAttribute(h)||!me(e))return!1;e.setAttribute(h,"");let t=e.getAttribute(F);if(t!==null){if(fe.has(t))return!1;fe.add(t)}let n=e.content.cloneNode(!0);return n instanceof DocumentFragment?(M.activate(n,o=>e.after(o),()=>e.isConnected&&I()&&me(e),ke),!0):!1},ne=e=>e instanceof HTMLTemplateElement,ge=8,Pe=()=>new Promise(e=>{let t=r.scheduler;t!=null&&t.postTask?t.postTask(e,{priority:"user-visible"}):setTimeout(e,0)}),re=e=>{if(!I())return[];let t=[];for(let i of e.querySelectorAll(s))ne(i)&&t.push(i);let n=[],o=0;for(;o<t.length&&o<ge;o++){let i=t[o];if(i&&K(i)){let u=we(i);u!==null&&n.push(u)}}return o<t.length&&(async()=>{for(;o<t.length;o++){o%ge===0&&await Pe();let i=t[o];if(i)try{K(i)}catch{}}})(),n},ye=!1,_e=()=>I()?c.readyState!=="loading"?re(c):(ye||(ye=!0,c.addEventListener("DOMContentLoaded",()=>re(c),{once:!0})),[]):[];C=new MutationObserver(e=>{if(!(!I()||c.readyState==="loading"||_===null&&S===null))for(let t of e)for(let n of t.addedNodes)ne(n)?K(n):n instanceof Element&&re(n)}),C.observe(c.documentElement,{childList:!0,subtree:!0});let Se=()=>{Q=void 0,Z=void 0,ee=void 0,I()},Le=()=>{Y=!0,M.clear(),_=null,S=null,C==null||C.disconnect(),te(),r.__1CONSENT_REACT_FASTPATH__===U&&delete r.__1CONSENT_REACT_FASTPATH__},Ee=(e,t,n,o=!1)=>{if(I()){de=o,M.setPaused(o),x!==void 0&&Date.now()>x&&(_=null,S=null),n!==void 0&&(x=n===0?void 0:n),_=_||{},S=S||{};for(let i of Object.keys(e))_[i]=e[i]===!0;if(t)for(let i of Object.keys(t))S[i]=t[i]===!0;M.recheck()}},Ae=()=>(M.flush(),_e());U={appId:k,frameworkId:P,frameworkType:V,machine:G,primaryLanguage:B,structuralVersion:L,consentEpoch:v,runtimeKey:ae,apply(e,t){return Ee(e,t),Ae()},supportsPendingConsent:!0,updateConsent:Ee,promote:Ae,resolve(e){return e!==null&&ne(e)?K(e):!1},reconcile:I,destroy:Le},r.__1CONSENT_REACT_FASTPATH__=U,r.addEventListener(p,Se),te=()=>r.removeEventListener(p,Se),(_!==null||S!==null)&&_e()})();})();';
264
264
 
265
265
  // src/provider.tsx
266
266
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1consent/react",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "React 19 consent components and hooks for the 1Consent CMP.",
5
5
  "type": "module",
6
6
  "sideEffects": false,