@builder.io/sdk-react 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/lib/browser/blocks-exports.cjs +187 -0
- package/lib/browser/blocks-exports.mjs +3441 -0
- package/lib/browser/index.cjs +1 -187
- package/lib/browser/index.mjs +26 -3449
- package/lib/browser/{server-entry-a595b1cf.cjs → server-entry-093e302c.cjs} +1 -1
- package/lib/browser/{server-entry-f6f9bdcb.js → server-entry-7839c812.js} +1 -1
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/blocks-0fc8e8d2.js +3385 -0
- package/lib/edge/blocks-exports.cjs +1 -0
- package/lib/edge/blocks-exports.mjs +16 -0
- package/lib/edge/blocks-f8688fcb.cjs +32 -0
- package/lib/edge/button-61181684.cjs +1 -0
- package/lib/edge/button-d9bbef90.js +29 -0
- package/lib/edge/columns-d152e266.cjs +28 -0
- package/lib/edge/columns-f7a9bca7.js +156 -0
- package/lib/edge/content-variants-cdcbcdd8.js +1711 -0
- package/lib/edge/content-variants-d2500971.cjs +133 -0
- package/lib/edge/custom-code-33b73ed1.js +44 -0
- package/lib/edge/custom-code-7390ba8b.cjs +1 -0
- package/lib/edge/dynamic-blocks-exports.cjs +39 -0
- package/lib/edge/dynamic-blocks-exports.mjs +37 -0
- package/lib/edge/dynamic-renderer-b5124984.js +9 -0
- package/lib/edge/dynamic-renderer-c00b8bcb.cjs +1 -0
- package/lib/edge/embed-11e03fa7.js +38 -0
- package/lib/edge/embed-9edce7df.cjs +1 -0
- package/lib/edge/form-ac531791.cjs +1 -0
- package/lib/edge/form-fb5fd55e.js +194 -0
- package/lib/edge/fragment-015b0912.js +8 -0
- package/lib/edge/fragment-61ef192d.cjs +1 -0
- package/lib/edge/get-class-prop-name-caee6506.cjs +1 -0
- package/lib/edge/get-class-prop-name-f22d7d53.js +18 -0
- package/lib/edge/image-6a3654d5.js +118 -0
- package/lib/edge/image-e4128296.cjs +17 -0
- package/lib/edge/img-317659e2.js +21 -0
- package/lib/edge/img-f2eeaa75.cjs +1 -0
- package/lib/edge/index.cjs +1 -207
- package/lib/edge/index.mjs +25 -5922
- package/lib/edge/input-526ea905.js +21 -0
- package/lib/edge/input-562438c4.cjs +1 -0
- package/lib/edge/section-68fbc212.js +26 -0
- package/lib/edge/section-70c8b709.cjs +1 -0
- package/lib/edge/select-17802399.js +21 -0
- package/lib/edge/select-d87a6280.cjs +1 -0
- package/lib/edge/server-entry-88f58ed4.cjs +2 -0
- package/lib/edge/{server-entry-f6f9bdcb.js → server-entry-e0830caf.js} +373 -372
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/slot-39b50f6b.cjs +1 -0
- package/lib/edge/slot-eb244885.js +33 -0
- package/lib/edge/submit-button-13d8d5a7.cjs +1 -0
- package/lib/edge/submit-button-71dd4015.js +8 -0
- package/lib/edge/symbol-bf773f2a.js +78 -0
- package/lib/edge/symbol-ee31bb7f.cjs +1 -0
- package/lib/edge/text-15f0a6f4.js +18 -0
- package/lib/edge/text-7fdbde16.cjs +1 -0
- package/lib/edge/video-66b20833.js +106 -0
- package/lib/edge/video-702696a8.cjs +1 -0
- package/lib/node/blocks-exports.cjs +227 -0
- package/lib/node/blocks-exports.mjs +3548 -0
- package/lib/node/index.cjs +1 -227
- package/lib/node/index.mjs +27 -3556
- package/lib/node/{server-entry-31b5d683.cjs → server-entry-0e638a4f.cjs} +1 -1
- package/lib/node/{server-entry-c2b6d198.js → server-entry-e1cc0803.js} +1 -1
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +19 -13
- package/types/blocks/button/index.d.ts +1 -0
- package/types/blocks/columns/index.d.ts +1 -0
- package/types/blocks/custom-code/index.d.ts +1 -0
- package/types/blocks/embed/index.d.ts +1 -0
- package/types/blocks/form/form/index.d.ts +1 -0
- package/types/blocks/form/input/index.d.ts +1 -0
- package/types/blocks/form/select/index.d.ts +1 -0
- package/types/blocks/form/submit-button/index.d.ts +1 -0
- package/types/blocks/fragment/index.d.ts +1 -0
- package/types/blocks/image/index.d.ts +1 -0
- package/types/blocks/img/index.d.ts +1 -0
- package/types/blocks/raw-text/index.d.ts +1 -0
- package/types/blocks/section/index.d.ts +1 -0
- package/types/blocks/slot/index.d.ts +1 -0
- package/types/blocks/symbol/index.d.ts +1 -0
- package/types/blocks/text/index.d.ts +1 -0
- package/types/blocks/textarea/index.d.ts +1 -0
- package/types/blocks/video/index.d.ts +1 -0
- package/types/components/blocks/index.d.ts +1 -0
- package/types/components/content-variants/index.d.ts +1 -0
- package/types/components/error-boundary.d.ts +11 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/get-content/types.d.ts +1 -1
- package/types/index-helpers/blocks-exports.d.ts +10 -11
- package/lib/edge/server-entry-a595b1cf.cjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";const S="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"}function ae(){return c()&&window.self!==window.top}function k(){return ae()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const ce=()=>{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},ue=()=>typeof navigator=="object"&&navigator.userAgent||"",U=()=>{const e=ue(),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()||S==="reactNative"}},n=e.match(/Tablet|iPad/i),r=ce();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"}},C=e=>JSON.parse(JSON.stringify(e)),p=e=>e!=null,de=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},F=({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}},N=async e=>F(e),le=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),fe=[["secure",""],["SameSite","None"]],ge=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?fe:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",de(window.location.hostname)],...o];return le(a)},D=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ge({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},he="builder.tests",P=e=>`${he}.${e}`,pe=({contentId:e})=>N({name:P(e),canTrack:!0}),me=({contentId:e})=>F({name:P(e),canTrack:!0}),ye=({contentId:e,value:t})=>D({name:P(e),value:t,canTrack:!0}),j=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,we=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},K=e=>{const t=we(e);return ye({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},_=({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":"")}},be=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!j(e))return e;const n=me({contentId:e.id})||K({variations:e.variations,id:e.id}),r=_({item:e,testGroupId:n});return{...e,...r}},Se=async({item:e,canTrack:t})=>{if(!t||!j(e))return e;const r=await pe({contentId:e.id})||K({variations:e.variations,id:e.id}),o=_({item:e,testGroupId:r});return{...e,...o}},W=e=>p(e)?e:!0,Ie=e=>({type:"builder.registerComponent",data:$(e)}),ve=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`},Ee=e=>typeof e=="function"?ve(e):C(e),$=({inputs:e,...t})=>({...C(t),inputs:e==null?void 0:e.map(n=>Object.entries(n).reduce((r,[o,s])=>({...r,[o]:Ee(s)}),{}))});function ke(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Ce(){const e=ke().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 G=Ce();function v(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...v(s,a,n)}:{...r,[a]:s}},{})}const Pe="v3",R="builder.",Oe="options.",Te=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},O=e=>{if(!e)return{};const t=J(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(R)){const o=r.replace(R,"").replace(Oe,"");n[o]=t[r]}}),n},xe=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return O(e)},J=e=>e instanceof URLSearchParams?Te(e):e,B=e=>typeof e=="number"&&!isNaN(e)&&e>=0,T=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Pe,fields:m,omit:E,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:x}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const se=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(se)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",E||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof x=="boolean"&&i.searchParams.set("includeUnpublished",String(x)),g&&B(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&B(h)&&i.searchParams.set("staleCacheSeconds",String(h)),w){const f=v({sort:w});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}const ie={...xe(),...J(e.options||{})},A=v(ie);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=v({query:r});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}return i},Ae=e=>"results"in e;async function z(e){const t=await X({...e,limit:1});return t&&t[0]||null}const Re=async e=>{const t=T(e);return await(await G(t.href)).json()},H=async(e,t,n=T(e))=>{const r=W(e.canTrack);if(n.search.includes("preview="),!r||!(c()||S==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await Se({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function X(e){try{const t=T(e),n=await Re(e);return Ae(n)?H(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(){return!c()||k()?!1:location.search.indexOf("builder.preview=")!==-1}function Le(){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 Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await N({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>q(),Ue=({id:e,canTrack:t})=>D({name:Y,value:e,canTrack:t}),Q=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({key:e,canTrack:t})=>{var n;try{return t?(n=Q())==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=Q())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},Z="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:Z,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>q(),Ke=({id:e,canTrack:t})=>Ne({key:Z,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:U(),ownerId:n}});async function ee(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!k()&&(c()||S==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>ee({...e,canTrack:!0}),Ge=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function te(e,t){const n=new URL(t.origin),r=n.hostname;return(e||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Je="1.0.
|
|
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 G=Ce();function v(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...v(s,a,n)}:{...r,[a]:s}},{})}const Pe="v3",R="builder.",Oe="options.",Te=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},O=e=>{if(!e)return{};const t=J(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(R)){const o=r.replace(R,"").replace(Oe,"");n[o]=t[r]}}),n},xe=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return O(e)},J=e=>e instanceof URLSearchParams?Te(e):e,B=e=>typeof e=="number"&&!isNaN(e)&&e>=0,T=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Pe,fields:m,omit:E,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:x}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const se=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(se)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",E||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof x=="boolean"&&i.searchParams.set("includeUnpublished",String(x)),g&&B(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&B(h)&&i.searchParams.set("staleCacheSeconds",String(h)),w){const f=v({sort:w});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}const ie={...xe(),...J(e.options||{})},A=v(ie);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=v({query:r});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}return i},Ae=e=>"results"in e;async function z(e){const t=await X({...e,limit:1});return t&&t[0]||null}const Re=async e=>{const t=T(e);return await(await G(t.href)).json()},H=async(e,t,n=T(e))=>{const r=W(e.canTrack);if(n.search.includes("preview="),!r||!(c()||S==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await Se({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function X(e){try{const t=T(e),n=await Re(e);return Ae(n)?H(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(){return!c()||k()?!1:location.search.indexOf("builder.preview=")!==-1}function Le(){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 Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await N({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>q(),Ue=({id:e,canTrack:t})=>D({name:Y,value:e,canTrack:t}),Q=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({key:e,canTrack:t})=>{var n;try{return t?(n=Q())==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=Q())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},Z="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:Z,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>q(),Ke=({id:e,canTrack:t})=>Ne({key:Z,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:U(),ownerId:n}});async function ee(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!k()&&(c()||S==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>ee({...e,canTrack:!0}),Ge=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function te(e,t){const n=new URL(t.origin),r=n.hostname;return(e||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Je="1.0.4",L={};function ne(e,t){let n=L[e];if(n||(n=L[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(o){console.debug("Could not postmessage",o)}}}const ze=()=>{ne("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 V=!1;const re=(e={})=>{var t,n;V||(V=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:S,version:Je,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!te(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,E=new Function(l);let u,g=null;try{u=E.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},oe=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!te(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},He=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};re();const r=oe({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},M={};function Xe(e){if(c()){Object.assign(M,e);const t={type:"builder.settingsChange",data:M};parent.postMessage(t,"*")}}const qe=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:O(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await z(n)}};exports.TARGET=S;exports._processContentResult=H;exports._track=ee;exports.checkIsDefined=p;exports.createEditorListener=oe;exports.createRegisterComponentMessage=Ie;exports.fastClone=C;exports.fetch=G;exports.fetchBuilderProps=qe;exports.fetchEntries=X;exports.fetchOneEntry=z;exports.getBuilderSearchParams=O;exports.getDefaultCanTrack=W;exports.getUserAttributes=U;exports.handleABTestingSync=be;exports.isBrowser=c;exports.isEditing=k;exports.isPreviewing=Be;exports.logger=d;exports.register=ne;exports.registerInsertMenu=ze;exports.serializeComponentInfo=$;exports.setEditorSettings=Xe;exports.setupBrowserForEditing=re;exports.subscribeToEditor=He;exports.track=$e;
|
|
@@ -472,7 +472,7 @@ function H(e, t) {
|
|
|
472
472
|
const n = new URL(t.origin), r = n.hostname;
|
|
473
473
|
return (e || Fe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
474
474
|
}
|
|
475
|
-
const je = "1.0.
|
|
475
|
+
const je = "1.0.4", A = {};
|
|
476
476
|
function De(e, t) {
|
|
477
477
|
let n = A[e];
|
|
478
478
|
if (n || (n = A[e] = []), n.push(t), c()) {
|
|
@@ -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-0e638a4f.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 { _ as t, c as r, f as a, d as i, e as n, g as o, i as c, a as g, r as d, s as f, b as E, t as h } from "./server-entry-
|
|
1
|
+
import { _ as t, c as r, f as a, d as i, e as n, g as o, i as c, a as g, r as d, s as f, b as E, t as h } from "./server-entry-e1cc0803.js";
|
|
2
2
|
export {
|
|
3
3
|
t as _processContentResult,
|
|
4
4
|
r as createRegisterComponentMessage,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react",
|
|
3
3
|
"description": "Builder.io SDK for React",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -18,16 +18,6 @@
|
|
|
18
18
|
"module": "./lib/node/index.mjs",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"node": {
|
|
22
|
-
"types": "./types/index.d.ts",
|
|
23
|
-
"import": "./lib/node/index.mjs",
|
|
24
|
-
"require": "./lib/node/index.cjs"
|
|
25
|
-
},
|
|
26
|
-
"browser": {
|
|
27
|
-
"types": "./types/index.d.ts",
|
|
28
|
-
"import": "./lib/browser/index.mjs",
|
|
29
|
-
"require": "./lib/browser/index.cjs"
|
|
30
|
-
},
|
|
31
21
|
"edge-routine": {
|
|
32
22
|
"types": "./types/index.d.ts",
|
|
33
23
|
"import": "./lib/edge/index.mjs",
|
|
@@ -73,6 +63,16 @@
|
|
|
73
63
|
"import": "./lib/node/index.mjs",
|
|
74
64
|
"require": "./lib/node/index.cjs"
|
|
75
65
|
},
|
|
66
|
+
"node": {
|
|
67
|
+
"types": "./types/index.d.ts",
|
|
68
|
+
"import": "./lib/node/index.mjs",
|
|
69
|
+
"require": "./lib/node/index.cjs"
|
|
70
|
+
},
|
|
71
|
+
"browser": {
|
|
72
|
+
"types": "./types/index.d.ts",
|
|
73
|
+
"import": "./lib/browser/index.mjs",
|
|
74
|
+
"require": "./lib/browser/index.cjs"
|
|
75
|
+
},
|
|
76
76
|
"default": {
|
|
77
77
|
"types": "./types/index.d.ts",
|
|
78
78
|
"import": "./lib/browser/index.mjs",
|
|
@@ -80,16 +80,21 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"./edge": {
|
|
83
|
+
"types": "./types/index.d.ts",
|
|
84
|
+
"import": "./lib/edge/dynamic-blocks-exports.mjs",
|
|
85
|
+
"require": "./lib/edge/dynamic-blocks-exports.cjs"
|
|
86
|
+
},
|
|
87
|
+
"./bundle/edge": {
|
|
83
88
|
"types": "./types/index.d.ts",
|
|
84
89
|
"import": "./lib/edge/index.mjs",
|
|
85
90
|
"require": "./lib/edge/index.cjs"
|
|
86
91
|
},
|
|
87
|
-
"./node": {
|
|
92
|
+
"./bundle/node": {
|
|
88
93
|
"types": "./types/index.d.ts",
|
|
89
94
|
"import": "./lib/node/index.mjs",
|
|
90
95
|
"require": "./lib/node/index.cjs"
|
|
91
96
|
},
|
|
92
|
-
"./browser": {
|
|
97
|
+
"./bundle/browser": {
|
|
93
98
|
"types": "./types/index.d.ts",
|
|
94
99
|
"import": "./lib/browser/index.mjs",
|
|
95
100
|
"require": "./lib/browser/index.cjs"
|
|
@@ -121,6 +126,7 @@
|
|
|
121
126
|
"nx": "^16.6.0",
|
|
122
127
|
"nx-cloud": "^16.2.0",
|
|
123
128
|
"react": "^18.2.0",
|
|
129
|
+
"recast": "^0.23.4",
|
|
124
130
|
"rimraf": "^3.0.2",
|
|
125
131
|
"typescript": "^4.9.4",
|
|
126
132
|
"vite": "^4.4.9"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './columns';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './custom-code';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './embed';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './form';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './input';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './select';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './submit-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './fragment';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './image';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './img';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './raw-text';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './section';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './slot';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './symbol';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './text';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './textarea';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './video';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './blocks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './content-variants';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default class ErrorBoundary extends React.Component<React.PropsWithChildren, {
|
|
3
|
+
hasError: boolean;
|
|
4
|
+
}> {
|
|
5
|
+
constructor(props: any);
|
|
6
|
+
static getDerivedStateFromError(_error: any): {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
};
|
|
9
|
+
componentDidCatch(error: any, info: any): void;
|
|
10
|
+
render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode>;
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.4";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export { default as Button } from '../blocks/button/
|
|
2
|
-
export { default as Columns } from '../blocks/columns/
|
|
3
|
-
export { default as Fragment } from '../blocks/fragment/
|
|
4
|
-
export { default as Image } from '../blocks/image/
|
|
5
|
-
export { default as Section } from '../blocks/section/
|
|
6
|
-
export { default as Symbol } from '../blocks/symbol/
|
|
7
|
-
export { default as Text } from '../blocks/text/
|
|
8
|
-
export { default as Video } from '../blocks/video/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export { Blocks, Content };
|
|
1
|
+
export { default as Button } from '../blocks/button/index.js';
|
|
2
|
+
export { default as Columns } from '../blocks/columns/index.js';
|
|
3
|
+
export { default as Fragment } from '../blocks/fragment/index.js';
|
|
4
|
+
export { default as Image } from '../blocks/image/index.js';
|
|
5
|
+
export { default as Section } from '../blocks/section/index.js';
|
|
6
|
+
export { default as Symbol } from '../blocks/symbol/index.js';
|
|
7
|
+
export { default as Text } from '../blocks/text/index.js';
|
|
8
|
+
export { default as Video } from '../blocks/video/index.js';
|
|
9
|
+
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
|
+
export { default as Content } from '../components/content-variants/index.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const S="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"}function ae(){return c()&&window.self!==window.top}function k(){return ae()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const ce=()=>{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},ue=()=>typeof navigator=="object"&&navigator.userAgent||"",U=()=>{const e=ue(),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()||S==="reactNative"}},n=e.match(/Tablet|iPad/i),r=ce();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,C=e=>JSON.parse(JSON.stringify(e)),de=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},F=({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}},N=async e=>F(e),le=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),fe=[["secure",""],["SameSite","None"]],ge=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?fe:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",de(window.location.hostname)],...o];return le(a)},D=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ge({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},he="builder.tests",P=e=>`${he}.${e}`,pe=({contentId:e})=>N({name:P(e),canTrack:!0}),me=({contentId:e})=>F({name:P(e),canTrack:!0}),ye=({contentId:e,value:t})=>D({name:P(e),value:t,canTrack:!0}),j=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,we=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},K=e=>{const t=we(e);return ye({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},_=({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":"")}},be=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!j(e))return e;const n=me({contentId:e.id})||K({variations:e.variations,id:e.id}),r=_({item:e,testGroupId:n});return{...e,...r}},Se=async({item:e,canTrack:t})=>{if(!t||!j(e))return e;const r=await pe({contentId:e.id})||K({variations:e.variations,id:e.id}),o=_({item:e,testGroupId:r});return{...e,...o}},W=e=>p(e)?e:!0,Ie=e=>({type:"builder.registerComponent",data:$(e)}),ve=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`},Ee=e=>typeof e=="function"?ve(e):C(e),$=({inputs:e,...t})=>({...C(t),inputs:e==null?void 0:e.map(n=>Object.entries(n).reduce((r,[o,s])=>({...r,[o]:Ee(s)}),{}))});function ke(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Ce(){const e=ke().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 G=Ce();function v(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...v(s,a,n)}:{...r,[a]:s}},{})}const Pe="v3",R="builder.",Oe="options.",Te=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},O=e=>{if(!e)return{};const t=J(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(R)){const o=r.replace(R,"").replace(Oe,"");n[o]=t[r]}}),n},xe=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return O(e)},J=e=>e instanceof URLSearchParams?Te(e):e,B=e=>typeof e=="number"&&!isNaN(e)&&e>=0,T=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Pe,fields:m,omit:E,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:x}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const se=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(se)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",E||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof x=="boolean"&&i.searchParams.set("includeUnpublished",String(x)),g&&B(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&B(h)&&i.searchParams.set("staleCacheSeconds",String(h)),w){const f=v({sort:w});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}const ie={...xe(),...J(e.options||{})},A=v(ie);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=v({query:r});for(const b in f)i.searchParams.set(b,JSON.stringify(f[b]))}return i},Ae=e=>"results"in e;async function z(e){const t=await X({...e,limit:1});return t&&t[0]||null}const Re=async e=>{const t=T(e);return await(await G(t.href)).json()},H=async(e,t,n=T(e))=>{const r=W(e.canTrack);if(n.search.includes("preview="),!r||!(c()||S==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await Se({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function X(e){try{const t=T(e),n=await Re(e);return Ae(n)?H(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(){return!c()||k()?!1:location.search.indexOf("builder.preview=")!==-1}function Le(){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 Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await N({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>q(),Ue=({id:e,canTrack:t})=>D({name:Y,value:e,canTrack:t}),Q=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({key:e,canTrack:t})=>{var n;try{return t?(n=Q())==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=Q())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},Z="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:Z,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>q(),Ke=({id:e,canTrack:t})=>Ne({key:Z,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:U(),ownerId:n}});async function ee(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!k()&&(c()||S==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>ee({...e,canTrack:!0}),Ge=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function te(e,t){const n=new URL(t.origin),r=n.hostname;return(e||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Je="1.0.2",L={};function ne(e,t){let n=L[e];if(n||(n=L[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(o){console.debug("Could not postmessage",o)}}}const ze=()=>{ne("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 V=!1;const re=(e={})=>{var t,n;V||(V=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:S,version:Je,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!te(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,E=new Function(l);let u,g=null;try{u=E.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},oe=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!te(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},He=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};re();const r=oe({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},M={};function Xe(e){if(c()){Object.assign(M,e);const t={type:"builder.settingsChange",data:M};parent.postMessage(t,"*")}}const qe=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:O(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await z(n)}};exports.TARGET=S;exports._processContentResult=H;exports._track=ee;exports.checkIsDefined=p;exports.createEditorListener=oe;exports.createRegisterComponentMessage=Ie;exports.fastClone=C;exports.fetch=G;exports.fetchBuilderProps=qe;exports.fetchEntries=X;exports.fetchOneEntry=z;exports.getBuilderSearchParams=O;exports.getDefaultCanTrack=W;exports.getUserAttributes=U;exports.handleABTestingSync=be;exports.isBrowser=c;exports.isEditing=k;exports.isPreviewing=Be;exports.logger=d;exports.register=ne;exports.registerInsertMenu=ze;exports.serializeComponentInfo=$;exports.setEditorSettings=Xe;exports.setupBrowserForEditing=re;exports.subscribeToEditor=He;exports.track=$e;
|