@builder.io/sdk-react 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/blocks-exports.cjs +1 -1
- package/lib/browser/blocks-exports.mjs +1 -1
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +1 -1
- package/lib/{node/server-entry-7304506e.cjs → browser/server-entry-6758904f.cjs} +1 -1
- package/lib/browser/{server-entry-288f3748.js → server-entry-b4e02b7f.js} +1 -1
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-807094e8.cjs → accordion-9d6ead4a.cjs} +1 -1
- package/lib/edge/{accordion-3cfa3eee.js → accordion-cc5e4262.js} +1 -1
- package/lib/edge/{blocks-54e76c48.js → blocks-28f8515f.js} +3 -3
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{blocks-ec210226.cjs → blocks-f9516def.cjs} +1 -1
- package/lib/edge/{button-0d89818e.js → button-5b479c4f.js} +2 -2
- package/lib/edge/{button-e3dbd868.cjs → button-d5d5a523.cjs} +1 -1
- package/lib/edge/{columns-f4875265.cjs → columns-52de76ba.cjs} +1 -1
- package/lib/edge/{columns-f9a7710d.js → columns-80468479.js} +4 -4
- package/lib/edge/{content-variants-8ab0c195.js → content-variants-4a3c14d6.js} +11 -11
- package/lib/edge/{content-variants-aadc6d6c.cjs → content-variants-ab7b16da.cjs} +1 -1
- package/lib/edge/{evaluate-1ef00edc.js → evaluate-9643776e.js} +1 -1
- package/lib/edge/{evaluate-4d70dcda.cjs → evaluate-b34c0621.cjs} +1 -1
- package/lib/edge/{form-8edb1a1e.cjs → form-2490bc65.cjs} +1 -1
- package/lib/edge/{form-0e3e79d5.js → form-8614781e.js} +4 -4
- package/lib/edge/{get-class-prop-name-f64b085a.cjs → get-class-prop-name-3fcaaa4e.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-c8375d5b.js → get-class-prop-name-982b0eeb.js} +1 -1
- package/lib/edge/{img-411548cf.js → img-2750ffb8.js} +1 -1
- package/lib/edge/{img-a63de542.cjs → img-5481830d.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +1 -1
- package/lib/edge/{input-59f88558.cjs → input-4018ed38.cjs} +1 -1
- package/lib/edge/{input-a31ad183.js → input-a53f13e5.js} +1 -1
- package/lib/edge/{select-bfc6e2dd.js → select-a9ba7290.js} +1 -1
- package/lib/edge/{select-31a4a930.cjs → select-b5257730.cjs} +1 -1
- package/lib/edge/{server-entry-899f7119.js → server-entry-425ab225.js} +1 -1
- package/lib/edge/{server-entry-f0b40e5b.cjs → server-entry-c0a129cd.cjs} +1 -1
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-634372d2.js → slot-2806840c.js} +4 -4
- package/lib/edge/{slot-c9228b15.cjs → slot-7c52b924.cjs} +1 -1
- package/lib/edge/{symbol-10d573de.cjs → symbol-2a759e66.cjs} +1 -1
- package/lib/edge/{symbol-32a5d0f7.js → symbol-f4a3bd00.js} +2 -2
- package/lib/edge/{tabs-52ed1067.js → tabs-1e5bb78c.js} +4 -4
- package/lib/edge/{tabs-71e3e002.cjs → tabs-238833b0.cjs} +1 -1
- package/lib/edge/{text-ea8a6161.js → text-4492d4a7.js} +2 -2
- package/lib/edge/{text-853d6ef4.cjs → text-95df08ad.cjs} +1 -1
- package/lib/node/blocks-exports.cjs +1 -1
- package/lib/node/blocks-exports.mjs +2 -2
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +2 -2
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +2 -2
- package/lib/node/{node-runtime-8348be9f.cjs → node-runtime-9a8c1fa3.cjs} +1 -1
- package/lib/node/{node-runtime-792d0497.js → node-runtime-e5a24b2b.js} +1 -1
- package/lib/{browser/server-entry-7304506e.cjs → node/server-entry-6758904f.cjs} +1 -1
- package/lib/node/{server-entry-288f3748.js → server-entry-b4e02b7f.js} +1 -1
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +4 -5
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/server-index.d.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const serverEntry=require("./server-entry-
|
|
1
|
+
"use strict";const serverEntry=require("./server-entry-6758904f.cjs"),getFunctionArguments=({builder:e,context:t,event:s,state:r})=>Object.entries({state:r,Builder:e,builder:e,context:t,event:s}),getBuilderGlobals=()=>({isEditing:serverEntry.isEditing(),isBrowser:serverEntry.isBrowser(),isServer:!serverEntry.isBrowser(),getUserAttributes:()=>serverEntry.getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e,SDK_NAME_FOR_TARGET=(()=>{switch(serverEntry.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return serverEntry.TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,s)=>{if(Object(e)!==e)return e;const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return r.slice(0,-1).reduce((n,o,i)=>Object(n[o])===n[o]?n[o]:n[o]=Math.abs(Number(r[i+1]))>>0===+r[i+1]?[]:{},e)[r[r.length-1]]=s,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=eval("require")}catch(e){}const getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-
|
|
1
|
+
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-b4e02b7f.js";
|
|
2
2
|
const getFunctionArguments = ({
|
|
3
3
|
builder: e,
|
|
4
4
|
context: t,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const I="react",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},M=e=>e instanceof URLSearchParams?ce(e):e,U=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ue(){return c()&&window.self!==window.top}function F(e){return ue()&&U(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const de=()=>{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},le=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=le(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=de();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function fe(e){const t=e||(c()?window.location.search:void 0);return t?U(t).indexOf("builder.preview=")!==-1:!1}const ge=e=>({type:"builder.registerComponent",data:k(e)}),he=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?he(n):n))}const x={};function D(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[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 R={};function pe(e){if(c()){Object.assign(R,e);const t={type:"builder.settingsChange",data:R};parent.postMessage(t,"*")}}const B="builder.",me="options.",P=e=>{if(!e)return{};const t=M(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(B)){const o=r.replace(B,"").replace(me,"");n[o]=t[r]}}),n},ye=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},Se=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},j=({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}},K=async e=>j(e),we=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),be=[["secure",""],["SameSite","None"]],Ie=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?be:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",Se(window.location.hostname)],...o];return we(a)},_=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=Ie({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ve(){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 W(){return ve().replace(/-/g,"")}const $="builderSessionId",Ee=async({canTrack:e})=>{if(!e)return;const t=await K({name:$,canTrack:e});if(p(t))return t;{const n=ke();return Pe({id:n,canTrack:e}),n}},ke=()=>W(),Pe=({id:e,canTrack:t})=>_({name:$,value:e,canTrack:t}),G=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Ce=({key:e,canTrack:t})=>{var n;try{return t?(n=G())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Oe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=G())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Ae=({canTrack:e})=>{if(!e)return;const t=Ce({key:z,canTrack:e});if(p(t))return t;{const n=Te();return xe({id:n,canTrack:e}),n}},Te=()=>W(),xe=({id:e,canTrack:t})=>Oe({key:z,value:e,canTrack:t}),Re=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ee({canTrack:e}),n=Ae({canTrack:e});return{sessionId:t,visitorId:n}},Be=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Re({canTrack:t}),userAttributes:N(),ownerId:n}});async function J(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!F()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Be(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const Le=e=>J({...e,canTrack:!0}),Ve=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function H(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Ve).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Me="2.0.
|
|
1
|
+
"use strict";const I="react",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},M=e=>e instanceof URLSearchParams?ce(e):e,U=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ue(){return c()&&window.self!==window.top}function F(e){return ue()&&U(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const de=()=>{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},le=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=le(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=de();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function fe(e){const t=e||(c()?window.location.search:void 0);return t?U(t).indexOf("builder.preview=")!==-1:!1}const ge=e=>({type:"builder.registerComponent",data:k(e)}),he=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?he(n):n))}const x={};function D(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[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 R={};function pe(e){if(c()){Object.assign(R,e);const t={type:"builder.settingsChange",data:R};parent.postMessage(t,"*")}}const B="builder.",me="options.",P=e=>{if(!e)return{};const t=M(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(B)){const o=r.replace(B,"").replace(me,"");n[o]=t[r]}}),n},ye=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},Se=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},j=({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}},K=async e=>j(e),we=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),be=[["secure",""],["SameSite","None"]],Ie=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?be:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",Se(window.location.hostname)],...o];return we(a)},_=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=Ie({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ve(){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 W(){return ve().replace(/-/g,"")}const $="builderSessionId",Ee=async({canTrack:e})=>{if(!e)return;const t=await K({name:$,canTrack:e});if(p(t))return t;{const n=ke();return Pe({id:n,canTrack:e}),n}},ke=()=>W(),Pe=({id:e,canTrack:t})=>_({name:$,value:e,canTrack:t}),G=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Ce=({key:e,canTrack:t})=>{var n;try{return t?(n=G())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Oe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=G())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Ae=({canTrack:e})=>{if(!e)return;const t=Ce({key:z,canTrack:e});if(p(t))return t;{const n=Te();return xe({id:n,canTrack:e}),n}},Te=()=>W(),xe=({id:e,canTrack:t})=>Oe({key:z,value:e,canTrack:t}),Re=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ee({canTrack:e}),n=Ae({canTrack:e});return{sessionId:t,visitorId:n}},Be=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Re({canTrack:t}),userAttributes:N(),ownerId:n}});async function J(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!F()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Be(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const Le=e=>J({...e,canTrack:!0}),Ve=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function H(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Ve).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Me="2.0.15",Ue=()=>{D("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 L=!1;const X=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:Me,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(!H(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,v=new Function(l);let u,g=null;try{u=v.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 S;(S=window.parent)==null||S.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}}})))},q=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!H(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}}},Fe=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};X();const r=q({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ne="builder.tests",C=e=>`${Ne}.${e}`,De=({contentId:e})=>K({name:C(e),canTrack:!0}),je=({contentId:e})=>j({name:C(e),canTrack:!0}),Ke=({contentId:e,value:t})=>_({name:C(e),value:t,canTrack:!0}),Q=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,_e=({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},Y=e=>{const t=_e(e);return Ke({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},Z=({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":"")}},We=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Q(e))return e;const n=je({contentId:e.id})||Y({variations:e.variations,id:e.id}),r=Z({item:e,testGroupId:n});return{...e,...r}},$e=async({item:e,canTrack:t})=>{if(!t||!Q(e))return e;const r=await De({contentId:e.id})||Y({variations:e.variations,id:e.id}),o=Z({item:e,testGroupId:r});return{...e,...o}},ee=e=>p(e)?e:!0;function Ge(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=Ge().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
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 te=ze();function E(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,...E(s,a,n)}:{...r,[a]:s}},{})}function ne(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(a=>a.startsWith("$"))?ne(o,s,n):n[s]=o}return n}const Je="v3",V=e=>typeof e=="number"&&!isNaN(e)&&e>=0,O=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Je,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:A}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ie=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(ie)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof A=="boolean"&&i.searchParams.set("includeUnpublished",String(A)),g&&V(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&V(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ae={...ye(),...M(e.options||{})},T=E(ae);for(const f in T)i.searchParams.set(f,String(T[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=ne({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},He=e=>"results"in e;async function re(e){const t=await se({...e,limit:1});return t&&t[0]||null}const Xe=async e=>{var s;const t=O(e);return await(await((s=e.fetch)!=null?s:te)(t.href,e.fetchOptions)).json()},oe=async(e,t,n=O(e))=>{const r=ee(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await $e({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function se(e){try{const t=O(e),n=await Xe(e);return He(n)?oe(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}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:P(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await re(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=oe;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=q;exports.createRegisterComponentMessage=ge;exports.fetch=te;exports.fetchBuilderProps=qe;exports.fetchEntries=se;exports.fetchOneEntry=re;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ee;exports.getUserAttributes=N;exports.handleABTestingSync=We;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=fe;exports.logger=d;exports.register=D;exports.registerInsertMenu=Ue;exports.serializeIncludingFunctions=k;exports.setEditorSettings=pe;exports.setupBrowserForEditing=X;exports.subscribeToEditor=Fe;exports.track=Le;
|
|
@@ -302,7 +302,7 @@ function $(t, e) {
|
|
|
302
302
|
const n = new URL(e.origin), r = n.hostname;
|
|
303
303
|
return (t || kt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
304
304
|
}
|
|
305
|
-
const Et = "2.0.
|
|
305
|
+
const Et = "2.0.15", zt = () => {
|
|
306
306
|
ot("insertMenu", {
|
|
307
307
|
name: "_default",
|
|
308
308
|
default: !0,
|
|
@@ -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-6758904f.cjs");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-b4e02b7f.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
s 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": "2.0.
|
|
4
|
+
"version": "2.0.15",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
"types": "./types/index.d.ts",
|
|
78
78
|
"import": "./lib/browser/index.mjs",
|
|
79
79
|
"require": "./lib/browser/index.cjs"
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
|
+
"types": "./types/index.d.ts"
|
|
81
82
|
},
|
|
82
83
|
"./node/init": {
|
|
83
84
|
"types": "./types/functions/evaluate/node-runtime/init.d.ts",
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
"release": "npm publish",
|
|
110
111
|
"build-inline-fns": "yarn g:build-inline-fns",
|
|
111
112
|
"types": "tsc",
|
|
112
|
-
"build": "nx run-many -p @builder.io/sdk-react -t types build:node build:edge build:browser",
|
|
113
|
+
"build": "yarn g:nx run-many -p @builder.io/sdk-react -t types build:node build:edge build:browser",
|
|
113
114
|
"build:node": "SDK_ENV=node vite build --mode lib",
|
|
114
115
|
"build:edge": "SDK_ENV=edge vite build --mode lib",
|
|
115
116
|
"build:browser": "SDK_ENV=browser vite build --mode lib"
|
|
@@ -123,8 +124,6 @@
|
|
|
123
124
|
"devDependencies": {
|
|
124
125
|
"@builder.io/sdks": "workspace:*",
|
|
125
126
|
"@vitejs/plugin-react": "^4.0.4",
|
|
126
|
-
"nx": "^19.6.5",
|
|
127
|
-
"nx-cloud": "^19.0.0",
|
|
128
127
|
"react": "^18.2.0",
|
|
129
128
|
"recast": "^0.23.4",
|
|
130
129
|
"typescript": "^4.9.4",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.15";
|
package/types/server-index.d.ts
CHANGED
|
@@ -37,3 +37,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor';
|
|
|
37
37
|
*/
|
|
38
38
|
export { fetchBuilderProps } from './functions/fetch-builder-props';
|
|
39
39
|
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index';
|
|
40
|
+
export type { GetContentOptions } from './functions/get-content/types';
|