@builder.io/sdk-react 4.0.5 → 4.0.6
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/lib/browser/blocks-exports.cjs +1 -1
- package/lib/browser/blocks-exports.mjs +2 -2
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/server-entry-5449a575.cjs +2 -0
- package/lib/browser/{server-entry-a14e875b.js → server-entry-79285592.js} +24 -24
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-fc5895b3.js → accordion-87ad8263.js} +1 -1
- package/lib/edge/{accordion-7bf0ff52.cjs → accordion-f7e030d5.cjs} +1 -1
- package/lib/edge/{blocks-52d6c5f1.cjs → blocks-31199191.cjs} +1 -1
- package/lib/edge/{blocks-7de3c1bb.js → blocks-a066bb29.js} +2 -2
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-ae68e3ea.js → button-1d265b68.js} +2 -2
- package/lib/edge/{button-b71ce341.cjs → button-45c9b994.cjs} +1 -1
- package/lib/edge/{columns-2eadfbdb.cjs → columns-2282e71d.cjs} +1 -1
- package/lib/edge/{columns-34c30ac0.js → columns-6f323a60.js} +3 -3
- package/lib/edge/{content-variants-0bbaf095.js → content-variants-ddc4462d.js} +12 -12
- package/lib/edge/{content-variants-ed4c0d09.cjs → content-variants-ea56e041.cjs} +1 -1
- package/lib/edge/{custom-code-436cb5b5.cjs → custom-code-046c9e54.cjs} +1 -1
- package/lib/edge/{custom-code-366f612e.js → custom-code-27f3a9d0.js} +1 -1
- package/lib/edge/{embed-c6833cd7.js → embed-962809ed.js} +1 -1
- package/lib/edge/{embed-7c75778e.cjs → embed-a90e1ebf.cjs} +1 -1
- package/lib/edge/{form-268c6d7a.cjs → form-2112cb80.cjs} +1 -1
- package/lib/edge/{form-c946b554.js → form-4fc6f70a.js} +3 -3
- package/lib/edge/{get-class-prop-name-33e113fc.js → get-class-prop-name-03e66a61.js} +1 -1
- package/lib/edge/{get-class-prop-name-ff751f68.cjs → get-class-prop-name-77a0b81b.cjs} +1 -1
- package/lib/edge/{img-468b2c5a.cjs → img-5850d9d8.cjs} +1 -1
- package/lib/edge/{img-fae48c58.js → img-95c678b5.js} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-7ddc0bdd.cjs → input-3937aa23.cjs} +1 -1
- package/lib/edge/{input-7477c1ba.js → input-7d147e6f.js} +1 -1
- package/lib/edge/{personalization-container-5f45f9fa.cjs → personalization-container-aff166ba.cjs} +1 -1
- package/lib/edge/{personalization-container-a316285a.js → personalization-container-d687ea13.js} +4 -4
- package/lib/edge/{select-64516839.cjs → select-5bdfe568.cjs} +1 -1
- package/lib/edge/{select-1cc6458e.js → select-bfca657e.js} +1 -1
- package/lib/edge/{server-entry-b0ba438a.js → server-entry-1d157602.js} +25 -25
- package/lib/edge/server-entry-e8854034.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-61b75e8e.cjs → slot-a4c97369.cjs} +1 -1
- package/lib/edge/{slot-e2c0521b.js → slot-acb2aa8e.js} +3 -3
- package/lib/edge/{symbol-7fdb1286.cjs → symbol-33b65252.cjs} +1 -1
- package/lib/edge/{symbol-ab8b1dc8.js → symbol-cc7e6b66.js} +2 -2
- package/lib/edge/{tabs-65969ff0.cjs → tabs-900d88a9.cjs} +1 -1
- package/lib/edge/{tabs-1faf3b62.js → tabs-9cbb5615.js} +3 -3
- package/lib/node/blocks-exports.cjs +1 -1
- package/lib/node/blocks-exports.mjs +4 -4
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +3 -3
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/node/server-entry-0dcb0303.cjs +2 -0
- package/lib/node/{server-entry-922dcbdc.js → server-entry-ee54171f.js} +25 -25
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-2b3e3bab.js → setIvm-b773f3ba.js} +1 -1
- package/lib/node/{setIvm-7ec43953.cjs → setIvm-d479356f.cjs} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-f382a7f3.cjs → should-force-browser-runtime-in-node-364ee049.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-7796759e.js → should-force-browser-runtime-in-node-bdb5bf58.js} +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/helpers/preview-lru-cache/set.d.ts +3 -4
- package/lib/browser/server-entry-d084d6c0.cjs +0 -2
- package/lib/edge/server-entry-6bf98a1a.cjs +0 -2
- package/lib/node/server-entry-e00081d3.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function c(){return typeof window!="undefined"&&typeof document!="undefined"}const E="[Builder.io]: ",d={log:(...e)=>console.log(E,...e),error:(...e)=>console.error(E,...e),warn:(...e)=>console.warn(E,...e),debug:(...e)=>console.debug(E,...e)},p=e=>e!=null,me=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},I=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},j=async e=>I(e),be=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),ye=[["secure",""],["SameSite","None"]],Se=({name:e,value:t,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?ye:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...o,["path","/"],["domain",me(window.location.hostname)],...s];return be(i)},C=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const s=Se({name:e,value:t,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}},F="builder.userAttributes";function we(){let e=!0;const t=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};C({name:F,value:JSON.stringify(r),canTrack:e}),t.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(I({name:F,canTrack:e})||"{}"):{}},subscribeOnUserAttributesChange(n){return t.add(n),()=>{t.delete(n)}},setCanTrack(n){e=n}}}const P=we(),ve=e=>{P.setUserAttributes(e)},y="react",ke=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},W=e=>e instanceof URLSearchParams?ke(e):e,$=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function Ee(){return c()&&window.self!==window.top}function G(e){return Ee()&&$(e||window.location.search).indexOf("builder.frameEditing=")!==-1}function Ie(e){const t=e||(c()?window.location.search:void 0);return t?$(t).indexOf("builder.preview=")!==-1:!1}const Ae=e=>({type:"builder.registerComponent",data:U(e)}),Oe=e=>{const t=e.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(t);return`return (${!t.startsWith("function")&&!t.startsWith("async")&&!t.startsWith("(")&&!n?"function ":""}${t}).apply(this, arguments)`};function U(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?Oe(n):n))}const V={};function J(e,t){e==="plugin"&&(t=U(t));let n=V[e];if(n||(n=V[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const D={};function Ce(e){if(c()){Object.assign(D,e);const t={type:"builder.settingsChange",data:D};parent.postMessage(t,"*")}}const M="builder.",Pe="options.",T=e=>{if(!e)return{};const t=W(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(M)){const s=r.replace(M,"").replace(Pe,"");n[s]=t[r]}}),n},Ue=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return T(e)},z="4.0.6",X=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z});function Te(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function H(){return Te().replace(/-/g,"")}const Q="builderSessionId",Be=async({canTrack:e})=>{if(!e)return;const t=await j({name:Q,canTrack:e});if(p(t))return t;{const n=xe();return Re({id:n,canTrack:e}),n}},xe=()=>H(),Re=({id:e,canTrack:t})=>C({name:Q,value:e,canTrack:t}),Y=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Le=({key:e,canTrack:t})=>{var n;try{return t?(n=Y())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ne=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=Y())==null||r.setItem(e,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},Z="builderVisitorId",Fe=({canTrack:e})=>{if(!e)return;const t=Le({key:Z,canTrack:e});if(p(t))return t;{const n=Ve();return De({id:n,canTrack:e}),n}},Ve=()=>H(),De=({id:e,canTrack:t})=>Ne({key:Z,value:e,canTrack:t});function q(e){var t;typeof process!="undefined"&&((t=process.env)!=null&&t.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(e)}const Me=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Ke=()=>typeof navigator=="object"&&navigator.userAgent||"",ee=()=>{const e=Ke(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=Me();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Be({canTrack:e}),n=Fe({canTrack:e});return{sessionId:t,visitorId:n}},je=async({type:e,canTrack:t,apiKey:n,metadata:r,...s})=>({type:e,data:{...s,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:ee(),ownerId:n}});async function te({apiHost:e,...t}){if(!t.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||G()||!(c()||y==="reactNative"))return;const r=`${e||"https://cdn.builder.io"}/api/v1/track`;return q(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await je(t)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const We=e=>te({...e,canTrack:!0}),$e=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function ne(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||$e).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const Ge=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let K=!1;const re=e=>{var t,n;K||(K=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:e.modelName,apiKey:e.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var o,i;if(!ne(e.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,w=new Function(u);let l,g=null;try{l=w.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var v;(v=window.parent)==null||v.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(t,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===e&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===e&&n.contentUpdate(u);break}}},Je=({model:e,apiKey:t,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};re({modelName:e,apiKey:t});const s=se({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:e,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},ze="builder.tests",B=e=>`${ze}.${e}`,Xe=({contentId:e})=>j({name:B(e),canTrack:!0}),He=({contentId:e})=>I({name:B(e),canTrack:!0}),Qe=({contentId:e,value:t})=>C({name:B(e),value:t,canTrack:!0}),oe=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,Ye=({id:e,variations:t})=>{var s;let n=0;const r=Math.random();for(const o in t){const i=(s=t[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return e},ie=e=>{const t=Ye(e);return Qe({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},ae=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Ze=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!oe(e))return e;const n=He({contentId:e.id})||ie({variations:e.variations,id:e.id}),r=ae({item:e,testGroupId:n});return{...e,...r}},qe=async({item:e,canTrack:t})=>{if(!t||!oe(e))return e;const r=await Xe({contentId:e.id})||ie({variations:e.variations,id:e.id}),s=ae({item:e,testGroupId:r});return{...e,...s}},ce=e=>{const t=p(e)?e:!0;return P.setCanTrack(t),t};function et(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function tt(){const e=et().fetch;if(typeof e=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return e}const nt=tt();function O(e,t=null,n="."){return Object.keys(e).reduce((r,s)=>{const o=e[s],i=[t,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...O(o,i,n)}:{...r,[i]:o}},{})}function ue(e,t,n={}){for(const r in e){const s=e[r],o=t?t+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ue(s,o,n):n[o]=s}return n}function rt(e){const t={};for(const n in e){const r=n.split(".");let s=t;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=e[n]:(s[i]=s[i]||{},s=s[i])}}return t}const st="v3",_=e=>typeof e=="number"&&!isNaN(e)&&e>=0,x=e=>{const{limit:t=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=st,fields:m,omit:w,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:v,includeUnpublished:R,apiHost:ge}=e;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const he=t!==1,pe=ge||"https://cdn.builder.io",a=new URL(`${pe}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(he)),a.searchParams.set("includeRefs",String(!0));const A=u||(n==null?void 0:n.locale);let b=n||{};if(A&&(a.searchParams.set("locale",A),b={locale:A,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",w!=null?w:"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),v){const f=O({sort:v});for(const k in f)a.searchParams.set(k,JSON.stringify(f[k]))}const L={...Ue(),...W(e.options||{})};b={...b,...it(L)};const N=O(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ue({query:r});for(const k in f)a.searchParams.set(k,JSON.stringify(f[k]))}return a},ot=e=>{const t={};for(const n in e)n.startsWith("userAttributes.")&&(t[n]=e[n],delete e[n]);return t},it=e=>{if(c()&&e.preview==="BUILDER_STUDIO"){e["userAttributes.urlPath"]=window.location.pathname,e["userAttributes.host"]=window.location.host;const t=ot(e),{userAttributes:n}=rt(t);return n}return{}},at=e=>"results"in e;async function le(e){const t=await fe({...e,limit:1});return t&&t[0]||null}const ct=async e=>{var i,u;const t=x(e),n=(i=e.fetch)!=null?i:nt,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...X()}};return await(await n(t.href,r)).json()},de=async(e,t,n=x(e))=>{const r=ce(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const s=[];for(const o of t.results)s.push(await qe({item:o,canTrack:r}));t.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return t.results};async function fe(e){const t=x(e),n=await ct(e);if(!at(n))throw d.error("Error fetching data. ",{url:t,content:n,options:e}),n;return de(e,n)}const ut=async e=>{var r,s,o;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((s=e.userAttributes)==null?void 0:s.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:T(e.searchParams||((o=e.url)==null?void 0:o.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await le(n)}};exports.TARGET=y;exports._processContentResult=de;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=Ae;exports.fetchBuilderProps=ut;exports.fetchEntries=fe;exports.fetchOneEntry=le;exports.getBuilderSearchParams=T;exports.getCookieSync=I;exports.getDefaultCanTrack=ce;exports.getUserAttributes=ee;exports.handleABTestingSync=Ze;exports.isBrowser=c;exports.isEditing=G;exports.isPreviewing=Ie;exports.logFetch=q;exports.logger=d;exports.register=J;exports.registerInsertMenu=Ge;exports.serializeIncludingFunctions=U;exports.setClientUserAttributes=ve;exports.setEditorSettings=Ce;exports.setupBrowserForEditing=re;exports.subscribeToEditor=Je;exports.track=We;exports.userAttributesService=P;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-e8854034.cjs");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-1d157602.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
s as createRegisterComponentMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("./blocks-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("./blocks-31199191.cjs");require("react");require("./blocks-exports.cjs");require("./server-entry-e8854034.cjs");require("./get-class-prop-name-77a0b81b.cjs");require("./dynamic-renderer-b29b45ca.cjs");function u(e){var t,n,r;return o.jsx("div",{style:{pointerEvents:"auto"},...!((t=e.builderContext.context)!=null&&t.symbolId)&&{"builder-slot":e.name},children:o.jsx(i.Blocks,{parent:(n=e.builderContext.context)==null?void 0:n.symbolId,path:`symbol.data.${e.name}`,context:e.builderContext,registeredComponents:e.builderComponents,blocks:(r=e.builderContext.rootState)==null?void 0:r[e.name]})})}exports.default=u;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { Blocks as m } from "./blocks-
|
|
2
|
+
import { Blocks as m } from "./blocks-a066bb29.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "./blocks-exports.mjs";
|
|
5
|
-
import "./server-entry-
|
|
6
|
-
import "./get-class-prop-name-
|
|
5
|
+
import "./server-entry-1d157602.js";
|
|
6
|
+
import "./get-class-prop-name-03e66a61.js";
|
|
7
7
|
import "./dynamic-renderer-8b343325.js";
|
|
8
8
|
function c(t) {
|
|
9
9
|
var e, o, n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),o=require("react"),v=require("./blocks-exports.cjs"),k=require("./get-class-prop-name-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),o=require("react"),v=require("./blocks-exports.cjs"),k=require("./get-class-prop-name-77a0b81b.cjs"),b=require("./server-entry-e8854034.cjs"),x=async({builderContextValue:e,symbol:t})=>{if(t!=null&&t.model&&(e!=null&&e.apiKey))return b.fetchOneEntry({model:t.model,apiKey:e.apiKey,apiVersion:e.apiVersion,...(t==null?void 0:t.entry)&&{query:{id:t.entry}}}).catch(r=>{b.logger.error("Could not fetch symbol content: ",r)})};function g(e){var c,a,d,u,l;function t(){return"div"}function r(){return"div"}function y(){var n,s;return[e.attributes[k.getClassPropName()],"builder-symbol",(n=e.symbol)!=null&&n.inline?"builder-inline-symbol":void 0,(s=e.symbol)!=null&&s.dynamic||e.dynamic?"builder-dynamic-symbol":void 0].filter(Boolean).join(" ")}const[i,f]=o.useState(()=>{var n;return(n=e.symbol)==null?void 0:n.content});function C(){i||x({symbol:e.symbol,builderContextValue:e.builderContext}).then(n=>{n&&f(n)})}return o.useEffect(()=>{},[]),o.useEffect(()=>{C()},[e.symbol]),m.jsx("div",{...e.attributes,className:y(),children:m.jsx(v.Content,{nonce:e.builderContext.nonce,isNestedRender:!0,apiVersion:e.builderContext.apiVersion,apiKey:e.builderContext.apiKey,context:{...e.builderContext.context,symbolId:(c=e.builderBlock)==null?void 0:c.id},customComponents:Object.values(e.builderComponents),data:{...(a=e.symbol)==null?void 0:a.data,...e.builderContext.localState,...(d=i==null?void 0:i.data)==null?void 0:d.state},canTrack:e.builderContext.canTrack,model:(l=(u=e.symbol)==null?void 0:u.model)!=null?l:"",content:i,linkComponent:e.builderLinkComponent,blocksWrapper:t(),contentWrapper:r()})})}exports.default=g;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as u } from "react/jsx-runtime";
|
|
2
2
|
import { useState as C, useEffect as f } from "react";
|
|
3
3
|
import { Content as v } from "./blocks-exports.mjs";
|
|
4
|
-
import { getClassPropName as k } from "./get-class-prop-name-
|
|
5
|
-
import { fetchOneEntry as h, logger as x } from "./server-entry-
|
|
4
|
+
import { getClassPropName as k } from "./get-class-prop-name-03e66a61.js";
|
|
5
|
+
import { fetchOneEntry as h, logger as x } from "./server-entry-1d157602.js";
|
|
6
6
|
const K = async ({
|
|
7
7
|
builderContextValue: e,
|
|
8
8
|
symbol: t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),u=require("react"),b=require("./blocks-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),u=require("react"),b=require("./blocks-31199191.cjs");require("./blocks-exports.cjs");require("./server-entry-e8854034.cjs");require("./get-class-prop-name-77a0b81b.cjs");require("./dynamic-renderer-b29b45ca.cjs");function s(e){var o;const[t,a]=u.useState(()=>e.defaultActiveTab?e.defaultActiveTab-1:0);function c(n){return e.tabs&&e.tabs[n].content}function r(n){n===t&&e.collapsible?a(-1):a(n)}return l.jsxs("div",{children:[l.jsx("div",{className:"builder-tabs-wrap",style:{display:"flex",flexDirection:"row",justifyContent:e.tabHeaderLayout||"flex-start",overflow:"auto"},children:(o=e.tabs)==null?void 0:o.map((n,i)=>l.jsx("span",{className:`builder-tab-wrap ${t===i?"builder-tab-active":""}`,style:{...t===i?e.activeTabStyle:{}},onClick:d=>r(i),children:l.jsx(b.Blocks,{parent:e.builderBlock.id,path:`tabs.${i}.label`,blocks:n.label,context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})},i))}),c(t)?l.jsx("div",{children:l.jsx(b.Blocks,{parent:e.builderBlock.id,path:`tabs.${t}.content`,blocks:c(t),context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})}):null]})}exports.default=s;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as u, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { useState as d } from "react";
|
|
3
|
-
import { Blocks as c } from "./blocks-
|
|
3
|
+
import { Blocks as c } from "./blocks-a066bb29.js";
|
|
4
4
|
import "./blocks-exports.mjs";
|
|
5
|
-
import "./server-entry-
|
|
6
|
-
import "./get-class-prop-name-
|
|
5
|
+
import "./server-entry-1d157602.js";
|
|
6
|
+
import "./get-class-prop-name-03e66a61.js";
|
|
7
7
|
import "./dynamic-renderer-8b343325.js";
|
|
8
8
|
function y(t) {
|
|
9
9
|
var b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./server-entry-
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./server-entry-0dcb0303.cjs"),r=require("react/jsx-runtime"),f=require("react"),N=require("./setIvm-d479356f.cjs"),Oe=require("./should-force-browser-runtime-in-node-364ee049.cjs");function Le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ue=Le(f),_e=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),qe=e=>typeof e=="string"&&_e.has(e.toLowerCase());function ne(e){return r.jsx(r.Fragment,{children:qe(e.TagName)?r.jsx(r.Fragment,{children:r.jsx(e.TagName,{...e.attributes,...e.actionAttributes})}):r.jsx(r.Fragment,{children:typeof e.TagName=="string"?r.jsx(e.TagName,{...e.attributes,...e.actionAttributes,children:e.children}):r.jsx(e.TagName,{...e.attributes,...e.actionAttributes,children:e.children})})})}const O=()=>{switch(p.TARGET){case"react":case"reactNative":case"rsc":return"className";case"svelte":case"vue":case"solid":case"qwik":case"angular":return"class"}};function he(e){function t(){return{...e.attributes,[O()]:`${e.link?"":"builder-button"} ${e.attributes[O()]||""}`,...e.link?{href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"link"}:{role:"button"}}}return r.jsx(ne,{attributes:t(),TagName:e.link?e.builderLinkComponent||"a":"button",actionAttributes:{},children:e.text})}const H=f.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{},BlocksWrapper:"div",BlocksWrapperProps:{},nonce:"",model:""}),be=f.createContext({registeredComponents:{}}),pe=(e,t,n)=>{const i=String.prototype.split.call(t,/[,[\].]+?/).filter(Boolean).reduce((a,s)=>a!=null?a[s]:a,e);return i===void 0||i===e?n:i},Me=({code:e,builder:t,context:n,event:i,localState:a,rootSetState:s,rootState:o})=>{const l=N.getFunctionArguments({builder:t,context:n,event:i,state:N.flattenState({rootState:o,localState:a,rootSetState:s})});return new Function(...l.map(([d])=>d),e)(...l.map(([,d])=>d))},He=e=>p.isBrowser()||Oe.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0})?Me(e):N.runInNode(e),ze=/^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/,Ke=/(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/,Ge=e=>{var t,n,i,a,s,o;return((i=(n=(t=ze.exec(e.trim()))==null?void 0:t.groups)==null?void 0:n.getPath)==null?void 0:i.slice(1))||((o=(s=(a=Ke.exec(e.trim()))==null?void 0:a.groups)==null?void 0:s.getPath)==null?void 0:o.slice(1))};function W({code:e,context:t,localState:n,rootState:i,rootSetState:a,event:s,isExpression:o=!0}){if(e.trim()==="")return;const l=Ge(e.trim());if(l)return pe({...i,...n},l);const d={code:N.parseCode(e,{isExpression:o}),builder:N.getBuilderGlobals(),context:t,event:s,rootSetState:a,rootState:i,localState:n};try{return He(d)}catch(u){p.logger.error("Failed code evaluation: "+u.message,{code:e});return}}function Je(e,t){var n;return{...(n=e.component)==null?void 0:n.options,...e.options,...Qe(e,t)}}const Qe=(e,t)=>{var n,i;if(((n=e.component)==null?void 0:n.name)==="Text"&&((i=e.component.options)!=null&&i.text)&&typeof e.component.options.text=="string")return{...e.component.options,text:e.component.options.text.replace(/{{([^}]+)}}/g,(a,s)=>W({code:s,context:t,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState}))}};function Ye(e,...t){const n=Object.assign({},e);for(const i of t)delete n[i];return n}function q(e,t,n=null,i=null,a=new WeakSet){if(e==null||typeof e!="object"){t(e,s=>{n!==null&&i!==null&&(n[i]=s)});return}a.has(e)||(a.add(e),Array.isArray(e)?e.forEach((s,o)=>{t(s,d=>{e[o]=d}),q(s,t,e,o,a)}):Object.entries(e).forEach(([s,o])=>{t(o,d=>{e[s]=d}),q(o,t,e,s,a)}))}function ye(e){return e&&typeof e=="object"&&e["@type"]==="@builder.io/core:LocalizedValue"}function Xe(e){if(!e||!Object.getOwnPropertyNames(e).length)return!1;let t=!1;return q(e,n=>{if(ye(n)){t=!0;return}}),t}function Ze(e,t){return!e||!Object.getOwnPropertyNames(e).length?{}:(q(e,(n,i)=>{var a;ye(n)&&i((a=n[t])!=null?a:void 0)}),e)}function et(e,t){var n,i;return(n=e.component)!=null&&n.options&&Xe((i=e.component)==null?void 0:i.options)&&(t||console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization"),e.component.options=Ze(e.component.options,t!=null?t:"Default")),e}function te(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>te(n));if(e["@type"]==="@builder.io/sdk:Element")return e;const t={};for(const n in e)n!=="meta"&&Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=te(e[n]));return t}const tt=["svelte","vue","angular","qwik","solid"].includes(p.TARGET),nt=e=>{if(tt){const t=N.fastClone(e);return{...t,properties:{...t.properties},actions:{...t.actions}}}else{const t=te(Ye(e,"children","meta"));return{...t,properties:{...t.properties},actions:{...t.actions},children:e.children,meta:e.meta}}},it=({block:e,context:t,localState:n,rootState:i,rootSetState:a})=>{if(!e.bindings)return e;const s=nt(e);for(const o in e.bindings){const l=e.bindings[o],d=W({code:l,localState:n,rootState:i,rootSetState:a,context:t});N.set(s,o,d)}return s};function at({block:e,context:t,localState:n,rootState:i,rootSetState:a}){let s=et(e,i.locale);return s=s,it({block:s,localState:n,rootState:i,rootSetState:a,context:t})}const z=e=>e?e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase():"";function ot(e,t,n={}){let i,a,s,o=null,l=0;const d=function(){l=n.leading===!1?0:Date.now(),o=null,s=e.apply(i,a),o||(i=a=null)};return function(){const u=Date.now();!l&&n.leading===!1&&(l=u);const h=t-(u-l);return i=this,a=arguments,h<=0||h>t?(o&&(clearTimeout(o),o=null),l=u,s=e.apply(i,a),o||(i=a=null)):!o&&n.trailing!==!1&&(o=setTimeout(d,h)),s}}function $(e,...t){const n=Object(e);for(let i=1;i<arguments.length;i++){const a=arguments[i];if(a!=null)for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&(n[s]=a[s])}return n}function rt(e){for(const t of e)switch(t.trigger){case"pageLoad":Se(t);break;case"scrollInView":lt(t);break}}function xe(e){console.warn(`Cannot animate element: element with ID ${e} not found!`)}function ve(e,t){const n=st(e),i=getComputedStyle(t),a=e.steps[0].styles,s=e.steps[e.steps.length-1].styles,o=[a,s];for(const l of o)for(const d of n)d in l||(l[d]=i[d])}function st(e){const t=[];for(const n of e.steps)for(const i in n.styles)t.indexOf(i)===-1&&t.push(i);return t}function Se(e){const t=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));if(!t.length){xe(e.elementId||e.id||"");return}Array.from(t).forEach(n=>{ve(e,n),n.style.transition="none",n.style.transitionDelay="0",$(n.style,e.steps[0].styles),setTimeout(()=>{n.style.transition=`all ${e.duration}s ${z(e.easing)}`,e.delay&&(n.style.transitionDelay=e.delay+"s"),$(n.style,e.steps[1].styles),setTimeout(()=>{n.style.transition="",n.style.transitionDelay=""},(e.delay||0)*1e3+e.duration*1e3+100)})})}function lt(e){const t=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));if(!t.length){xe(e.elementId||e.id||"");return}Array.from(t).forEach(n=>{ve(e,n);let i=!1,a=!1;function s(){!i&&l(n)?(i=!0,a=!0,setTimeout(()=>{$(n.style,e.steps[1].styles),e.repeat||document.removeEventListener("scroll",o),setTimeout(()=>{a=!1,e.repeat||(n.style.transition="",n.style.transitionDelay="")},(e.duration+(e.delay||0))*1e3+100)})):e.repeat&&i&&!a&&!l(n)&&(i=!1,$(n.style,e.steps[0].styles))}const o=ot(s,200,{leading:!1});function l(h){const b=h.getBoundingClientRect(),c=window.innerHeight,g=(e.thresholdPercent||0)/100*c;return b.bottom>g&&b.top<c-g}const d=e.steps[0].styles;function u(){$(n.style,d)}u(),setTimeout(()=>{n.style.transition=`all ${e.duration}s ${z(e.easing)}`,e.delay&&(n.style.transitionDelay=e.delay+"s")}),document.addEventListener("scroll",o,{capture:!0,passive:!0}),s()})}const ke=e=>Object.entries(e).map(([n,i])=>{if(typeof i=="string")return`${z(n)}: ${i};`}).filter(p.checkIsDefined),ct=e=>ke(e).join(`
|
|
2
2
|
`),D=({mediaQuery:e,className:t,styles:n})=>{const i=`.${t} {
|
|
3
3
|
${ct(n)}
|
|
4
4
|
}`;return e?`${e} {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { TARGET as O, isBrowser as U, logger as z, checkIsDefined as se, isPreviewing as X, isEditing as N, userAttributesService as be, getDefaultCanTrack as M, logFetch as Ve, registerInsertMenu as Ge, setupBrowserForEditing as Qe, createRegisterComponentMessage as Ye, getCookieSync as Xe, _track as pe, fetchOneEntry as Pe, createEditorListener as Ze, serializeIncludingFunctions as ye, handleABTestingSync as et } from "./server-entry-
|
|
3
|
-
import { setClientUserAttributes as Ri } from "./server-entry-
|
|
2
|
+
import { TARGET as O, isBrowser as U, logger as z, checkIsDefined as se, isPreviewing as X, isEditing as N, userAttributesService as be, getDefaultCanTrack as M, logFetch as Ve, registerInsertMenu as Ge, setupBrowserForEditing as Qe, createRegisterComponentMessage as Ye, getCookieSync as Xe, _track as pe, fetchOneEntry as Pe, createEditorListener as Ze, serializeIncludingFunctions as ye, handleABTestingSync as et } from "./server-entry-ee54171f.js";
|
|
3
|
+
import { setClientUserAttributes as Ri } from "./server-entry-ee54171f.js";
|
|
4
4
|
import { jsx as s, Fragment as R, jsxs as B } from "react/jsx-runtime";
|
|
5
5
|
import * as tt from "react";
|
|
6
6
|
import { createContext as Be, useEffect as P, useState as I, useRef as L, useContext as ve, createElement as Ae } from "react";
|
|
7
|
-
import { getFunctionArguments as nt, flattenState as it, runInNode as at, parseCode as ot, getBuilderGlobals as rt, set as Ne, fastClone as ue } from "./setIvm-
|
|
8
|
-
import { shouldForceBrowserRuntimeInNode as lt } from "./should-force-browser-runtime-in-node-
|
|
7
|
+
import { getFunctionArguments as nt, flattenState as it, runInNode as at, parseCode as ot, getBuilderGlobals as rt, set as Ne, fastClone as ue } from "./setIvm-b773f3ba.js";
|
|
8
|
+
import { shouldForceBrowserRuntimeInNode as lt } from "./should-force-browser-runtime-in-node-bdb5bf58.js";
|
|
9
9
|
const st = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), ct = (e) => typeof e == "string" && st.has(e.toLowerCase());
|
|
10
10
|
function de(e) {
|
|
11
11
|
return /* @__PURE__ */ s(R, { children: ct(e.TagName) ? /* @__PURE__ */ s(R, { children: /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes }) }) : /* @__PURE__ */ s(R, { children: typeof e.TagName == "string" ? /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) : /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) }) });
|
package/lib/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-0dcb0303.cjs");require("react/jsx-runtime");require("react");require("./setIvm-d479356f.cjs");require("./should-force-browser-runtime-in-node-364ee049.cjs");exports.Blocks=t.Blocks;exports.BuilderContext=t.BuilderContext;exports.Button=t.Button;exports.Columns=t.Columns;exports.Content=t.Content;exports.Fragment=t.Fragment;exports.Image=t.Image;exports.Section=t.Section;exports.Symbol=t.Symbol;exports.Text=t.Text;exports.Video=t.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setClientUserAttributes=e.setClientUserAttributes;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Blocks as n, BuilderContext as m, Button as c, Columns as g, Content as p, Fragment as a, Image as l, Section as u, Symbol as d, Text as C, Video as f } from "./blocks-exports.mjs";
|
|
2
|
-
import { _processContentResult as E, createRegisterComponentMessage as b, fetchBuilderProps as h, fetchEntries as x, fetchOneEntry as S, getBuilderSearchParams as P, isEditing as k, isPreviewing as y, register as R, setClientUserAttributes as T, setEditorSettings as v, subscribeToEditor as w, track as A } from "./server-entry-
|
|
2
|
+
import { _processContentResult as E, createRegisterComponentMessage as b, fetchBuilderProps as h, fetchEntries as x, fetchOneEntry as S, getBuilderSearchParams as P, isEditing as k, isPreviewing as y, register as R, setClientUserAttributes as T, setEditorSettings as v, subscribeToEditor as w, track as A } from "./server-entry-ee54171f.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
|
-
import "./setIvm-
|
|
6
|
-
import "./should-force-browser-runtime-in-node-
|
|
5
|
+
import "./setIvm-b773f3ba.js";
|
|
6
|
+
import "./should-force-browser-runtime-in-node-bdb5bf58.js";
|
|
7
7
|
export {
|
|
8
8
|
n as Blocks,
|
|
9
9
|
m as BuilderContext,
|
package/lib/node/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./should-force-browser-runtime-in-node-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./should-force-browser-runtime-in-node-364ee049.cjs"),t=require("isolated-vm"),r=require("./setIvm-d479356f.cjs");require("./server-entry-0dcb0303.cjs");const n=e=>{if(o.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0}))return;const{ivmIsolateOptions:i}=e||{};r.setIvm(t,i)};exports.initializeNodeRuntime=n;
|
package/lib/node/init.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { shouldForceBrowserRuntimeInNode as r } from "./should-force-browser-runtime-in-node-
|
|
1
|
+
import { shouldForceBrowserRuntimeInNode as r } from "./should-force-browser-runtime-in-node-bdb5bf58.js";
|
|
2
2
|
import t from "isolated-vm";
|
|
3
|
-
import { setIvm as e } from "./setIvm-
|
|
4
|
-
import "./server-entry-
|
|
3
|
+
import { setIvm as e } from "./setIvm-b773f3ba.js";
|
|
4
|
+
import "./server-entry-ee54171f.js";
|
|
5
5
|
const u = (o) => {
|
|
6
6
|
if (r({
|
|
7
7
|
shouldLogWarning: !0
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const y="react",I="[Builder.io]: ",d={log:(...e)=>console.log(I,...e),error:(...e)=>console.error(I,...e),warn:(...e)=>console.warn(I,...e),debug:(...e)=>console.debug(I,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const me=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},j=e=>e instanceof URLSearchParams?me(e):e,W=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function be(){return c()&&window.self!==window.top}function G(e){return be()&&W(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const ye=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Se=()=>typeof navigator=="object"&&navigator.userAgent||"",$=()=>{const e=Se(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=ye();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function we(e){const t=e||(c()?window.location.search:void 0);return t?W(t).indexOf("builder.preview=")!==-1:!1}const ve=e=>({type:"builder.registerComponent",data:P(e)}),Ee=e=>{const t=e.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(t);return`return (${!t.startsWith("function")&&!t.startsWith("async")&&!t.startsWith("(")&&!n?"function ":""}${t}).apply(this, arguments)`};function P(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?Ee(n):n))}const F={};function J(e,t){e==="plugin"&&(t=P(t));let n=F[e];if(n||(n=F[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const V={};function Ie(e){if(c()){Object.assign(V,e);const t={type:"builder.settingsChange",data:V};parent.postMessage(t,"*")}}const M="builder.",ke="options.",C=e=>{if(!e)return{};const t=j(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(M)){const s=r.replace(M,"").replace(ke,"");n[s]=t[r]}}),n},Ae=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return C(e)},X="4.0.6",z=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":X}),Oe=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},k=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},H=async e=>k(e),Pe=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ce=[["secure",""],["SameSite","None"]],Ue=({name:e,value:t,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Ce:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...o,["path","/"],["domain",Oe(window.location.hostname)],...s];return Pe(i)},U=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const s=Ue({name:e,value:t,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Te(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function Q(){return Te().replace(/-/g,"")}const Y="builderSessionId",Be=async({canTrack:e})=>{if(!e)return;const t=await H({name:Y,canTrack:e});if(p(t))return t;{const n=Re();return xe({id:n,canTrack:e}),n}},Re=()=>Q(),xe=({id:e,canTrack:t})=>U({name:Y,value:e,canTrack:t}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Le=({key:e,canTrack:t})=>{var n;try{return t?(n=Z())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ne=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=Z())==null||r.setItem(e,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Fe=({canTrack:e})=>{if(!e)return;const t=Le({key:q,canTrack:e});if(p(t))return t;{const n=Ve();return Me({id:n,canTrack:e}),n}},Ve=()=>Q(),Me=({id:e,canTrack:t})=>Ne({key:q,value:e,canTrack:t});function ee(e){var t;typeof process!="undefined"&&((t=process.env)!=null&&t.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(e)}const De=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Be({canTrack:e}),n=Fe({canTrack:e});return{sessionId:t,visitorId:n}},Ke=async({type:e,canTrack:t,apiKey:n,metadata:r,...s})=>({type:e,data:{...s,metadata:{url:location.href,...r},...await De({canTrack:t}),userAttributes:$(),ownerId:n}});async function te({apiHost:e,...t}){if(!t.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||G()||!(c()||y==="reactNative"))return;const r=`${e||"https://cdn.builder.io"}/api/v1/track`;return ee(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await Ke(t)]}),headers:{"content-type":"application/json",...z()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const _e=e=>te({...e,canTrack:!0}),je=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function ne(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||je).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const We=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let D=!1;const re=e=>{var t,n;D||(D=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:X,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:e.modelName,apiKey:e.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var o,i;if(!ne(e.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,w=new Function(u);let l,g=null;try{l=w.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var v;(v=window.parent)==null||v.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(t,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===e&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===e&&n.contentUpdate(u);break}}},Ge=({model:e,apiKey:t,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};re({modelName:e,apiKey:t});const s=se({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:e,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},$e="builder.tests",T=e=>`${$e}.${e}`,Je=({contentId:e})=>H({name:T(e),canTrack:!0}),Xe=({contentId:e})=>k({name:T(e),canTrack:!0}),ze=({contentId:e,value:t})=>U({name:T(e),value:t,canTrack:!0}),oe=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,He=({id:e,variations:t})=>{var s;let n=0;const r=Math.random();for(const o in t){const i=(s=t[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return e},ie=e=>{const t=He(e);return ze({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},ae=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Qe=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!oe(e))return e;const n=Xe({contentId:e.id})||ie({variations:e.variations,id:e.id}),r=ae({item:e,testGroupId:n});return{...e,...r}},Ye=async({item:e,canTrack:t})=>{if(!t||!oe(e))return e;const r=await Je({contentId:e.id})||ie({variations:e.variations,id:e.id}),s=ae({item:e,testGroupId:r});return{...e,...s}},K="builder.userAttributes";function Ze(){let e=!0;const t=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};U({name:K,value:JSON.stringify(r),canTrack:e}),t.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(k({name:K,canTrack:e})||"{}"):{}},subscribeOnUserAttributesChange(n){return t.add(n),()=>{t.delete(n)}},setCanTrack(n){e=n}}}const B=Ze(),qe=e=>{B.setUserAttributes(e)},ce=e=>{const t=p(e)?e:!0;return B.setCanTrack(t),t};function et(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function tt(){const e=et().fetch;if(typeof e=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return e}const nt=tt();function O(e,t=null,n="."){return Object.keys(e).reduce((r,s)=>{const o=e[s],i=[t,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...O(o,i,n)}:{...r,[i]:o}},{})}function ue(e,t,n={}){for(const r in e){const s=e[r],o=t?t+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ue(s,o,n):n[o]=s}return n}function rt(e){const t={};for(const n in e){const r=n.split(".");let s=t;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=e[n]:(s[i]=s[i]||{},s=s[i])}}return t}const st="v3",_=e=>typeof e=="number"&&!isNaN(e)&&e>=0,R=e=>{const{limit:t=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=st,fields:m,omit:w,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:v,includeUnpublished:x,apiHost:ge}=e;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const he=t!==1,pe=ge||"https://cdn.builder.io",a=new URL(`${pe}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(he)),a.searchParams.set("includeRefs",String(!0));const A=u||(n==null?void 0:n.locale);let b=n||{};if(A&&(a.searchParams.set("locale",A),b={locale:A,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",w!=null?w:"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof x=="boolean"&&a.searchParams.set("includeUnpublished",String(x)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),v){const f=O({sort:v});for(const E in f)a.searchParams.set(E,JSON.stringify(f[E]))}const L={...Ae(),...j(e.options||{})};b={...b,...it(L)};const N=O(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ue({query:r});for(const E in f)a.searchParams.set(E,JSON.stringify(f[E]))}return a},ot=e=>{const t={};for(const n in e)n.startsWith("userAttributes.")&&(t[n]=e[n],delete e[n]);return t},it=e=>{if(c()&&e.preview==="BUILDER_STUDIO"){e["userAttributes.urlPath"]=window.location.pathname,e["userAttributes.host"]=window.location.host;const t=ot(e),{userAttributes:n}=rt(t);return n}return{}},at=e=>"results"in e;async function le(e){const t=await fe({...e,limit:1});return t&&t[0]||null}const ct=async e=>{var i,u;const t=R(e),n=(i=e.fetch)!=null?i:nt,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...z()}};return await(await n(t.href,r)).json()},de=async(e,t,n=R(e))=>{const r=ce(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const s=[];for(const o of t.results)s.push(await Ye({item:o,canTrack:r}));t.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return t.results};async function fe(e){const t=R(e),n=await ct(e);if(!at(n))throw d.error("Error fetching data. ",{url:t,content:n,options:e}),n;return de(e,n)}const ut=async e=>{var r,s,o;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((s=e.userAttributes)==null?void 0:s.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:C(e.searchParams||((o=e.url)==null?void 0:o.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await le(n)}};exports.MSG_PREFIX=I;exports.TARGET=y;exports._processContentResult=de;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=ve;exports.fetchBuilderProps=ut;exports.fetchEntries=fe;exports.fetchOneEntry=le;exports.getBuilderSearchParams=C;exports.getCookieSync=k;exports.getDefaultCanTrack=ce;exports.getUserAttributes=$;exports.handleABTestingSync=Qe;exports.isBrowser=c;exports.isEditing=G;exports.isPreviewing=we;exports.logFetch=ee;exports.logger=d;exports.register=J;exports.registerInsertMenu=We;exports.serializeIncludingFunctions=P;exports.setClientUserAttributes=qe;exports.setEditorSettings=Ie;exports.setupBrowserForEditing=re;exports.subscribeToEditor=Ge;exports.track=_e;exports.userAttributesService=B;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
log: (...t) => console.log(
|
|
3
|
-
error: (...t) => console.error(
|
|
4
|
-
warn: (...t) => console.warn(
|
|
5
|
-
debug: (...t) => console.debug(
|
|
1
|
+
const I = "react", k = "[Builder.io]: ", f = {
|
|
2
|
+
log: (...t) => console.log(k, ...t),
|
|
3
|
+
error: (...t) => console.error(k, ...t),
|
|
4
|
+
warn: (...t) => console.warn(k, ...t),
|
|
5
|
+
debug: (...t) => console.debug(k, ...t)
|
|
6
6
|
};
|
|
7
7
|
function c() {
|
|
8
8
|
return typeof window != "undefined" && typeof document != "undefined";
|
|
@@ -44,7 +44,7 @@ const ct = () => {
|
|
|
44
44
|
return t.match(/IEMobile/i) || t.match(/WPDesktop/i);
|
|
45
45
|
},
|
|
46
46
|
any() {
|
|
47
|
-
return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() ||
|
|
47
|
+
return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || I === "reactNative";
|
|
48
48
|
}
|
|
49
49
|
}, n = t.match(/Tablet|iPad/i), r = ct();
|
|
50
50
|
return {
|
|
@@ -112,8 +112,8 @@ const N = "builder.", ht = "options.", W = (t) => {
|
|
|
112
112
|
return {};
|
|
113
113
|
const t = new URLSearchParams(window.location.search);
|
|
114
114
|
return W(t);
|
|
115
|
-
}, _ = "4.0.
|
|
116
|
-
"X-Builder-SDK":
|
|
115
|
+
}, _ = "4.0.6", $ = () => ({
|
|
116
|
+
"X-Builder-SDK": I,
|
|
117
117
|
"X-Builder-SDK-GEN": "2",
|
|
118
118
|
"X-Builder-SDK-Version": _
|
|
119
119
|
}), pt = (t) => {
|
|
@@ -290,7 +290,7 @@ async function xt({
|
|
|
290
290
|
f.error("Missing API key for track call. Please provide your API key.");
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
|
-
if (!e.canTrack || at() || !(c() ||
|
|
293
|
+
if (!e.canTrack || at() || !(c() || I === "reactNative"))
|
|
294
294
|
return;
|
|
295
295
|
const r = `${t || "https://cdn.builder.io"}/api/v1/track`;
|
|
296
296
|
return Ct(r), fetch(r, {
|
|
@@ -346,7 +346,7 @@ const Rt = (t) => {
|
|
|
346
346
|
V || (V = !0, c() && ((e = window.parent) == null || e.postMessage({
|
|
347
347
|
type: "builder.sdkInfo",
|
|
348
348
|
data: {
|
|
349
|
-
target:
|
|
349
|
+
target: I,
|
|
350
350
|
version: _,
|
|
351
351
|
supportsPatchUpdates: !1,
|
|
352
352
|
// Supports builder-model="..." attribute which is needed to
|
|
@@ -373,10 +373,10 @@ const Rt = (t) => {
|
|
|
373
373
|
if (s != null && s.type)
|
|
374
374
|
switch (s.type) {
|
|
375
375
|
case "builder.evaluate": {
|
|
376
|
-
const u = s.data.text, b = s.data.arguments || [], p = s.data.id,
|
|
376
|
+
const u = s.data.text, b = s.data.arguments || [], p = s.data.id, S = new Function(u);
|
|
377
377
|
let l, h = null;
|
|
378
378
|
try {
|
|
379
|
-
l =
|
|
379
|
+
l = S.apply(null, b);
|
|
380
380
|
} catch (g) {
|
|
381
381
|
h = g;
|
|
382
382
|
}
|
|
@@ -387,8 +387,8 @@ const Rt = (t) => {
|
|
|
387
387
|
error: h.message
|
|
388
388
|
}
|
|
389
389
|
}, "*") : l && typeof l.then == "function" ? l.then((g) => {
|
|
390
|
-
var
|
|
391
|
-
(
|
|
390
|
+
var w;
|
|
391
|
+
(w = window.parent) == null || w.postMessage({
|
|
392
392
|
type: "builder.evaluateResult",
|
|
393
393
|
data: {
|
|
394
394
|
id: p,
|
|
@@ -653,11 +653,11 @@ const Xt = "v3", D = (t) => typeof t == "number" && !isNaN(t) && t >= 0, U = (t)
|
|
|
653
653
|
locale: u,
|
|
654
654
|
apiVersion: b = Xt,
|
|
655
655
|
fields: p,
|
|
656
|
-
omit:
|
|
656
|
+
omit: S,
|
|
657
657
|
offset: l,
|
|
658
658
|
cacheSeconds: h,
|
|
659
659
|
staleCacheSeconds: g,
|
|
660
|
-
sort:
|
|
660
|
+
sort: w,
|
|
661
661
|
includeUnpublished: T,
|
|
662
662
|
apiHost: nt
|
|
663
663
|
} = t;
|
|
@@ -672,12 +672,12 @@ const Xt = "v3", D = (t) => typeof t == "number" && !isNaN(t) && t >= 0, U = (t)
|
|
|
672
672
|
if (A && (a.searchParams.set("locale", A), m = {
|
|
673
673
|
locale: A,
|
|
674
674
|
...m
|
|
675
|
-
}), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit",
|
|
675
|
+
}), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", S != null ? S : "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(l) && l > -1 && a.searchParams.set("offset", String(Math.floor(l))), typeof T == "boolean" && a.searchParams.set("includeUnpublished", String(T)), h && D(h) && a.searchParams.set("cacheSeconds", String(h)), g && D(g) && a.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
676
676
|
const d = E({
|
|
677
|
-
sort:
|
|
677
|
+
sort: w
|
|
678
678
|
});
|
|
679
|
-
for (const
|
|
680
|
-
a.searchParams.set(
|
|
679
|
+
for (const v in d)
|
|
680
|
+
a.searchParams.set(v, JSON.stringify(d[v]));
|
|
681
681
|
}
|
|
682
682
|
const x = {
|
|
683
683
|
...gt(),
|
|
@@ -694,8 +694,8 @@ const Xt = "v3", D = (t) => typeof t == "number" && !isNaN(t) && t >= 0, U = (t)
|
|
|
694
694
|
const d = et({
|
|
695
695
|
query: r
|
|
696
696
|
});
|
|
697
|
-
for (const
|
|
698
|
-
a.searchParams.set(
|
|
697
|
+
for (const v in d)
|
|
698
|
+
a.searchParams.set(v, JSON.stringify(d[v]));
|
|
699
699
|
}
|
|
700
700
|
return a;
|
|
701
701
|
}, zt = (t) => {
|
|
@@ -732,7 +732,7 @@ const Zt = async (t) => {
|
|
|
732
732
|
return await (await n(e.href, r)).json();
|
|
733
733
|
}, qt = async (t, e, n = U(t)) => {
|
|
734
734
|
const r = Wt(t.canTrack);
|
|
735
|
-
if (n.search.includes("preview="), !r || !(c() ||
|
|
735
|
+
if (n.search.includes("preview="), !r || !(c() || I === "reactNative"))
|
|
736
736
|
return e.results;
|
|
737
737
|
try {
|
|
738
738
|
const s = [];
|
|
@@ -778,8 +778,8 @@ const ue = async (t) => {
|
|
|
778
778
|
};
|
|
779
779
|
};
|
|
780
780
|
export {
|
|
781
|
-
|
|
782
|
-
|
|
781
|
+
k as MSG_PREFIX,
|
|
782
|
+
I as TARGET,
|
|
783
783
|
qt as _processContentResult,
|
|
784
784
|
xt as _track,
|
|
785
785
|
y as checkIsDefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-0dcb0303.cjs");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-ee54171f.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
s as createRegisterComponentMessage,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-
|
|
1
|
+
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-ee54171f.js";
|
|
2
2
|
const getFunctionArguments = ({
|
|
3
3
|
builder: e,
|
|
4
4
|
context: t,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const serverEntry=require("./server-entry-
|
|
1
|
+
"use strict";const serverEntry=require("./server-entry-0dcb0303.cjs"),getFunctionArguments=({builder:e,context:t,event:s,state:r})=>Object.entries({state:r,Builder:e,builder:e,context:t,event:s}),getBuilderGlobals=()=>({isEditing:serverEntry.isEditing(),isBrowser:serverEntry.isBrowser(),isServer:!serverEntry.isBrowser(),getUserAttributes:()=>serverEntry.getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function flattenState({rootState:e,localState:t,rootSetState:s}){return new Proxy(e,{get:(r,n)=>{if(t&&n in t)return t[n];const o=r[n];return typeof o=="object"&&o!==null?flattenState({rootState:o,localState:void 0,rootSetState:s?i=>{r[n]=i,s(r)}:void 0}):o},set:(r,n,o)=>{if(t&&n in t)throw new Error("Writing to local state is not allowed as it is read-only.");return r[n]=o,s==null||s(r),!0}})}const SDK_NAME_FOR_TARGET=(()=>{switch(serverEntry.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return serverEntry.TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,s)=>{if(Object(e)!==e)return e;const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return r.slice(0,-1).reduce((n,o,i)=>Object(n[o])===n[o]?n[o]:n[o]=Math.abs(Number(r[i+1]))>>0===+r[i+1]?[]:{},e)[r[r.length-1]]=s,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=eval("require")}catch(e){}const getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
package/lib/node/setIvm.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./setIvm-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./setIvm-d479356f.cjs");require("./server-entry-0dcb0303.cjs");exports.setIvm=e.setIvm;
|
package/lib/node/setIvm.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("./server-entry-
|
|
1
|
+
"use strict";const s=require("./server-entry-0dcb0303.cjs");function t(){var e;return typeof process!="undefined"&&s.checkIsDefined((e=process==null?void 0:process.versions)==null?void 0:e.node)}const c=({shouldLogWarning:e})=>{var o;if(!t())return!1;const n=process.arch==="arm64",r=process.version.startsWith("v20"),i=(o=process.env.NODE_OPTIONS)==null?void 0:o.includes("--no-node-snapshot");return n&&r&&!i?(e&&s.logger.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "),!0):!1};exports.shouldForceBrowserRuntimeInNode=c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkIsDefined as i, logger as t } from "./server-entry-
|
|
1
|
+
import { checkIsDefined as i, logger as t } from "./server-entry-ee54171f.js";
|
|
2
2
|
function a() {
|
|
3
3
|
var o;
|
|
4
4
|
return typeof process != "undefined" && i((o = process == null ? void 0 : process.versions) == null ? void 0 : o.node);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.6";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BuilderContent } from '../../types/builder-content';
|
|
2
|
-
export declare function postPreviewContent(
|
|
2
|
+
export declare function postPreviewContent(_opts: {
|
|
3
3
|
key: string;
|
|
4
4
|
value: BuilderContent;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}>;
|
|
5
|
+
url: string;
|
|
6
|
+
}): Promise<any>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const y="react",k="[Builder.io]: ",d={log:(...t)=>console.log(k,...t),error:(...t)=>console.error(k,...t),warn:(...t)=>console.warn(k,...t),debug:(...t)=>console.debug(k,...t)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const mt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},j=t=>t instanceof URLSearchParams?mt(t):t,W=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function bt(){return c()&&window.self!==window.top}function $(t){return bt()&&W(t||window.location.search).indexOf("builder.frameEditing=")!==-1}const yt=()=>{if(c()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},St=()=>typeof navigator=="object"&&navigator.userAgent||"",G=()=>{const t=St(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||y==="reactNative"}},n=t.match(/Tablet|iPad/i),r=yt();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},p=t=>t!=null;function wt(t){const e=t||(c()?window.location.search:void 0);return e?W(e).indexOf("builder.preview=")!==-1:!1}const vt=t=>({type:"builder.registerComponent",data:C(t)}),kt=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function C(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?kt(n):n))}const F={};function J(t,e){t==="plugin"&&(e=C(e));let n=F[t];if(n||(n=F[t]=[]),n.push(e),c()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const V={};function Et(t){if(c()){Object.assign(V,t);const e={type:"builder.settingsChange",data:V};parent.postMessage(e,"*")}}const D="builder.",It="options.",P=t=>{if(!t)return{};const e=j(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(D)){const s=r.replace(D,"").replace(It,"");n[s]=e[r]}}),n},At=()=>{if(!c())return{};const t=new URLSearchParams(window.location.search);return P(t)},z="4.0.5",X=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z}),Ot=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},E=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},H=async t=>E(t),Ct=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),Pt=[["secure",""],["SameSite","None"]],Ut=({name:t,value:e,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Pt:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",Ot(window.location.hostname)],...s];return Ct(i)},U=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=Ut({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Tt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function Q(){return Tt().replace(/-/g,"")}const Y="builderSessionId",Bt=async({canTrack:t})=>{if(!t)return;const e=await H({name:Y,canTrack:t});if(p(e))return e;{const n=xt();return Rt({id:n,canTrack:t}),n}},xt=()=>Q(),Rt=({id:t,canTrack:e})=>U({name:Y,value:t,canTrack:e}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Lt=({key:t,canTrack:e})=>{var n;try{return e?(n=Z())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Nt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=Z())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Ft=({canTrack:t})=>{if(!t)return;const e=Lt({key:q,canTrack:t});if(p(e))return e;{const n=Vt();return Dt({id:n,canTrack:t}),n}},Vt=()=>Q(),Dt=({id:t,canTrack:e})=>Nt({key:q,value:t,canTrack:e});function tt(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Mt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await Bt({canTrack:t}),n=Ft({canTrack:t});return{sessionId:e,visitorId:n}},Kt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await Mt({canTrack:e}),userAttributes:G(),ownerId:n}});async function et({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||$()||!(c()||y==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return tt(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await Kt(e)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const _t=t=>et({...t,canTrack:!0}),jt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function nt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||jt).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const Wt=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let M=!1;const rt=t=>{var e,n;M||(M=!0,c()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:t.modelName,apiKey:t.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!nt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,I=new Function(u);let l,g=null;try{l=I.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!nt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===t&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},$t=({model:t,apiKey:e,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};rt({modelName:t,apiKey:e});const s=st({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:t,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Gt="builder.tests",T=t=>`${Gt}.${t}`,Jt=({contentId:t})=>H({name:T(t),canTrack:!0}),zt=({contentId:t})=>E({name:T(t),canTrack:!0}),Xt=({contentId:t,value:e})=>U({name:T(t),value:e,canTrack:!0}),ot=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Ht=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},it=t=>{const e=Ht(t);return Xt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},at=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Qt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const n=zt({contentId:t.id})||it({variations:t.variations,id:t.id}),r=at({item:t,testGroupId:n});return{...t,...r}},Yt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const r=await Jt({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:r});return{...t,...s}},K="builder.userAttributes";function Zt(){let t=!0;const e=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};U({name:K,value:JSON.stringify(r),canTrack:t}),e.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(E({name:K,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(n){return e.add(n),()=>{e.delete(n)}},setCanTrack(n){t=n}}}const B=Zt(),qt=t=>{B.setUserAttributes(t)},ct=t=>{const e=p(t)?t:!0;return B.setCanTrack(e),e};function te(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ee(){const t=te().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const ne=ee();function O(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...O(o,i,n)}:{...r,[i]:o}},{})}function ut(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,n):n[o]=s}return n}function re(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",_=t=>typeof t=="number"&&!isNaN(t)&&t>=0,x=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=se,fields:m,omit:I,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:R,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",a=new URL(`${pt}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(e)),a.searchParams.set("noTraverse",String(ht)),a.searchParams.set("includeRefs",String(!0));const A=u||(n==null?void 0:n.locale);let b=n||{};if(A&&(a.searchParams.set("locale",A),b={locale:A,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",I||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=O({sort:w});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}const L={...At(),...j(t.options||{})};b={...b,...ie(L)};const N=O(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ut({query:r});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}return a},oe=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ie=t=>{if(c()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=oe(t),{userAttributes:n}=re(e);return n}return{}},ae=t=>"results"in t;async function lt(t){const e=await ft({...t,limit:1});return e&&e[0]||null}const ce=async t=>{var i,u;const e=x(t),n=(i=t.fetch)!=null?i:ne,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...X()}};return await(await n(e.href,r)).json()},dt=async(t,e,n=x(t))=>{const r=ct(t.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await Yt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function ft(t){const e=x(t),n=await ce(t);if(!ae(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return dt(t,n)}const ue=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:P(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await lt(n)}};exports.TARGET=y;exports._processContentResult=dt;exports._track=et;exports.checkIsDefined=p;exports.createEditorListener=st;exports.createRegisterComponentMessage=vt;exports.fetchBuilderProps=ue;exports.fetchEntries=ft;exports.fetchOneEntry=lt;exports.getBuilderSearchParams=P;exports.getCookieSync=E;exports.getDefaultCanTrack=ct;exports.getUserAttributes=G;exports.handleABTestingSync=Qt;exports.isBrowser=c;exports.isEditing=$;exports.isPreviewing=wt;exports.logFetch=tt;exports.logger=d;exports.register=J;exports.registerInsertMenu=Wt;exports.serializeIncludingFunctions=C;exports.setClientUserAttributes=qt;exports.setEditorSettings=Et;exports.setupBrowserForEditing=rt;exports.subscribeToEditor=$t;exports.track=_t;exports.userAttributesService=B;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function c(){return typeof window!="undefined"&&typeof document!="undefined"}const k="[Builder.io]: ",d={log:(...t)=>console.log(k,...t),error:(...t)=>console.error(k,...t),warn:(...t)=>console.warn(k,...t),debug:(...t)=>console.debug(k,...t)},p=t=>t!=null,mt=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},E=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},j=async t=>E(t),bt=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),yt=[["secure",""],["SameSite","None"]],St=({name:t,value:e,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?yt:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",mt(window.location.hostname)],...s];return bt(i)},C=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=St({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}},F="builder.userAttributes";function wt(){let t=!0;const e=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};C({name:F,value:JSON.stringify(r),canTrack:t}),e.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(E({name:F,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(n){return e.add(n),()=>{e.delete(n)}},setCanTrack(n){t=n}}}const P=wt(),vt=t=>{P.setUserAttributes(t)},y="react",kt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},W=t=>t instanceof URLSearchParams?kt(t):t,$=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function Et(){return c()&&window.self!==window.top}function G(t){return Et()&&$(t||window.location.search).indexOf("builder.frameEditing=")!==-1}function It(t){const e=t||(c()?window.location.search:void 0);return e?$(e).indexOf("builder.preview=")!==-1:!1}const At=t=>({type:"builder.registerComponent",data:U(t)}),Ot=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function U(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?Ot(n):n))}const V={};function J(t,e){t==="plugin"&&(e=U(e));let n=V[t];if(n||(n=V[t]=[]),n.push(e),c()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const D={};function Ct(t){if(c()){Object.assign(D,t);const e={type:"builder.settingsChange",data:D};parent.postMessage(e,"*")}}const M="builder.",Pt="options.",T=t=>{if(!t)return{};const e=W(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(M)){const s=r.replace(M,"").replace(Pt,"");n[s]=e[r]}}),n},Ut=()=>{if(!c())return{};const t=new URLSearchParams(window.location.search);return T(t)},z="4.0.5",X=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z});function Tt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function H(){return Tt().replace(/-/g,"")}const Q="builderSessionId",Bt=async({canTrack:t})=>{if(!t)return;const e=await j({name:Q,canTrack:t});if(p(e))return e;{const n=xt();return Rt({id:n,canTrack:t}),n}},xt=()=>H(),Rt=({id:t,canTrack:e})=>C({name:Q,value:t,canTrack:e}),Y=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Lt=({key:t,canTrack:e})=>{var n;try{return e?(n=Y())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Nt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=Y())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},Z="builderVisitorId",Ft=({canTrack:t})=>{if(!t)return;const e=Lt({key:Z,canTrack:t});if(p(e))return e;{const n=Vt();return Dt({id:n,canTrack:t}),n}},Vt=()=>H(),Dt=({id:t,canTrack:e})=>Nt({key:Z,value:t,canTrack:e});function q(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Mt=()=>{if(c()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Kt=()=>typeof navigator=="object"&&navigator.userAgent||"",tt=()=>{const t=Kt(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||y==="reactNative"}},n=t.match(/Tablet|iPad/i),r=Mt();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},_t=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await Bt({canTrack:t}),n=Ft({canTrack:t});return{sessionId:e,visitorId:n}},jt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await _t({canTrack:e}),userAttributes:tt(),ownerId:n}});async function et({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||G()||!(c()||y==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return q(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await jt(e)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const Wt=t=>et({...t,canTrack:!0}),$t=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function nt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||$t).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const Gt=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let K=!1;const rt=t=>{var e,n;K||(K=!0,c()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:t.modelName,apiKey:t.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!nt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,I=new Function(u);let l,g=null;try{l=I.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!nt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===t&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},Jt=({model:t,apiKey:e,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};rt({modelName:t,apiKey:e});const s=st({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:t,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},zt="builder.tests",B=t=>`${zt}.${t}`,Xt=({contentId:t})=>j({name:B(t),canTrack:!0}),Ht=({contentId:t})=>E({name:B(t),canTrack:!0}),Qt=({contentId:t,value:e})=>C({name:B(t),value:e,canTrack:!0}),ot=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Yt=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},it=t=>{const e=Yt(t);return Qt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},at=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Zt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const n=Ht({contentId:t.id})||it({variations:t.variations,id:t.id}),r=at({item:t,testGroupId:n});return{...t,...r}},qt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const r=await Xt({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:r});return{...t,...s}},ct=t=>{const e=p(t)?t:!0;return P.setCanTrack(e),e};function te(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ee(){const t=te().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const ne=ee();function O(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...O(o,i,n)}:{...r,[i]:o}},{})}function ut(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,n):n[o]=s}return n}function re(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",_=t=>typeof t=="number"&&!isNaN(t)&&t>=0,x=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=se,fields:m,omit:I,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:R,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",a=new URL(`${pt}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(e)),a.searchParams.set("noTraverse",String(ht)),a.searchParams.set("includeRefs",String(!0));const A=u||(n==null?void 0:n.locale);let b=n||{};if(A&&(a.searchParams.set("locale",A),b={locale:A,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",I||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=O({sort:w});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}const L={...Ut(),...W(t.options||{})};b={...b,...ie(L)};const N=O(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ut({query:r});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}return a},oe=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ie=t=>{if(c()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=oe(t),{userAttributes:n}=re(e);return n}return{}},ae=t=>"results"in t;async function lt(t){const e=await ft({...t,limit:1});return e&&e[0]||null}const ce=async t=>{var i,u;const e=x(t),n=(i=t.fetch)!=null?i:ne,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...X()}};return await(await n(e.href,r)).json()},dt=async(t,e,n=x(t))=>{const r=ct(t.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await qt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function ft(t){const e=x(t),n=await ce(t);if(!ae(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return dt(t,n)}const ue=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:T(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await lt(n)}};exports.TARGET=y;exports._processContentResult=dt;exports._track=et;exports.checkIsDefined=p;exports.createEditorListener=st;exports.createRegisterComponentMessage=At;exports.fetchBuilderProps=ue;exports.fetchEntries=ft;exports.fetchOneEntry=lt;exports.getBuilderSearchParams=T;exports.getCookieSync=E;exports.getDefaultCanTrack=ct;exports.getUserAttributes=tt;exports.handleABTestingSync=Zt;exports.isBrowser=c;exports.isEditing=G;exports.isPreviewing=It;exports.logFetch=q;exports.logger=d;exports.register=J;exports.registerInsertMenu=Gt;exports.serializeIncludingFunctions=U;exports.setClientUserAttributes=vt;exports.setEditorSettings=Ct;exports.setupBrowserForEditing=rt;exports.subscribeToEditor=Jt;exports.track=Wt;exports.userAttributesService=P;
|