@builder.io/sdk-react 5.1.0 → 5.1.1
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 +15 -15
- package/lib/browser/blocks-exports.mjs +400 -368
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/{server-entry-7b82deab.cjs → server-entry-85aa99e6.cjs} +2 -2
- package/lib/browser/{server-entry-1df58bc2.js → server-entry-a3b5302c.js} +126 -126
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-ac489baa.cjs → accordion-1e467b30.cjs} +1 -1
- package/lib/edge/{accordion-a57423b4.js → accordion-83f68de4.js} +1 -1
- package/lib/edge/{blocks-612edfa7.cjs → blocks-4d57d38f.cjs} +12 -12
- package/lib/edge/{blocks-966052b8.js → blocks-6b821501.js} +359 -327
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-da479943.js → button-52af8a54.js} +2 -2
- package/lib/edge/{button-33b8e000.cjs → button-b2eb1d64.cjs} +1 -1
- package/lib/edge/{columns-476f3763.cjs → columns-8eb66fad.cjs} +1 -1
- package/lib/edge/{columns-384a8553.js → columns-e0489b50.js} +3 -3
- package/lib/edge/{content-variants-b281c0c9.js → content-variants-5003144d.js} +12 -12
- package/lib/edge/{content-variants-21daab2e.cjs → content-variants-6c1ee307.cjs} +2 -2
- package/lib/edge/{custom-code-8f1a8bf6.js → custom-code-4e76fc0d.js} +1 -1
- package/lib/edge/{custom-code-d420a6d1.cjs → custom-code-bc787526.cjs} +1 -1
- package/lib/edge/{embed-36d96f7c.cjs → embed-8ef248c5.cjs} +1 -1
- package/lib/edge/{embed-4baabd44.js → embed-fd344d6d.js} +1 -1
- package/lib/edge/{form-597542fa.cjs → form-107c9eae.cjs} +1 -1
- package/lib/edge/{form-7b4ce85e.js → form-4efa40a5.js} +3 -3
- package/lib/edge/{get-class-prop-name-0e04739a.cjs → get-class-prop-name-2c2513e9.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-71cc2ebb.js → get-class-prop-name-e6f7321f.js} +1 -1
- package/lib/edge/{img-f7f612f5.js → img-a32b0723.js} +2 -2
- package/lib/edge/{img-ac7c30e0.cjs → img-ab241f22.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-b6bd8bd9.cjs → input-ada30ffb.cjs} +1 -1
- package/lib/edge/{input-eb1cbd99.js → input-c48fe23a.js} +1 -1
- package/lib/edge/{personalization-container-c5a53dee.cjs → personalization-container-375a1501.cjs} +1 -1
- package/lib/edge/{personalization-container-5fd328ca.js → personalization-container-ad7cf89c.js} +4 -4
- package/lib/edge/{select-e0f16408.cjs → select-879c52dd.cjs} +1 -1
- package/lib/edge/{select-3f4a8f91.js → select-a49d819c.js} +1 -1
- package/lib/edge/{server-entry-00719c56.cjs → server-entry-560732da.cjs} +1 -1
- package/lib/edge/{server-entry-2d0b2a53.js → server-entry-68d59577.js} +1 -1
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-38a6fa40.js → slot-005d6258.js} +3 -3
- package/lib/edge/{slot-bf1f3ed7.cjs → slot-5da991d1.cjs} +1 -1
- package/lib/edge/{symbol-54dc2d3c.js → symbol-155906ed.js} +2 -2
- package/lib/edge/{symbol-3a09c0c2.cjs → symbol-7e6ac72e.cjs} +1 -1
- package/lib/edge/{tabs-312a6e0a.js → tabs-69a36a5c.js} +3 -3
- package/lib/edge/{tabs-c4a1844c.cjs → tabs-96367bf5.cjs} +1 -1
- package/lib/node/blocks-exports.cjs +5 -5
- package/lib/node/blocks-exports.mjs +143 -127
- 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-6fc232c7.cjs → server-entry-2529c06e.cjs} +2 -2
- package/lib/node/{server-entry-4228cc2b.js → server-entry-fc7f08d8.js} +126 -126
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-29867fb3.js → setIvm-41d8b067.js} +60 -44
- package/lib/node/setIvm-b97cfb8b.cjs +48 -0
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-eab67c2a.cjs → should-force-browser-runtime-in-node-1d85a066.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-7c48ac04.js → should-force-browser-runtime-in-node-fc5c3a06.js} +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/evaluate/evaluate.d.ts +1 -1
- package/types/functions/evaluate/helpers.d.ts +9 -1
- package/types/functions/get-block-actions-handler.d.ts +2 -0
- package/types/functions/get-block-actions.d.ts +2 -0
- package/lib/node/setIvm-5abc9e0c.cjs +0 -48
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-2529c06e.cjs");require("react/jsx-runtime");require("react");require("./setIvm-b97cfb8b.cjs");require("./should-force-browser-runtime-in-node-1d85a066.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.registerAction=e.registerAction;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 A, registerAction as R, setClientUserAttributes as T, setEditorSettings as v, subscribeToEditor as w, track as F } 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 A, registerAction as R, setClientUserAttributes as T, setEditorSettings as v, subscribeToEditor as w, track as F } from "./server-entry-fc7f08d8.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-41d8b067.js";
|
|
6
|
+
import "./should-force-browser-runtime-in-node-fc5c3a06.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-1d85a066.cjs"),t=require("isolated-vm"),r=require("./setIvm-b97cfb8b.cjs");require("./server-entry-2529c06e.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-fc5c3a06.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-41d8b067.js";
|
|
4
|
+
import "./server-entry-fc7f08d8.js";
|
|
5
5
|
const u = (o) => {
|
|
6
6
|
if (r({
|
|
7
7
|
shouldLogWarning: !0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const b="react",A="[Builder.io]: ",f={log:(...t)=>console.log(A,...t),error:(...t)=>console.error(A,...t),warn:(...t)=>console.warn(A,...t),debug:(...t)=>console.debug(A,...t)};function a(){return typeof window!="undefined"&&typeof document!="undefined"}const St=t=>{const e={};return t.forEach((r,n)=>{e[n]=r}),e},j=t=>t instanceof URLSearchParams?St(t):t,G=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function bt(){return a()&&window.self!==window.top}function $(t){return bt()&&G(t||window.location.search).indexOf("builder.frameEditing=")!==-1}const yt=()=>{if(a()){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},mt=()=>typeof navigator=="object"&&navigator.userAgent||"",J=()=>{const t=mt(),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()||b==="reactNative"}},r=t.match(/Tablet|iPad/i),n=yt();return{urlPath:n==null?void 0:n.pathname,host:(n==null?void 0:n.host)||(n==null?void 0:n.hostname),device:r?"tablet":e.any()?"mobile":"desktop"}},S=t=>t!=null;function wt(t){const e=t||(a()?window.location.search:void 0);return e?G(e).indexOf("builder.preview=")!==-1:!1}const Et=t=>({type:"builder.registerComponent",data:U(t)}),At=t=>{const e=t.toString().trim(),r=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!r?"function ":""}${e}).apply(this, arguments)`};function U(t){return JSON.parse(JSON.stringify(t,(e,r)=>typeof r=="function"?At(r):r))}const N={};function It(t,e){t==="plugin"&&(e=U(e));let r=N[t];if(r||(r=N[t]=[]),r.push(e),a()){const n={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(n,"*"),parent!==window&&window.postMessage(n,"*")}catch(s){console.debug("Could not postmessage",s)}}}function vt(t){var e;if(a()){const r=JSON.parse(JSON.stringify(t));t.action&&(r.action=t.action.toString()),(e=window.parent)==null||e.postMessage({type:"builder.registerAction",data:r},"*")}}const V={};function kt(t){if(a()){Object.assign(V,t);const e={type:"builder.settingsChange",data:V};parent.postMessage(e,"*")}}const D="builder.",Tt="options.",O=t=>{if(!t)return{};const e=j(t),r={};return Object.keys(e).forEach(n=>{if(n.startsWith(D)){const s=n.replace(D,"").replace(Tt,"");r[s]=e[n]}}),r},Ut=()=>{if(!a())return{};const t=new URLSearchParams(window.location.search);return O(t)},z="5.1.0",X=()=>({"X-Builder-SDK":b,"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},v=({name:t,canTrack:e})=>{var r;try{return e?(r=document.cookie.split("; ").find(n=>n.startsWith(`${t}=`)))==null?void 0:r.split("=")[1]:void 0}catch(n){f.warn("[COOKIE] GET error: ",(n==null?void 0:n.message)||n);return}},H=async t=>v(t),Pt=t=>t.map(([e,r])=>r?`${e}=${r}`:e).filter(S).join("; "),Rt=[["secure",""],["SameSite","None"]],Ct=({name:t,value:e,expires:r})=>{const s=(a()?location.protocol==="https:":!0)?Rt:[[]],o=r?[["expires",r.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",Ot(window.location.hostname)],...s];return Pt(i)},P=async({name:t,value:e,expires:r,canTrack:n})=>{try{if(!n)return;const s=Ct({name:t,value:e,expires:r});document.cookie=s}catch(s){f.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Bt(){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 Bt().replace(/-/g,"")}const Y="builderSessionId",_t=async({canTrack:t})=>{if(!t)return;const e=await H({name:Y,canTrack:t});if(S(e))return e;{const r=xt();return Lt({id:r,canTrack:t}),r}},xt=()=>Q(),Lt=({id:t,canTrack:e})=>P({name:Y,value:t,canTrack:e}),Z=()=>a()&&typeof localStorage!="undefined"?localStorage:void 0,Nt=({key:t,canTrack:e})=>{var r;try{return e?(r=Z())==null?void 0:r.getItem(t):void 0}catch(n){console.debug("[LocalStorage] GET error: ",n);return}},Vt=({key:t,canTrack:e,value:r})=>{var n;try{e&&((n=Z())==null||n.setItem(t,r))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Dt=({canTrack:t})=>{if(!t)return;const e=Nt({key:q,canTrack:t});if(S(e))return e;{const r=Ft();return Mt({id:r,canTrack:t}),r}},Ft=()=>Q(),Mt=({id:t,canTrack:e})=>Vt({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"&&f.log(t)}const Kt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await _t({canTrack:t}),r=Dt({canTrack:t});return{sessionId:e,visitorId:r}},Wt=async({type:t,canTrack:e,apiKey:r,metadata:n,...s})=>({type:t,data:{...s,metadata:{url:location.href,...n},...await Kt({canTrack:e}),userAttributes:J(),ownerId:r}});async function et({apiHost:t,...e}){if(!e.apiKey){f.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||$()||!(a()||b==="reactNative"))return;const n=`${t||"https://cdn.builder.io"}/api/v1/track`;return tt(n),fetch(n,{method:"POST",body:JSON.stringify({events:[await Wt(e)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const jt=t=>et({...t,canTrack:!0}),Gt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function rt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const r=new URL(e.origin),n=r.hostname;return(t||Gt).findIndex(s=>s.startsWith("*.")?n.endsWith(s.slice(1)):s===n)>-1}let F=!1;const nt=t=>{var e,r;F||(F=!0,a()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:b,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:t.modelName,apiKey:t.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(r=window.parent)==null||r.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",n=>{var o,i;if(!rt(t.trustedHosts,n))return;const{data:s}=n;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,l=s.data.arguments||[],y=s.data.id,m=new Function(u);let d,h=null;try{d=m.apply(null,l)}catch(p){h=p}h?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:y,error:h.message}},"*"):d&&typeof d.then=="function"?d.then(p=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:y,result:p}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:y}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:r})=>n=>{if(!rt(e,n))return;const{data:s}=n;if(s)switch(s.type){case"builder.configureSdk":{r.configureSdk(s.data);break}case"builder.triggerAnimation":{r.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state,l=o.editType;i===t&&u&&r.stateUpdate(u,l);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data,l=o.editType;i===t&&r.contentUpdate(u,l);break}}},$t=({model:t,apiKey:e,callback:r,trustedHosts:n})=>{if(!a)return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};nt({modelName:t,apiKey:e});const s=st({callbacks:{contentUpdate:r,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:t,trustedHosts:n});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Jt="builder.tests",R=t=>`${Jt}.${t}`,zt=({contentId:t})=>H({name:R(t),canTrack:!0}),Xt=({contentId:t})=>v({name:R(t),canTrack:!0}),Ht=({contentId:t,value:e})=>P({name:R(t),value:e,canTrack:!0}),ot=t=>S(t.id)&&S(t.variations)&&Object.keys(t.variations).length>0,Qt=({id:t,variations:e})=>{var s;let r=0;const n=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(r+=i,n<r)return o}return t},it=t=>{const e=Qt(t);return Ht({contentId:t.id,value:e}).catch(r=>{f.error("could not store A/B test variation: ",r)}),e},at=({item:t,testGroupId:e})=>{const r=t.variations[e];return e===t.id||!r?{testVariationId:t.id,testVariationName:"Default"}:{data:r.data,testVariationId:r.id,testVariationName:r.name||(r.id===t.id?"Default":"")}},Yt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const r=Xt({contentId:t.id})||it({variations:t.variations,id:t.id}),n=at({item:t,testGroupId:r});return{...t,...n}},Zt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const n=await zt({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:n});return{...t,...s}};const M="builder.userAttributes";function K(){let t=!0;const e=new Set;return{setUserAttributes(r){if(!a())return;const n={...this.getUserAttributes(),...r};P({name:M,value:JSON.stringify(n),canTrack:t}),e.forEach(s=>s(n))},getUserAttributes(){return a()?JSON.parse(v({name:M,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(r,{fireImmediately:n}={}){return e.add(r),n&&r(this.getUserAttributes()),function(){e.delete(r)}},setCanTrack(r){t=r}}}let k;a()&&b==="qwik"?(window.__BUILDER_USER_ATTRIBUTES_SERVICE__||(window.__BUILDER_USER_ATTRIBUTES_SERVICE__=K()),k=window.__BUILDER_USER_ATTRIBUTES_SERVICE__):k=K();const C=k,qt=t=>{C.setUserAttributes(t)},ct=t=>{const e=S(t)?t:!0;return C.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 re=ee();function T(t,e=null,r="."){return Object.keys(t).reduce((n,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(r);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...n,...T(o,i,r)}:{...n,[i]:o}},{})}function ut(t,e,r={}){for(const n in t){const s=t[n],o=e?e+"."+n:n;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,r):r[o]=s}return r}function ne(t){const e={};for(const r in t){const n=r.split(".");let s=e;for(let o=0;o<n.length;o++){const i=n[o];o===n.length-1?s[i]=t[r]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",W=t=>typeof t=="number"&&!isNaN(t)&&t>=0,B=t=>{const{limit:e=30,userAttributes:r,query:n,model:s,apiKey:o,enrich:i,locale:u,apiVersion:l=se,fields:y,omit:m,offset:d,cacheSeconds:h,staleCacheSeconds:p,sort:w,includeUnpublished:_,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(l))throw new Error(`Invalid apiVersion: expected 'v3', received '${l}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",c=new URL(`${pt}/api/${l}/content/${s}`);c.searchParams.set("apiKey",o),c.searchParams.set("limit",String(e)),c.searchParams.set("noTraverse",String(ht)),c.searchParams.set("includeRefs",String(!0)),u&&c.searchParams.set("locale",u);let I=r||{};if(i&&c.searchParams.set("enrich",String(i)),c.searchParams.set("omit",m!=null?m:"meta.componentsUsed"),y&&c.searchParams.set("fields",y),Number.isFinite(d)&&d>-1&&c.searchParams.set("offset",String(Math.floor(d))),typeof _=="boolean"&&c.searchParams.set("includeUnpublished",String(_)),h&&W(h)&&c.searchParams.set("cacheSeconds",String(h)),p&&W(p)&&c.searchParams.set("staleCacheSeconds",String(p)),w){const g=T({sort:w});for(const E in g)c.searchParams.set(E,JSON.stringify(g[E]))}const x={...
|
|
1
|
+
"use strict";const b="react",A="[Builder.io]: ",f={log:(...t)=>console.log(A,...t),error:(...t)=>console.error(A,...t),warn:(...t)=>console.warn(A,...t),debug:(...t)=>console.debug(A,...t)};function a(){return typeof window!="undefined"&&typeof document!="undefined"}const St=t=>{const e={};return t.forEach((r,n)=>{e[n]=r}),e},j=t=>t instanceof URLSearchParams?St(t):t,G=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function bt(){return a()&&window.self!==window.top}function $(t){return bt()&&G(t||window.location.search).indexOf("builder.frameEditing=")!==-1}const yt=()=>{if(a()){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},mt=()=>typeof navigator=="object"&&navigator.userAgent||"",J=()=>{const t=mt(),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()||b==="reactNative"}},r=t.match(/Tablet|iPad/i),n=yt();return{urlPath:n==null?void 0:n.pathname,host:(n==null?void 0:n.host)||(n==null?void 0:n.hostname),device:r?"tablet":e.any()?"mobile":"desktop"}},z="5.1.1",X=()=>({"X-Builder-SDK":b,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z}),S=t=>t!=null,wt=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},v=({name:t,canTrack:e})=>{var r;try{return e?(r=document.cookie.split("; ").find(n=>n.startsWith(`${t}=`)))==null?void 0:r.split("=")[1]:void 0}catch(n){f.warn("[COOKIE] GET error: ",(n==null?void 0:n.message)||n);return}},H=async t=>v(t),Et=t=>t.map(([e,r])=>r?`${e}=${r}`:e).filter(S).join("; "),At=[["secure",""],["SameSite","None"]],It=({name:t,value:e,expires:r})=>{const s=(a()?location.protocol==="https:":!0)?At:[[]],o=r?[["expires",r.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",wt(window.location.hostname)],...s];return Et(i)},U=async({name:t,value:e,expires:r,canTrack:n})=>{try{if(!n)return;const s=It({name:t,value:e,expires:r});document.cookie=s}catch(s){f.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function vt(){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 vt().replace(/-/g,"")}const Y="builderSessionId",kt=async({canTrack:t})=>{if(!t)return;const e=await H({name:Y,canTrack:t});if(S(e))return e;{const r=Tt();return Ut({id:r,canTrack:t}),r}},Tt=()=>Q(),Ut=({id:t,canTrack:e})=>U({name:Y,value:t,canTrack:e}),Z=()=>a()&&typeof localStorage!="undefined"?localStorage:void 0,Ot=({key:t,canTrack:e})=>{var r;try{return e?(r=Z())==null?void 0:r.getItem(t):void 0}catch(n){console.debug("[LocalStorage] GET error: ",n);return}},Pt=({key:t,canTrack:e,value:r})=>{var n;try{e&&((n=Z())==null||n.setItem(t,r))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Rt=({canTrack:t})=>{if(!t)return;const e=Ot({key:q,canTrack:t});if(S(e))return e;{const r=Ct();return Bt({id:r,canTrack:t}),r}},Ct=()=>Q(),Bt=({id:t,canTrack:e})=>Pt({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"&&f.log(t)}const _t=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await kt({canTrack:t}),r=Rt({canTrack:t});return{sessionId:e,visitorId:r}},xt=async({type:t,canTrack:e,apiKey:r,metadata:n,...s})=>({type:t,data:{...s,metadata:{url:location.href,...n},...await _t({canTrack:e}),userAttributes:J(),ownerId:r}});async function et({apiHost:t,...e}){if(!e.apiKey){f.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||$()||!(a()||b==="reactNative"))return;const n=`${t||"https://cdn.builder.io"}/api/v1/track`;return tt(n),fetch(n,{method:"POST",body:JSON.stringify({events:[await xt(e)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const Lt=t=>et({...t,canTrack:!0});function Nt(t){const e=t||(a()?window.location.search:void 0);return e?G(e).indexOf("builder.preview=")!==-1:!1}const Vt=t=>({type:"builder.registerComponent",data:O(t)}),Dt=t=>{const e=t.toString().trim(),r=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!r?"function ":""}${e}).apply(this, arguments)`};function O(t){return JSON.parse(JSON.stringify(t,(e,r)=>typeof r=="function"?Dt(r):r))}const N={};function Ft(t,e){t==="plugin"&&(e=O(e));let r=N[t];if(r||(r=N[t]=[]),r.push(e),a()){const n={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(n,"*"),parent!==window&&window.postMessage(n,"*")}catch(s){console.debug("Could not postmessage",s)}}}function Mt(t){var e;if(a()){const r=JSON.parse(JSON.stringify(t));t.action&&(r.action=t.action.toString()),(e=window.parent)==null||e.postMessage({type:"builder.registerAction",data:r},"*")}}const V={};function Kt(t){if(a()){Object.assign(V,t);const e={type:"builder.settingsChange",data:V};parent.postMessage(e,"*")}}const D="builder.",Wt="options.",P=t=>{if(!t)return{};const e=j(t),r={};return Object.keys(e).forEach(n=>{if(n.startsWith(D)){const s=n.replace(D,"").replace(Wt,"");r[s]=e[n]}}),r},jt=()=>{if(!a())return{};const t=new URLSearchParams(window.location.search);return P(t)},Gt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function rt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const r=new URL(e.origin),n=r.hostname;return(t||Gt).findIndex(s=>s.startsWith("*.")?n.endsWith(s.slice(1)):s===n)>-1}let F=!1;const nt=t=>{var e,r;F||(F=!0,a()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:b,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:t.modelName,apiKey:t.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(r=window.parent)==null||r.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",n=>{var o,i;if(!rt(t.trustedHosts,n))return;const{data:s}=n;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,l=s.data.arguments||[],y=s.data.id,m=new Function(u);let d,h=null;try{d=m.apply(null,l)}catch(p){h=p}h?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:y,error:h.message}},"*"):d&&typeof d.then=="function"?d.then(p=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:y,result:p}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:y}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:r})=>n=>{if(!rt(e,n))return;const{data:s}=n;if(s)switch(s.type){case"builder.configureSdk":{r.configureSdk(s.data);break}case"builder.triggerAnimation":{r.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state,l=o.editType;i===t&&u&&r.stateUpdate(u,l);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data,l=o.editType;i===t&&r.contentUpdate(u,l);break}}},$t=({model:t,apiKey:e,callback:r,trustedHosts:n})=>{if(!a)return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};nt({modelName:t,apiKey:e});const s=st({callbacks:{contentUpdate:r,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:t,trustedHosts:n});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Jt="builder.tests",R=t=>`${Jt}.${t}`,zt=({contentId:t})=>H({name:R(t),canTrack:!0}),Xt=({contentId:t})=>v({name:R(t),canTrack:!0}),Ht=({contentId:t,value:e})=>U({name:R(t),value:e,canTrack:!0}),ot=t=>S(t.id)&&S(t.variations)&&Object.keys(t.variations).length>0,Qt=({id:t,variations:e})=>{var s;let r=0;const n=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(r+=i,n<r)return o}return t},it=t=>{const e=Qt(t);return Ht({contentId:t.id,value:e}).catch(r=>{f.error("could not store A/B test variation: ",r)}),e},at=({item:t,testGroupId:e})=>{const r=t.variations[e];return e===t.id||!r?{testVariationId:t.id,testVariationName:"Default"}:{data:r.data,testVariationId:r.id,testVariationName:r.name||(r.id===t.id?"Default":"")}},Yt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const r=Xt({contentId:t.id})||it({variations:t.variations,id:t.id}),n=at({item:t,testGroupId:r});return{...t,...n}},Zt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const n=await zt({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:n});return{...t,...s}};const M="builder.userAttributes";function K(){let t=!0;const e=new Set;return{setUserAttributes(r){if(!a())return;const n={...this.getUserAttributes(),...r};U({name:M,value:JSON.stringify(n),canTrack:t}),e.forEach(s=>s(n))},getUserAttributes(){return a()?JSON.parse(v({name:M,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(r,{fireImmediately:n}={}){return e.add(r),n&&r(this.getUserAttributes()),function(){e.delete(r)}},setCanTrack(r){t=r}}}let k;a()&&b==="qwik"?(window.__BUILDER_USER_ATTRIBUTES_SERVICE__||(window.__BUILDER_USER_ATTRIBUTES_SERVICE__=K()),k=window.__BUILDER_USER_ATTRIBUTES_SERVICE__):k=K();const C=k,qt=t=>{C.setUserAttributes(t)},ct=t=>{const e=S(t)?t:!0;return C.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 re=ee();function T(t,e=null,r="."){return Object.keys(t).reduce((n,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(r);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...n,...T(o,i,r)}:{...n,[i]:o}},{})}function ut(t,e,r={}){for(const n in t){const s=t[n],o=e?e+"."+n:n;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,r):r[o]=s}return r}function ne(t){const e={};for(const r in t){const n=r.split(".");let s=e;for(let o=0;o<n.length;o++){const i=n[o];o===n.length-1?s[i]=t[r]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",W=t=>typeof t=="number"&&!isNaN(t)&&t>=0,B=t=>{const{limit:e=30,userAttributes:r,query:n,model:s,apiKey:o,enrich:i,locale:u,apiVersion:l=se,fields:y,omit:m,offset:d,cacheSeconds:h,staleCacheSeconds:p,sort:w,includeUnpublished:_,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(l))throw new Error(`Invalid apiVersion: expected 'v3', received '${l}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",c=new URL(`${pt}/api/${l}/content/${s}`);c.searchParams.set("apiKey",o),c.searchParams.set("limit",String(e)),c.searchParams.set("noTraverse",String(ht)),c.searchParams.set("includeRefs",String(!0)),u&&c.searchParams.set("locale",u);let I=r||{};if(i&&c.searchParams.set("enrich",String(i)),c.searchParams.set("omit",m!=null?m:"meta.componentsUsed"),y&&c.searchParams.set("fields",y),Number.isFinite(d)&&d>-1&&c.searchParams.set("offset",String(Math.floor(d))),typeof _=="boolean"&&c.searchParams.set("includeUnpublished",String(_)),h&&W(h)&&c.searchParams.set("cacheSeconds",String(h)),p&&W(p)&&c.searchParams.set("staleCacheSeconds",String(p)),w){const g=T({sort:w});for(const E in g)c.searchParams.set(E,JSON.stringify(g[E]))}const x={...jt(),...j(t.options||{})};I={...I,...ie(x)};const L=T(x);for(const g in L)c.searchParams.set(g,String(L[g]));if(Object.keys(I).length>0&&c.searchParams.set("userAttributes",JSON.stringify(I)),n){const g=ut({query:n});for(const E in g)c.searchParams.set(E,JSON.stringify(g[E]))}return c},oe=t=>{const e={};for(const r in t)r.startsWith("userAttributes.")&&(e[r]=t[r],delete t[r]);return e},ie=t=>{if(a()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=oe(t),{userAttributes:r}=ne(e);return r}return{}},ae=t=>"results"in t;async function lt(t){var n;const e=t.locale||((n=t.userAttributes)==null?void 0:n.locale);e&&(t.locale=e,t.userAttributes={locale:e,...t.userAttributes});const r=await ft({...t,limit:1});return r&&r[0]||null}const ce=async t=>{var i,u;const e=B(t),r=(i=t.fetch)!=null?i:re,n={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...X()}};return await(await r(e.href,n)).json()},dt=async(t,e,r=B(t))=>{const n=ct(t.canTrack);if(r.search.includes("preview="),!n||!(a()||b==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await Zt({item:o,canTrack:n}));e.results=s}catch(s){f.error("Could not process A/B tests. ",s)}return e.results};async function ft(t){const e=B(t),r=await ce(t);if(!ae(r))throw f.error("Error fetching data. ",{url:e,content:r,options:t}),r;return dt(t,r)}const ue=async t=>{var n,s,o;const e=t.path||((n=t.url)==null?void 0:n.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),r={...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:r.apiKey,model:r.model,content:await lt(r)}};exports.MSG_PREFIX=A;exports.TARGET=b;exports._processContentResult=dt;exports._track=et;exports.checkIsDefined=S;exports.createEditorListener=st;exports.createRegisterComponentMessage=Vt;exports.fetchBuilderProps=ue;exports.fetchEntries=ft;exports.fetchOneEntry=lt;exports.getBuilderSearchParams=P;exports.getCookieSync=v;exports.getDefaultCanTrack=ct;exports.getUserAttributes=J;exports.handleABTestingSync=Yt;exports.isBrowser=a;exports.isEditing=$;exports.isPreviewing=Nt;exports.logFetch=tt;exports.logger=f;exports.register=Ft;exports.registerAction=Mt;exports.serializeIncludingFunctions=O;exports.setClientUserAttributes=qt;exports.setEditorSettings=Kt;exports.setupBrowserForEditing=nt;exports.subscribeToEditor=$t;exports.track=Lt;exports.userAttributesService=C;
|
|
@@ -52,81 +52,11 @@ const ut = () => {
|
|
|
52
52
|
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
53
53
|
device: n ? "tablet" : e.any() ? "mobile" : "desktop"
|
|
54
54
|
};
|
|
55
|
-
},
|
|
56
|
-
function te(t) {
|
|
57
|
-
const e = t || (c() ? window.location.search : void 0);
|
|
58
|
-
return e ? M(e).indexOf("builder.preview=") !== -1 : !1;
|
|
59
|
-
}
|
|
60
|
-
const ee = (t) => ({
|
|
61
|
-
type: "builder.registerComponent",
|
|
62
|
-
data: W(t)
|
|
63
|
-
}), ft = (t) => {
|
|
64
|
-
const e = t.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(e);
|
|
65
|
-
return `return (${!e.startsWith("function") && !e.startsWith("async") && !e.startsWith("(") && !n ? "function " : ""}${e}).apply(this, arguments)`;
|
|
66
|
-
};
|
|
67
|
-
function W(t) {
|
|
68
|
-
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? ft(n) : n));
|
|
69
|
-
}
|
|
70
|
-
const x = {};
|
|
71
|
-
function ne(t, e) {
|
|
72
|
-
t === "plugin" && (e = W(e));
|
|
73
|
-
let n = x[t];
|
|
74
|
-
if (n || (n = x[t] = []), n.push(e), c()) {
|
|
75
|
-
const r = {
|
|
76
|
-
type: "builder.register",
|
|
77
|
-
data: {
|
|
78
|
-
type: t,
|
|
79
|
-
info: e
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
try {
|
|
83
|
-
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
84
|
-
} catch (s) {
|
|
85
|
-
console.debug("Could not postmessage", s);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function re(t) {
|
|
90
|
-
var e;
|
|
91
|
-
if (c()) {
|
|
92
|
-
const n = JSON.parse(JSON.stringify(t));
|
|
93
|
-
t.action && (n.action = t.action.toString()), (e = window.parent) == null || e.postMessage({
|
|
94
|
-
type: "builder.registerAction",
|
|
95
|
-
data: n
|
|
96
|
-
}, "*");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const _ = {};
|
|
100
|
-
function se(t) {
|
|
101
|
-
if (c()) {
|
|
102
|
-
Object.assign(_, t);
|
|
103
|
-
const e = {
|
|
104
|
-
type: "builder.settingsChange",
|
|
105
|
-
data: _
|
|
106
|
-
};
|
|
107
|
-
parent.postMessage(e, "*");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const L = "builder.", ht = "options.", j = (t) => {
|
|
111
|
-
if (!t)
|
|
112
|
-
return {};
|
|
113
|
-
const e = K(t), n = {};
|
|
114
|
-
return Object.keys(e).forEach((r) => {
|
|
115
|
-
if (r.startsWith(L)) {
|
|
116
|
-
const s = r.replace(L, "").replace(ht, "");
|
|
117
|
-
n[s] = e[r];
|
|
118
|
-
}
|
|
119
|
-
}), n;
|
|
120
|
-
}, gt = () => {
|
|
121
|
-
if (!c())
|
|
122
|
-
return {};
|
|
123
|
-
const t = new URLSearchParams(window.location.search);
|
|
124
|
-
return j(t);
|
|
125
|
-
}, $ = "5.1.0", G = () => ({
|
|
55
|
+
}, W = "5.1.1", j = () => ({
|
|
126
56
|
"X-Builder-SDK": b,
|
|
127
57
|
"X-Builder-SDK-GEN": "2",
|
|
128
|
-
"X-Builder-SDK-Version":
|
|
129
|
-
}),
|
|
58
|
+
"X-Builder-SDK-Version": W
|
|
59
|
+
}), y = (t) => t != null, ft = (t) => {
|
|
130
60
|
if (t === "localhost" || t === "127.0.0.1")
|
|
131
61
|
return t;
|
|
132
62
|
const e = t.split(".");
|
|
@@ -142,13 +72,13 @@ const L = "builder.", ht = "options.", j = (t) => {
|
|
|
142
72
|
h.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
143
73
|
return;
|
|
144
74
|
}
|
|
145
|
-
},
|
|
75
|
+
}, $ = async (t) => U(t), ht = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(y).join("; "), gt = [["secure", ""], ["SameSite", "None"]], pt = ({
|
|
146
76
|
name: t,
|
|
147
77
|
value: e,
|
|
148
78
|
expires: n
|
|
149
79
|
}) => {
|
|
150
|
-
const s = (c() ? location.protocol === "https:" : !0) ?
|
|
151
|
-
return
|
|
80
|
+
const s = (c() ? location.protocol === "https:" : !0) ? gt : [[]], o = n ? [["expires", n.toUTCString()]] : [[]], i = [[t, e], ...o, ["path", "/"], ["domain", ft(window.location.hostname)], ...s];
|
|
81
|
+
return ht(i);
|
|
152
82
|
}, T = async ({
|
|
153
83
|
name: t,
|
|
154
84
|
value: e,
|
|
@@ -158,7 +88,7 @@ const L = "builder.", ht = "options.", j = (t) => {
|
|
|
158
88
|
try {
|
|
159
89
|
if (!r)
|
|
160
90
|
return;
|
|
161
|
-
const s =
|
|
91
|
+
const s = pt({
|
|
162
92
|
name: t,
|
|
163
93
|
value: e,
|
|
164
94
|
expires: n
|
|
@@ -168,93 +98,93 @@ const L = "builder.", ht = "options.", j = (t) => {
|
|
|
168
98
|
h.warn("[COOKIE] SET error: ", (s == null ? void 0 : s.message) || s);
|
|
169
99
|
}
|
|
170
100
|
};
|
|
171
|
-
function
|
|
101
|
+
function St() {
|
|
172
102
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
173
103
|
const e = Math.random() * 16 | 0;
|
|
174
104
|
return (t == "x" ? e : e & 3 | 8).toString(16);
|
|
175
105
|
});
|
|
176
106
|
}
|
|
177
|
-
function
|
|
178
|
-
return
|
|
107
|
+
function G() {
|
|
108
|
+
return St().replace(/-/g, "");
|
|
179
109
|
}
|
|
180
|
-
const
|
|
110
|
+
const J = "builderSessionId", yt = async ({
|
|
181
111
|
canTrack: t
|
|
182
112
|
}) => {
|
|
183
113
|
if (!t)
|
|
184
114
|
return;
|
|
185
|
-
const e = await
|
|
186
|
-
name:
|
|
115
|
+
const e = await $({
|
|
116
|
+
name: J,
|
|
187
117
|
canTrack: t
|
|
188
118
|
});
|
|
189
119
|
if (y(e))
|
|
190
120
|
return e;
|
|
191
121
|
{
|
|
192
|
-
const n =
|
|
193
|
-
return
|
|
122
|
+
const n = bt();
|
|
123
|
+
return mt({
|
|
194
124
|
id: n,
|
|
195
125
|
canTrack: t
|
|
196
126
|
}), n;
|
|
197
127
|
}
|
|
198
|
-
},
|
|
128
|
+
}, bt = () => G(), mt = ({
|
|
199
129
|
id: t,
|
|
200
130
|
canTrack: e
|
|
201
131
|
}) => T({
|
|
202
|
-
name:
|
|
132
|
+
name: J,
|
|
203
133
|
value: t,
|
|
204
134
|
canTrack: e
|
|
205
|
-
}),
|
|
135
|
+
}), z = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, wt = ({
|
|
206
136
|
key: t,
|
|
207
137
|
canTrack: e
|
|
208
138
|
}) => {
|
|
209
139
|
var n;
|
|
210
140
|
try {
|
|
211
|
-
return e ? (n =
|
|
141
|
+
return e ? (n = z()) == null ? void 0 : n.getItem(t) : void 0;
|
|
212
142
|
} catch (r) {
|
|
213
143
|
console.debug("[LocalStorage] GET error: ", r);
|
|
214
144
|
return;
|
|
215
145
|
}
|
|
216
|
-
},
|
|
146
|
+
}, Et = ({
|
|
217
147
|
key: t,
|
|
218
148
|
canTrack: e,
|
|
219
149
|
value: n
|
|
220
150
|
}) => {
|
|
221
151
|
var r;
|
|
222
152
|
try {
|
|
223
|
-
e && ((r =
|
|
153
|
+
e && ((r = z()) == null || r.setItem(t, n));
|
|
224
154
|
} catch (s) {
|
|
225
155
|
console.debug("[LocalStorage] SET error: ", s);
|
|
226
156
|
}
|
|
227
|
-
},
|
|
157
|
+
}, X = "builderVisitorId", At = ({
|
|
228
158
|
canTrack: t
|
|
229
159
|
}) => {
|
|
230
160
|
if (!t)
|
|
231
161
|
return;
|
|
232
|
-
const e =
|
|
233
|
-
key:
|
|
162
|
+
const e = wt({
|
|
163
|
+
key: X,
|
|
234
164
|
canTrack: t
|
|
235
165
|
});
|
|
236
166
|
if (y(e))
|
|
237
167
|
return e;
|
|
238
168
|
{
|
|
239
|
-
const n =
|
|
240
|
-
return
|
|
169
|
+
const n = It();
|
|
170
|
+
return vt({
|
|
241
171
|
id: n,
|
|
242
172
|
canTrack: t
|
|
243
173
|
}), n;
|
|
244
174
|
}
|
|
245
|
-
},
|
|
175
|
+
}, It = () => G(), vt = ({
|
|
246
176
|
id: t,
|
|
247
177
|
canTrack: e
|
|
248
|
-
}) =>
|
|
249
|
-
key:
|
|
178
|
+
}) => Et({
|
|
179
|
+
key: X,
|
|
250
180
|
value: t,
|
|
251
181
|
canTrack: e
|
|
252
182
|
});
|
|
253
|
-
function
|
|
183
|
+
function kt(t) {
|
|
254
184
|
var e;
|
|
255
185
|
typeof process != "undefined" && ((e = process.env) != null && e.DEBUG) && String(process.env.DEBUG) == "true" && h.log(t);
|
|
256
186
|
}
|
|
257
|
-
const
|
|
187
|
+
const Ut = async ({
|
|
258
188
|
canTrack: t
|
|
259
189
|
}) => {
|
|
260
190
|
if (!t)
|
|
@@ -262,16 +192,16 @@ const Pt = async ({
|
|
|
262
192
|
visitorId: void 0,
|
|
263
193
|
sessionId: void 0
|
|
264
194
|
};
|
|
265
|
-
const e = await
|
|
195
|
+
const e = await yt({
|
|
266
196
|
canTrack: t
|
|
267
|
-
}), n =
|
|
197
|
+
}), n = At({
|
|
268
198
|
canTrack: t
|
|
269
199
|
});
|
|
270
200
|
return {
|
|
271
201
|
sessionId: e,
|
|
272
202
|
visitorId: n
|
|
273
203
|
};
|
|
274
|
-
},
|
|
204
|
+
}, Tt = async ({
|
|
275
205
|
type: t,
|
|
276
206
|
canTrack: e,
|
|
277
207
|
apiKey: n,
|
|
@@ -285,14 +215,14 @@ const Pt = async ({
|
|
|
285
215
|
url: location.href,
|
|
286
216
|
...r
|
|
287
217
|
},
|
|
288
|
-
...await
|
|
218
|
+
...await Ut({
|
|
289
219
|
canTrack: e
|
|
290
220
|
}),
|
|
291
221
|
userAttributes: dt(),
|
|
292
222
|
ownerId: n
|
|
293
223
|
}
|
|
294
224
|
});
|
|
295
|
-
async function
|
|
225
|
+
async function Ot({
|
|
296
226
|
apiHost: t,
|
|
297
227
|
...e
|
|
298
228
|
}) {
|
|
@@ -303,24 +233,94 @@ async function Ct({
|
|
|
303
233
|
if (!e.canTrack || ct() || !(c() || b === "reactNative"))
|
|
304
234
|
return;
|
|
305
235
|
const r = `${t || "https://cdn.builder.io"}/api/v1/track`;
|
|
306
|
-
return
|
|
236
|
+
return kt(r), fetch(r, {
|
|
307
237
|
method: "POST",
|
|
308
238
|
body: JSON.stringify({
|
|
309
|
-
events: [await
|
|
239
|
+
events: [await Tt(e)]
|
|
310
240
|
}),
|
|
311
241
|
headers: {
|
|
312
242
|
"content-type": "application/json",
|
|
313
|
-
...
|
|
243
|
+
...j()
|
|
314
244
|
},
|
|
315
245
|
mode: "cors"
|
|
316
246
|
}).catch((s) => {
|
|
317
247
|
console.error("Failed to track: ", s);
|
|
318
248
|
});
|
|
319
249
|
}
|
|
320
|
-
const
|
|
250
|
+
const te = (t) => Ot({
|
|
321
251
|
...t,
|
|
322
252
|
canTrack: !0
|
|
323
|
-
})
|
|
253
|
+
});
|
|
254
|
+
function ee(t) {
|
|
255
|
+
const e = t || (c() ? window.location.search : void 0);
|
|
256
|
+
return e ? M(e).indexOf("builder.preview=") !== -1 : !1;
|
|
257
|
+
}
|
|
258
|
+
const ne = (t) => ({
|
|
259
|
+
type: "builder.registerComponent",
|
|
260
|
+
data: H(t)
|
|
261
|
+
}), Pt = (t) => {
|
|
262
|
+
const e = t.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(e);
|
|
263
|
+
return `return (${!e.startsWith("function") && !e.startsWith("async") && !e.startsWith("(") && !n ? "function " : ""}${e}).apply(this, arguments)`;
|
|
264
|
+
};
|
|
265
|
+
function H(t) {
|
|
266
|
+
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? Pt(n) : n));
|
|
267
|
+
}
|
|
268
|
+
const x = {};
|
|
269
|
+
function re(t, e) {
|
|
270
|
+
t === "plugin" && (e = H(e));
|
|
271
|
+
let n = x[t];
|
|
272
|
+
if (n || (n = x[t] = []), n.push(e), c()) {
|
|
273
|
+
const r = {
|
|
274
|
+
type: "builder.register",
|
|
275
|
+
data: {
|
|
276
|
+
type: t,
|
|
277
|
+
info: e
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
try {
|
|
281
|
+
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
282
|
+
} catch (s) {
|
|
283
|
+
console.debug("Could not postmessage", s);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function se(t) {
|
|
288
|
+
var e;
|
|
289
|
+
if (c()) {
|
|
290
|
+
const n = JSON.parse(JSON.stringify(t));
|
|
291
|
+
t.action && (n.action = t.action.toString()), (e = window.parent) == null || e.postMessage({
|
|
292
|
+
type: "builder.registerAction",
|
|
293
|
+
data: n
|
|
294
|
+
}, "*");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const _ = {};
|
|
298
|
+
function oe(t) {
|
|
299
|
+
if (c()) {
|
|
300
|
+
Object.assign(_, t);
|
|
301
|
+
const e = {
|
|
302
|
+
type: "builder.settingsChange",
|
|
303
|
+
data: _
|
|
304
|
+
};
|
|
305
|
+
parent.postMessage(e, "*");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const L = "builder.", Rt = "options.", Q = (t) => {
|
|
309
|
+
if (!t)
|
|
310
|
+
return {};
|
|
311
|
+
const e = K(t), n = {};
|
|
312
|
+
return Object.keys(e).forEach((r) => {
|
|
313
|
+
if (r.startsWith(L)) {
|
|
314
|
+
const s = r.replace(L, "").replace(Rt, "");
|
|
315
|
+
n[s] = e[r];
|
|
316
|
+
}
|
|
317
|
+
}), n;
|
|
318
|
+
}, Ct = () => {
|
|
319
|
+
if (!c())
|
|
320
|
+
return {};
|
|
321
|
+
const t = new URLSearchParams(window.location.search);
|
|
322
|
+
return Q(t);
|
|
323
|
+
}, Bt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
324
324
|
function Y(t, e) {
|
|
325
325
|
if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
|
|
326
326
|
return !1;
|
|
@@ -334,7 +334,7 @@ const xt = (t) => {
|
|
|
334
334
|
type: "builder.sdkInfo",
|
|
335
335
|
data: {
|
|
336
336
|
target: b,
|
|
337
|
-
version:
|
|
337
|
+
version: W,
|
|
338
338
|
supportsPatchUpdates: !1,
|
|
339
339
|
// Supports builder-model="..." attribute which is needed to
|
|
340
340
|
// scope our '+ add block' button styling
|
|
@@ -455,7 +455,7 @@ const xt = (t) => {
|
|
|
455
455
|
};
|
|
456
456
|
}, Lt = "builder.tests", O = (t) => `${Lt}.${t}`, Nt = ({
|
|
457
457
|
contentId: t
|
|
458
|
-
}) =>
|
|
458
|
+
}) => $({
|
|
459
459
|
name: O(t),
|
|
460
460
|
canTrack: !0
|
|
461
461
|
}), Vt = ({
|
|
@@ -668,7 +668,7 @@ const Jt = "v3", F = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t)
|
|
|
668
668
|
a.searchParams.set(E, JSON.stringify(f[E]));
|
|
669
669
|
}
|
|
670
670
|
const C = {
|
|
671
|
-
...
|
|
671
|
+
...Ct(),
|
|
672
672
|
...K(t.options || {})
|
|
673
673
|
};
|
|
674
674
|
A = {
|
|
@@ -720,7 +720,7 @@ const Yt = async (t) => {
|
|
|
720
720
|
...t.fetchOptions,
|
|
721
721
|
headers: {
|
|
722
722
|
...(u = t.fetchOptions) == null ? void 0 : u.headers,
|
|
723
|
-
...
|
|
723
|
+
...j()
|
|
724
724
|
}
|
|
725
725
|
};
|
|
726
726
|
return await (await n(e.href, r)).json();
|
|
@@ -763,7 +763,7 @@ const ue = async (t) => {
|
|
|
763
763
|
urlPath: e
|
|
764
764
|
} : {}
|
|
765
765
|
},
|
|
766
|
-
options:
|
|
766
|
+
options: Q(t.searchParams || ((o = t.url) == null ? void 0 : o.searchParams) || t.options)
|
|
767
767
|
};
|
|
768
768
|
return {
|
|
769
769
|
apiKey: n.apiKey,
|
|
@@ -775,30 +775,30 @@ export {
|
|
|
775
775
|
I as MSG_PREFIX,
|
|
776
776
|
b as TARGET,
|
|
777
777
|
Zt as _processContentResult,
|
|
778
|
-
|
|
778
|
+
Ot as _track,
|
|
779
779
|
y as checkIsDefined,
|
|
780
780
|
_t as createEditorListener,
|
|
781
|
-
|
|
781
|
+
ne as createRegisterComponentMessage,
|
|
782
782
|
ue as fetchBuilderProps,
|
|
783
783
|
qt as fetchEntries,
|
|
784
784
|
Qt as fetchOneEntry,
|
|
785
|
-
|
|
785
|
+
Q as getBuilderSearchParams,
|
|
786
786
|
U as getCookieSync,
|
|
787
787
|
Mt as getDefaultCanTrack,
|
|
788
788
|
dt as getUserAttributes,
|
|
789
789
|
ae as handleABTestingSync,
|
|
790
790
|
c as isBrowser,
|
|
791
791
|
ct as isEditing,
|
|
792
|
-
|
|
793
|
-
|
|
792
|
+
ee as isPreviewing,
|
|
793
|
+
kt as logFetch,
|
|
794
794
|
h as logger,
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
795
|
+
re as register,
|
|
796
|
+
se as registerAction,
|
|
797
|
+
H as serializeIncludingFunctions,
|
|
798
798
|
ce as setClientUserAttributes,
|
|
799
|
-
|
|
799
|
+
oe as setEditorSettings,
|
|
800
800
|
xt as setupBrowserForEditing,
|
|
801
801
|
ie as subscribeToEditor,
|
|
802
|
-
|
|
802
|
+
te as track,
|
|
803
803
|
et as userAttributesService
|
|
804
804
|
};
|
|
@@ -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-2529c06e.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.registerAction=e.registerAction;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as i, fetchBuilderProps as s, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, registerAction as E, setEditorSettings as f, subscribeToEditor as h, track as p } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as i, fetchBuilderProps as s, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, registerAction as E, setEditorSettings as f, subscribeToEditor as h, track as p } from "./server-entry-fc7f08d8.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
i as createRegisterComponentMessage,
|