@builder.io/sdk-react 0.6.3 → 0.7.0
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/index.cjs +22 -22
- package/lib/browser/index.mjs +398 -400
- package/lib/{node/server-entry-f7504f89.mjs → browser/server-entry-f341a184.mjs} +33 -30
- package/lib/browser/{server-entry-2e639417.js → server-entry-f668f903.js} +1 -1
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/index.cjs +25 -25
- package/lib/edge/index.mjs +1080 -1082
- package/lib/{browser/server-entry-f7504f89.mjs → edge/server-entry-f341a184.mjs} +33 -30
- package/lib/{node/server-entry-2e639417.js → edge/server-entry-f668f903.js} +1 -1
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/node/index.cjs +22 -22
- package/lib/node/index.mjs +398 -400
- package/lib/{edge/server-entry-f7504f89.mjs → node/server-entry-f341a184.mjs} +33 -30
- package/lib/{edge/server-entry-2e639417.js → node/server-entry-f668f903.js} +1 -1
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +2 -1
- package/types/constants/sdk-version.d.ts +1 -1
|
@@ -45,7 +45,7 @@ const G = () => {
|
|
|
45
45
|
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
46
46
|
device: n ? "tablet" : e.any() ? "mobile" : "desktop"
|
|
47
47
|
};
|
|
48
|
-
}, u = (t) => t != null,
|
|
48
|
+
}, u = (t) => t != null, Tt = [], Pt = (t) => ({
|
|
49
49
|
type: "builder.registerComponent",
|
|
50
50
|
data: q(t)
|
|
51
51
|
}), z = (t) => {
|
|
@@ -87,14 +87,14 @@ const Q = Y(), Z = (t) => {
|
|
|
87
87
|
c.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
},
|
|
90
|
+
}, T = async (t) => A(t), tt = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(u).join("; "), et = [["secure", ""], ["SameSite", "None"]], nt = ({
|
|
91
91
|
name: t,
|
|
92
92
|
value: e,
|
|
93
93
|
expires: n
|
|
94
94
|
}) => {
|
|
95
95
|
const o = (i() ? location.protocol === "https:" : !0) ? et : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", Z(window.location.hostname)], ...o];
|
|
96
96
|
return tt(a);
|
|
97
|
-
},
|
|
97
|
+
}, P = async ({
|
|
98
98
|
name: t,
|
|
99
99
|
value: e,
|
|
100
100
|
expires: n,
|
|
@@ -127,7 +127,7 @@ const V = "builderSessionId", ot = async ({
|
|
|
127
127
|
}) => {
|
|
128
128
|
if (!t)
|
|
129
129
|
return;
|
|
130
|
-
const e = await
|
|
130
|
+
const e = await T({
|
|
131
131
|
name: V,
|
|
132
132
|
canTrack: t
|
|
133
133
|
});
|
|
@@ -143,7 +143,7 @@ const V = "builderSessionId", ot = async ({
|
|
|
143
143
|
}, st = () => R(), it = ({
|
|
144
144
|
id: t,
|
|
145
145
|
canTrack: e
|
|
146
|
-
}) =>
|
|
146
|
+
}) => P({
|
|
147
147
|
name: V,
|
|
148
148
|
value: t,
|
|
149
149
|
canTrack: e
|
|
@@ -274,7 +274,7 @@ function Vt(t, e) {
|
|
|
274
274
|
}
|
|
275
275
|
const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
|
|
276
276
|
contentId: t
|
|
277
|
-
}) =>
|
|
277
|
+
}) => T({
|
|
278
278
|
name: m(t),
|
|
279
279
|
canTrack: !0
|
|
280
280
|
}), mt = ({
|
|
@@ -285,11 +285,11 @@ const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
|
|
|
285
285
|
}), wt = ({
|
|
286
286
|
contentId: t,
|
|
287
287
|
value: e
|
|
288
|
-
}) =>
|
|
288
|
+
}) => P({
|
|
289
289
|
name: m(t),
|
|
290
290
|
value: e,
|
|
291
291
|
canTrack: !0
|
|
292
|
-
}), $ = (t) => u(t.id) && u(t.variations) && Object.keys(t.variations).length > 0,
|
|
292
|
+
}), $ = (t) => u(t.id) && u(t.variations) && Object.keys(t.variations).length > 0, vt = ({
|
|
293
293
|
id: t,
|
|
294
294
|
variations: e
|
|
295
295
|
}) => {
|
|
@@ -303,7 +303,7 @@ const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
|
|
|
303
303
|
}
|
|
304
304
|
return t;
|
|
305
305
|
}, j = (t) => {
|
|
306
|
-
const e =
|
|
306
|
+
const e = vt(t);
|
|
307
307
|
return wt({
|
|
308
308
|
contentId: t.id,
|
|
309
309
|
value: e
|
|
@@ -347,7 +347,7 @@ const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
|
|
|
347
347
|
...t,
|
|
348
348
|
...r
|
|
349
349
|
};
|
|
350
|
-
},
|
|
350
|
+
}, It = async ({
|
|
351
351
|
item: t,
|
|
352
352
|
canTrack: e
|
|
353
353
|
}) => {
|
|
@@ -366,7 +366,7 @@ const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
|
|
|
366
366
|
...t,
|
|
367
367
|
...o
|
|
368
368
|
};
|
|
369
|
-
},
|
|
369
|
+
}, St = (t) => u(t) ? t : !0;
|
|
370
370
|
function p(t, e = null, n = ".") {
|
|
371
371
|
return Object.keys(t).reduce((r, o) => {
|
|
372
372
|
const s = t[o], a = [e, o].filter(Boolean).join(n);
|
|
@@ -400,31 +400,34 @@ const k = "builder.", bt = "options.", Ot = (t) => {
|
|
|
400
400
|
const t = new URLSearchParams(window.location.search);
|
|
401
401
|
return K(t);
|
|
402
402
|
}, N = (t) => t instanceof URLSearchParams ? Ot(t) : t, Et = "v3", w = (t) => {
|
|
403
|
+
let {
|
|
404
|
+
noTraverse: e = !1
|
|
405
|
+
} = t;
|
|
403
406
|
const {
|
|
404
|
-
limit:
|
|
405
|
-
userAttributes:
|
|
406
|
-
query:
|
|
407
|
-
noTraverse: o = !1,
|
|
407
|
+
limit: n = 30,
|
|
408
|
+
userAttributes: r,
|
|
409
|
+
query: o,
|
|
408
410
|
model: s,
|
|
409
411
|
apiKey: a,
|
|
410
412
|
includeRefs: h = !0,
|
|
411
|
-
enrich:
|
|
412
|
-
locale:
|
|
413
|
+
enrich: v,
|
|
414
|
+
locale: I,
|
|
413
415
|
apiVersion: g = Et
|
|
414
416
|
} = t;
|
|
415
417
|
if (!a)
|
|
416
418
|
throw new Error("Missing API key");
|
|
417
419
|
if (!["v2", "v3"].includes(g))
|
|
418
420
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${g}'`);
|
|
419
|
-
|
|
421
|
+
(t.limit === void 0 || t.limit > 1) && !("noTraverse" in t) && (e = !0);
|
|
422
|
+
const d = new URL(`https://cdn.builder.io/api/${g}/content/${s}?apiKey=${a}&limit=${n}&noTraverse=${e}&includeRefs=${h}${I ? `&locale=${I}` : ""}${v ? `&enrich=${v}` : ""}`), U = {
|
|
420
423
|
...kt(),
|
|
421
424
|
...N(t.options || {})
|
|
422
|
-
},
|
|
423
|
-
for (const l in
|
|
424
|
-
d.searchParams.set(l, String(
|
|
425
|
-
if (
|
|
425
|
+
}, S = p(U);
|
|
426
|
+
for (const l in S)
|
|
427
|
+
d.searchParams.set(l, String(S[l]));
|
|
428
|
+
if (r && d.searchParams.set("userAttributes", JSON.stringify(r)), o) {
|
|
426
429
|
const l = p({
|
|
427
|
-
query:
|
|
430
|
+
query: o
|
|
428
431
|
});
|
|
429
432
|
for (const b in l)
|
|
430
433
|
d.searchParams.set(b, JSON.stringify(l[b]));
|
|
@@ -442,13 +445,13 @@ const Lt = M, xt = async (t) => {
|
|
|
442
445
|
const e = w(t);
|
|
443
446
|
return await (await Q(e.href)).json();
|
|
444
447
|
}, At = async (t, e, n = w(t)) => {
|
|
445
|
-
const r =
|
|
448
|
+
const r = St(t.canTrack);
|
|
446
449
|
if (n.search.includes("preview="), !r || !(i() || y === "reactNative"))
|
|
447
450
|
return e;
|
|
448
451
|
try {
|
|
449
452
|
const o = [];
|
|
450
453
|
for (const s of e.results)
|
|
451
|
-
o.push(await
|
|
454
|
+
o.push(await It({
|
|
452
455
|
item: s,
|
|
453
456
|
canTrack: r
|
|
454
457
|
}));
|
|
@@ -510,7 +513,7 @@ export {
|
|
|
510
513
|
At as _,
|
|
511
514
|
jt as a,
|
|
512
515
|
M as b,
|
|
513
|
-
|
|
516
|
+
Pt as c,
|
|
514
517
|
Lt as d,
|
|
515
518
|
K as e,
|
|
516
519
|
D as f,
|
|
@@ -523,12 +526,12 @@ export {
|
|
|
523
526
|
J as m,
|
|
524
527
|
u as n,
|
|
525
528
|
gt as o,
|
|
526
|
-
|
|
527
|
-
|
|
529
|
+
St as p,
|
|
530
|
+
Q as q,
|
|
528
531
|
Vt as r,
|
|
529
532
|
Ft as s,
|
|
530
533
|
Rt as t,
|
|
531
|
-
|
|
532
|
-
|
|
534
|
+
Tt as u,
|
|
535
|
+
q as v,
|
|
533
536
|
Bt as w
|
|
534
537
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";const m=t=>JSON.parse(JSON.stringify(t)),g="react",f="[Builder.io]: ",c={log:(...t)=>console.log(f,...t),error:(...t)=>console.error(f,...t),warn:(...t)=>console.warn(f,...t),debug:(...t)=>console.debug(f,...t)};function s(){return typeof window<"u"&&typeof document<"u"}function q(){return s()&&window.self!==window.top}function w(){return q()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const H=()=>{if(s()){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},Y=()=>typeof navigator=="object"&&navigator.userAgent||"",R=()=>{const t=Y(),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()||g==="reactNative"}},n=t.match(/Tablet|iPad/i),r=H();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},u=t=>t!=null,Q=[],Z=t=>({type:"builder.registerComponent",data:B(t)}),tt=t=>{const e=t.toString().trim();return`return (${!e.startsWith("function")&&!e.startsWith("(")?"function ":""}${e}).apply(this, arguments)`},et=t=>typeof t=="function"?tt(t):m(t),B=({inputs:t,...e})=>({...m(e),inputs:t==null?void 0:t.map(n=>Object.entries(n).reduce((r,[o,i])=>({...r,[o]:et(i)}),{}))});function nt(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:globalThis}function rt(){const t=nt().fetch;if(typeof t>"u")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 V=rt(),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},L=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){c.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},$=async t=>L(t),it=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(u).join("; "),st=[["secure",""],["SameSite","None"]],at=({name:t,value:e,expires:n})=>{const o=(s()?location.protocol==="https:":!0)?st:[[]],i=n?[["expires",n.toUTCString()]]:[[]],a=[[t,e],...i,["path","/"],["domain",ot(window.location.hostname)],...o];return it(a)},j=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const o=at({name:t,value:e,expires:n});document.cookie=o}catch(o){c.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ct(){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 D(){return ct().replace(/-/g,"")}const F="builderSessionId",ut=async({canTrack:t})=>{if(!t)return;const e=await $({name:F,canTrack:t});if(u(e))return e;{const n=lt();return dt({id:n,canTrack:t}),n}},lt=()=>D(),dt=({id:t,canTrack:e})=>j({name:F,value:t,canTrack:e}),K=()=>s()&&typeof localStorage<"u"?localStorage:void 0,ft=({key:t,canTrack:e})=>{var n;try{return e?(n=K())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},gt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=K())==null||r.setItem(t,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},M="builderVisitorId",ht=({canTrack:t})=>{if(!t)return;const e=ft({key:M,canTrack:t});if(u(e))return e;{const n=pt();return yt({id:n,canTrack:t}),n}},pt=()=>D(),yt=({id:t,canTrack:e})=>gt({key:M,value:t,canTrack:e}),mt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await ut({canTrack:t}),n=ht({canTrack:t});return{sessionId:e,visitorId:n}},wt=async({type:t,canTrack:e,apiKey:n,metadata:r,...o})=>({type:t,data:{...o,metadata:{url:location.href,...r},...await mt({canTrack:e}),userAttributes:R(),ownerId:n}});async function N(t){if(!t.apiKey){c.error("Missing API key for track call. Please provide your API key.");return}if(t.canTrack&&!w()&&(s()||g==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await wt(t)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(e=>{console.error("Failed to track: ",e)})}const St=t=>N({...t,canTrack:!0}),x={};function It(t,e){let n=x[t];if(n||(n=x[t]=[]),n.push(e),s()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const vt="builder.tests",S=t=>`${vt}.${t}`,bt=({contentId:t})=>$({name:S(t),canTrack:!0}),Ct=({contentId:t})=>L({name:S(t),canTrack:!0}),Et=({contentId:t,value:e})=>j({name:S(t),value:e,canTrack:!0}),U=t=>u(t.id)&&u(t.variations)&&Object.keys(t.variations).length>0,kt=({id:t,variations:e})=>{var o;let n=0;const r=Math.random();for(const i in e){const a=(o=e[i])==null?void 0:o.testRatio;if(n+=a,r<n)return i}return t},_=t=>{const e=kt(t);return Et({contentId:t.id,value:e}).catch(n=>{c.error("could not store A/B test variation: ",n)}),e},G=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Ot=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!U(t))return t;const n=Ct({contentId:t.id})||_({variations:t.variations,id:t.id}),r=G({item:t,testGroupId:n});return{...t,...r}},At=async({item:t,canTrack:e})=>{if(!e||!U(t))return t;const r=await bt({contentId:t.id})||_({variations:t.variations,id:t.id}),o=G({item:t,testGroupId:r});return{...t,...o}},W=t=>u(t)?t:!0;function y(t,e=null,n="."){return Object.keys(t).reduce((r,o)=>{const i=t[o],a=[e,o].filter(Boolean).join(n);return[typeof i=="object",i!==null,!(Array.isArray(i)&&i.length===0)].every(Boolean)?{...r,...y(i,a,n)}:{...r,[a]:i}},{})}const
|
|
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 V=rt(),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},L=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){c.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},$=async t=>L(t),it=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(u).join("; "),st=[["secure",""],["SameSite","None"]],at=({name:t,value:e,expires:n})=>{const o=(s()?location.protocol==="https:":!0)?st:[[]],i=n?[["expires",n.toUTCString()]]:[[]],a=[[t,e],...i,["path","/"],["domain",ot(window.location.hostname)],...o];return it(a)},j=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const o=at({name:t,value:e,expires:n});document.cookie=o}catch(o){c.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ct(){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 D(){return ct().replace(/-/g,"")}const F="builderSessionId",ut=async({canTrack:t})=>{if(!t)return;const e=await $({name:F,canTrack:t});if(u(e))return e;{const n=lt();return dt({id:n,canTrack:t}),n}},lt=()=>D(),dt=({id:t,canTrack:e})=>j({name:F,value:t,canTrack:e}),K=()=>s()&&typeof localStorage<"u"?localStorage:void 0,ft=({key:t,canTrack:e})=>{var n;try{return e?(n=K())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},gt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=K())==null||r.setItem(t,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},M="builderVisitorId",ht=({canTrack:t})=>{if(!t)return;const e=ft({key:M,canTrack:t});if(u(e))return e;{const n=pt();return yt({id:n,canTrack:t}),n}},pt=()=>D(),yt=({id:t,canTrack:e})=>gt({key:M,value:t,canTrack:e}),mt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await ut({canTrack:t}),n=ht({canTrack:t});return{sessionId:e,visitorId:n}},wt=async({type:t,canTrack:e,apiKey:n,metadata:r,...o})=>({type:t,data:{...o,metadata:{url:location.href,...r},...await mt({canTrack:e}),userAttributes:R(),ownerId:n}});async function N(t){if(!t.apiKey){c.error("Missing API key for track call. Please provide your API key.");return}if(t.canTrack&&!w()&&(s()||g==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await wt(t)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(e=>{console.error("Failed to track: ",e)})}const St=t=>N({...t,canTrack:!0}),x={};function It(t,e){let n=x[t];if(n||(n=x[t]=[]),n.push(e),s()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const vt="builder.tests",S=t=>`${vt}.${t}`,bt=({contentId:t})=>$({name:S(t),canTrack:!0}),Ct=({contentId:t})=>L({name:S(t),canTrack:!0}),Et=({contentId:t,value:e})=>j({name:S(t),value:e,canTrack:!0}),U=t=>u(t.id)&&u(t.variations)&&Object.keys(t.variations).length>0,kt=({id:t,variations:e})=>{var o;let n=0;const r=Math.random();for(const i in e){const a=(o=e[i])==null?void 0:o.testRatio;if(n+=a,r<n)return i}return t},_=t=>{const e=kt(t);return Et({contentId:t.id,value:e}).catch(n=>{c.error("could not store A/B test variation: ",n)}),e},G=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Ot=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!U(t))return t;const n=Ct({contentId:t.id})||_({variations:t.variations,id:t.id}),r=G({item:t,testGroupId:n});return{...t,...r}},At=async({item:t,canTrack:e})=>{if(!e||!U(t))return t;const r=await bt({contentId:t.id})||_({variations:t.variations,id:t.id}),o=G({item:t,testGroupId:r});return{...t,...o}},W=t=>u(t)?t:!0;function y(t,e=null,n="."){return Object.keys(t).reduce((r,o)=>{const i=t[o],a=[e,o].filter(Boolean).join(n);return[typeof i=="object",i!==null,!(Array.isArray(i)&&i.length===0)].every(Boolean)?{...r,...y(i,a,n)}:{...r,[a]:i}},{})}const T="builder.",xt="options.",Tt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},I=t=>{if(!t)return{};const e=z(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(T)){const o=r.replace(T,"").replace(xt,"");n[o]=e[r]}}),n},Pt=()=>{if(!s())return{};const t=new URLSearchParams(window.location.search);return I(t)},z=t=>t instanceof URLSearchParams?Tt(t):t,Rt="v3",v=t=>{let{noTraverse:e=!1}=t;const{limit:n=30,userAttributes:r,query:o,model:i,apiKey:a,includeRefs:h=!0,enrich:E,locale:k,apiVersion:p=Rt}=t;if(!a)throw new Error("Missing API key");if(!["v2","v3"].includes(p))throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${p}'`);(t.limit===void 0||t.limit>1)&&!("noTraverse"in t)&&(e=!0);const d=new URL(`https://cdn.builder.io/api/${p}/content/${i}?apiKey=${a}&limit=${n}&noTraverse=${e}&includeRefs=${h}${k?`&locale=${k}`:""}${E?`&enrich=${E}`:""}`),X={...Pt(),...z(t.options||{})},O=y(X);for(const l in O)d.searchParams.set(l,String(O[l]));if(r&&d.searchParams.set("userAttributes",JSON.stringify(r)),o){const l=y({query:o});for(const A in l)d.searchParams.set(A,JSON.stringify(l[A]))}return d},Bt=t=>"results"in t;async function b(t){const e=await C({...t,limit:1});return e&&e.results[0]||null}const Vt=b,Lt=async t=>{const e=v(t);return await(await V(e.href)).json()},J=async(t,e,n=v(t))=>{const r=W(t.canTrack);if(n.search.includes("preview="),!r||!(s()||g==="reactNative"))return e;try{const o=[];for(const i of e.results)o.push(await At({item:i,canTrack:r}));e.results=o}catch(o){c.error("Could not process A/B tests. ",o)}return e};async function C(t){try{const e=v(t),n=await Lt(t);return Bt(n)?J(t,n):(c.error("Error fetching data. ",{url:e,content:n,options:t}),null)}catch(e){return c.error("Error fetching data. ",e),null}}const $t=C;function jt(){return!s()||w()?!1:location.search.indexOf("builder.preview=")!==-1}const P={};function Dt(t){if(s()){Object.assign(P,t);const e={type:"builder.settingsChange",data:P};parent.postMessage(e,"*")}}const Ft=async t=>{var r,o,i;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((o=t.userAttributes)==null?void 0:o.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:I(t.searchParams||((i=t.url)==null?void 0:i.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await b(n)}};exports.TARGET=g;exports._processContentResult=J;exports._track=N;exports.checkIsDefined=u;exports.components=Q;exports.createRegisterComponentMessage=Z;exports.fastClone=m;exports.fetch=V;exports.fetchBuilderProps=Ft;exports.fetchEntries=C;exports.fetchOneEntry=b;exports.getAllContent=$t;exports.getBuilderSearchParams=I;exports.getContent=Vt;exports.getDefaultCanTrack=W;exports.getUserAttributes=R;exports.handleABTestingSync=Ot;exports.isBrowser=s;exports.isEditing=w;exports.isPreviewing=jt;exports.logger=c;exports.register=It;exports.serializeComponentInfo=B;exports.setEditorSettings=Dt;exports.track=St;
|
|
@@ -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-f668f903.js");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as t, c as a, h as r, f as i, b as n, g, e as o, d as c, i as d, a as f, r as h, s as l, t as p } from "./server-entry-
|
|
1
|
+
import { _ as t, c as a, h as r, f as i, b as n, g, e as o, d as c, i as d, a as f, r as h, s as l, t as p } from "./server-entry-f341a184.mjs";
|
|
2
2
|
export {
|
|
3
3
|
t as _processContentResult,
|
|
4
4
|
a as createRegisterComponentMessage,
|