@builder.io/sdk-react-nextjs 0.16.18 → 0.16.19
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/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +107 -105
- package/lib/browser/components/content/content.cjs +1 -1
- package/lib/browser/components/content/content.mjs +23 -21
- package/lib/browser/components/content-variants/content-variants.cjs +1 -1
- package/lib/browser/components/content-variants/content-variants.mjs +10 -8
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +24 -23
- package/lib/browser/functions/track/index.cjs +1 -1
- package/lib/browser/functions/track/index.mjs +21 -19
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +107 -105
- package/lib/edge/components/content/content.cjs +1 -1
- package/lib/edge/components/content/content.mjs +23 -21
- package/lib/edge/components/content-variants/content-variants.cjs +1 -1
- package/lib/edge/components/content-variants/content-variants.mjs +10 -8
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +24 -23
- package/lib/edge/functions/track/index.cjs +1 -1
- package/lib/edge/functions/track/index.mjs +21 -19
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +107 -105
- package/lib/node/components/content/content.cjs +1 -1
- package/lib/node/components/content/content.mjs +23 -21
- package/lib/node/components/content-variants/content-variants.cjs +1 -1
- package/lib/node/components/content-variants/content-variants.mjs +10 -8
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +24 -23
- package/lib/node/functions/track/index.cjs +1 -1
- package/lib/node/functions/track/index.mjs +21 -19
- package/package.json +1 -1
- package/types/cjs/components/content/components/enable-editor.d.ts +1 -1
- package/types/cjs/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/get-content/types.d.ts +4 -0
- package/types/cjs/functions/track/index.d.ts +3 -1
- package/types/esm/components/content/components/enable-editor.d.ts +1 -1
- package/types/esm/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/get-content/types.d.ts +4 -0
- package/types/esm/functions/track/index.d.ts +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { flatten as g, flattenMongoQuery as
|
|
2
|
-
import { normalizeSearchParams as
|
|
3
|
-
import { DEFAULT_API_VERSION as
|
|
4
|
-
import { getBuilderSearchParamsFromWindow as
|
|
5
|
-
const y = (
|
|
1
|
+
import { flatten as g, flattenMongoQuery as O } from "../../helpers/flatten.mjs";
|
|
2
|
+
import { normalizeSearchParams as k } from "../../helpers/search/search.mjs";
|
|
3
|
+
import { DEFAULT_API_VERSION as E } from "../../types/api-version.mjs";
|
|
4
|
+
import { getBuilderSearchParamsFromWindow as I } from "../get-builder-search-params/index.mjs";
|
|
5
|
+
const y = (r) => typeof r == "number" && !isNaN(r) && r >= 0, M = (r) => {
|
|
6
6
|
const {
|
|
7
7
|
limit: c = 30,
|
|
8
8
|
userAttributes: m,
|
|
@@ -11,42 +11,43 @@ const y = (s) => typeof s == "number" && !isNaN(s) && s >= 0, J = (s) => {
|
|
|
11
11
|
apiKey: l,
|
|
12
12
|
enrich: h,
|
|
13
13
|
locale: d,
|
|
14
|
-
apiVersion: a =
|
|
14
|
+
apiVersion: a = E,
|
|
15
15
|
fields: u,
|
|
16
16
|
omit: N,
|
|
17
17
|
offset: i,
|
|
18
18
|
cacheSeconds: n,
|
|
19
19
|
staleCacheSeconds: o,
|
|
20
20
|
sort: P,
|
|
21
|
-
includeUnpublished:
|
|
22
|
-
|
|
21
|
+
includeUnpublished: p,
|
|
22
|
+
apiHost: v
|
|
23
|
+
} = r;
|
|
23
24
|
if (!l)
|
|
24
25
|
throw new Error("Missing API key");
|
|
25
26
|
if (!["v3"].includes(a))
|
|
26
27
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`);
|
|
27
|
-
const
|
|
28
|
-
if (e.searchParams.set("apiKey", l), e.searchParams.set("limit", String(c)), e.searchParams.set("noTraverse", String(
|
|
29
|
-
const
|
|
28
|
+
const U = c !== 1, w = v || "https://cdn.builder.io", e = new URL(`${w}/api/${a}/content/${b}`);
|
|
29
|
+
if (e.searchParams.set("apiKey", l), e.searchParams.set("limit", String(c)), e.searchParams.set("noTraverse", String(U)), e.searchParams.set("includeRefs", String(!0)), d && e.searchParams.set("locale", d), h && e.searchParams.set("enrich", String(h)), e.searchParams.set("omit", N || "meta.componentsUsed"), u && e.searchParams.set("fields", u), Number.isFinite(i) && i > -1 && e.searchParams.set("offset", String(Math.floor(i))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), n && y(n) && e.searchParams.set("cacheSeconds", String(n)), o && y(o) && e.searchParams.set("staleCacheSeconds", String(o)), P) {
|
|
30
|
+
const s = g({
|
|
30
31
|
sort: P
|
|
31
32
|
});
|
|
32
|
-
for (const t in
|
|
33
|
-
e.searchParams.set(t, JSON.stringify(
|
|
33
|
+
for (const t in s)
|
|
34
|
+
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
-
},
|
|
39
|
-
for (const
|
|
40
|
-
e.searchParams.set(
|
|
36
|
+
const A = {
|
|
37
|
+
...I(),
|
|
38
|
+
...k(r.options || {})
|
|
39
|
+
}, S = g(A);
|
|
40
|
+
for (const s in S)
|
|
41
|
+
e.searchParams.set(s, String(S[s]));
|
|
41
42
|
if (m && e.searchParams.set("userAttributes", JSON.stringify(m)), f) {
|
|
42
|
-
const
|
|
43
|
+
const s = O({
|
|
43
44
|
query: f
|
|
44
45
|
});
|
|
45
|
-
for (const t in
|
|
46
|
-
e.searchParams.set(t, JSON.stringify(
|
|
46
|
+
for (const t in s)
|
|
47
|
+
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
47
48
|
}
|
|
48
49
|
return e;
|
|
49
50
|
};
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
+
M as generateContentUrl
|
|
52
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),g=require("../is-browser.cjs"),l=require("../is-editing.cjs"),y=require("./helpers.cjs"),I=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await d.getSessionId({canTrack:e}),r=u.getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},k=async({type:e,canTrack:t,apiKey:r,metadata:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),g=require("../is-browser.cjs"),l=require("../is-editing.cjs"),y=require("./helpers.cjs"),I=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await d.getSessionId({canTrack:e}),r=u.getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},k=async({type:e,canTrack:t,apiKey:r,metadata:i,...o})=>({type:e,data:{...o,metadata:{url:location.href,...i},...await I({canTrack:t}),userAttributes:y.getUserAttributes(),ownerId:r}});async function s({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||l.isEditing()||!(g.isBrowser()||n.TARGET==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await k(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const f=e=>s({...e,canTrack:!0});exports._track=s;exports.track=f;
|
|
@@ -23,7 +23,7 @@ const u = async ({
|
|
|
23
23
|
sessionId: r,
|
|
24
24
|
visitorId: e
|
|
25
25
|
};
|
|
26
|
-
},
|
|
26
|
+
}, l = async ({
|
|
27
27
|
type: t,
|
|
28
28
|
canTrack: r,
|
|
29
29
|
apiKey: e,
|
|
@@ -44,31 +44,33 @@ const u = async ({
|
|
|
44
44
|
ownerId: e
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
async function
|
|
48
|
-
|
|
47
|
+
async function y({
|
|
48
|
+
apiHost: t,
|
|
49
|
+
...r
|
|
50
|
+
}) {
|
|
51
|
+
if (!r.apiKey) {
|
|
49
52
|
s.error("Missing API key for track call. Please provide your API key.");
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
55
|
+
return !r.canTrack || f() || !(m() || a === "reactNative") ? void 0 : fetch(`${t || "https://cdn.builder.io"}/api/v1/track`, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
events: [await l(r)]
|
|
59
|
+
}),
|
|
60
|
+
headers: {
|
|
61
|
+
"content-type": "application/json",
|
|
62
|
+
...n()
|
|
63
|
+
},
|
|
64
|
+
mode: "cors"
|
|
65
|
+
}).catch((o) => {
|
|
66
|
+
console.error("Failed to track: ", o);
|
|
67
|
+
});
|
|
66
68
|
}
|
|
67
|
-
const E = (t) =>
|
|
69
|
+
const E = (t) => y({
|
|
68
70
|
...t,
|
|
69
71
|
canTrack: !0
|
|
70
72
|
});
|
|
71
73
|
export {
|
|
72
|
-
|
|
74
|
+
y as _track,
|
|
73
75
|
E as track
|
|
74
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const k=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use client";"use strict";const k=require("react/jsx-runtime"),o=require("react"),N=require("../../../context/builder.context.cjs"),W=require("../../../functions/evaluate/evaluate.cjs"),A=require("../../../functions/fast-clone.cjs"),B=require("../../../functions/get-content/index.cjs"),R=require("../../../functions/is-browser.cjs"),g=require("../../../functions/is-editing.cjs"),D=require("../../../functions/is-previewing.cjs"),U=require("../../../functions/register-component.cjs"),P=require("../../../functions/track/index.cjs"),O=require("../../../functions/track/interaction.cjs"),y=require("../../../helpers/canTrack.cjs"),F=require("../../../helpers/preview-lru-cache/set.cjs"),$=require("../../../helpers/subscribe-to-editor.cjs"),H=require("../../../scripts/init-editing.cjs"),z=require("../../block/animator.cjs"),G=require("./styles.helpers.cjs"),J=require("next/navigation");function Q(e){var q,w,I;const d=o.useRef(null);function f(n){var a,i;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(i=(a=e.builderContextSignal).rootSetState)==null||i.call(a,t):e.builderContextSignal.rootState=t}function b(n){var a,i,r,c,u;const t={...e.builderContextSignal.content,...n,data:{...(a=e.builderContextSignal.content)==null?void 0:a.data,...n==null?void 0:n.data},meta:{...(i=e.builderContextSignal.content)==null?void 0:i.meta,...n==null?void 0:n.meta,breakpoints:((r=n==null?void 0:n.meta)==null?void 0:r.breakpoints)||((u=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:u.breakpoints)}};F.postPreviewContent({value:t,key:t.id}).then(()=>{V.refresh()})}function L(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[K,X]=o.useState(()=>e.contentWrapper||"div");function S(n){return $.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var r;const{breakpoints:a,contentId:i}=t;!i||i!==((r=e.builderContextSignal.content)==null?void 0:r.id)||a&&b({meta:{breakpoints:a}})},animation:t=>{z.triggerAnimation(t)},contentUpdate:t=>{b(t)}}})(n)}const[v,Y]=o.useState(()=>({})),[m,Z]=o.useState(()=>({})),[h,T]=o.useState(()=>!1);function _(n){var t,a;if(e.builderContextSignal.content){const i=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,r=(a=e.builderContextSignal.content)==null?void 0:a.id;P._track({apiHost:e.apiHost,type:"click",canTrack:y.getDefaultCanTrack(e.canTrack),contentId:r,apiKey:e.apiKey,variationId:i!==r?i:void 0,...O.getInteractionPropertiesForEvent(n),unique:!h})}h||T(!0)}function j(){var t,a,i;const n=(i=(a=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:a.httpRequests)!=null?i:{};Object.entries(n).forEach(([r,c])=>{if(!c||m[r]||v[r]&&!g.isEditing())return;m[r]=!0;const u=c.replace(/{{([^}]+)}}/g,(s,M)=>String(W.evaluate({code:M,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));fetch(u).then(s=>s.json()).then(s=>{f({[r]:s}),v[r]=!0}).catch(s=>{console.error("error fetching dynamic data",c,s)}).finally(()=>{m[r]=!1})})}function l(){g.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:A.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){window.addEventListener("message",S),H.registerInsertMenu(),H.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(t=>{var i;const a=U.createRegisterComponentMessage(t);(i=window.parent)==null||i.postMessage(a,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",l)}function x(n){const t=new URL(location.href).searchParams,a=t.get("builder.preview"),i=t.get(`builder.overrides.${a}`),r=t.get("apiKey")||t.get("builder.space");a===e.model&&r===e.apiKey&&(!e.content||i===e.content.id)&&B.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(c=>{c&&b(c)})}const V=J.useRouter(),C=o.useRef(!1);return C.current||(j(),l(),C.current=!0),o.useEffect(()=>{var n;return(n=d.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=d.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=d.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=d.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(R.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&d.current&&d.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&y.getDefaultCanTrack(e.canTrack)){const i=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,r=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;P._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:r,apiKey:c,variationId:i!==r?i:void 0})}D.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{l()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&f(e.data)},[e.data]),o.useEffect(()=>{e.locale&&f({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{R.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",l))},[]),k.jsx(N.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?k.jsx(K,{ref:d,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:G.getWrapperClassName(((w=e.content)==null?void 0:w.testVariationId)||((I=e.content)==null?void 0:I.id)),...L(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Q;
|
|
@@ -1,132 +1,133 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as R } from "react/jsx-runtime";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
3
|
+
import { useRef as H, useState as m, useEffect as c } from "react";
|
|
4
|
+
import A from "../../../context/builder.context.mjs";
|
|
5
5
|
import { evaluate as U } from "../../../functions/evaluate/evaluate.mjs";
|
|
6
6
|
import { fastClone as _ } from "../../../functions/fast-clone.mjs";
|
|
7
7
|
import { fetchOneEntry as D } from "../../../functions/get-content/index.mjs";
|
|
8
|
-
import { isBrowser as
|
|
8
|
+
import { isBrowser as L } from "../../../functions/is-browser.mjs";
|
|
9
9
|
import { isEditing as f } from "../../../functions/is-editing.mjs";
|
|
10
10
|
import { isPreviewing as O } from "../../../functions/is-previewing.mjs";
|
|
11
11
|
import { createRegisterComponentMessage as B } from "../../../functions/register-component.mjs";
|
|
12
|
-
import { _track as
|
|
12
|
+
import { _track as y } from "../../../functions/track/index.mjs";
|
|
13
13
|
import { getInteractionPropertiesForEvent as F } from "../../../functions/track/interaction.mjs";
|
|
14
|
-
import { getDefaultCanTrack as
|
|
14
|
+
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
15
15
|
import { postPreviewContent as z } from "../../../helpers/preview-lru-cache/set.mjs";
|
|
16
16
|
import { createEditorListener as $ } from "../../../helpers/subscribe-to-editor.mjs";
|
|
17
17
|
import { registerInsertMenu as G, setupBrowserForEditing as J } from "../../../scripts/init-editing.mjs";
|
|
18
18
|
import { triggerAnimation as Q } from "../../block/animator.mjs";
|
|
19
19
|
import { getWrapperClassName as X } from "./styles.helpers.mjs";
|
|
20
20
|
import { useRouter as Y } from "next/navigation";
|
|
21
|
-
function
|
|
21
|
+
function Ct(t) {
|
|
22
22
|
var w, k, P;
|
|
23
|
-
const d =
|
|
23
|
+
const d = H(null);
|
|
24
24
|
function g(n) {
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
...
|
|
25
|
+
var a, i;
|
|
26
|
+
const e = {
|
|
27
|
+
...t.builderContextSignal.rootState,
|
|
28
28
|
...n
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
t.builderContextSignal.rootSetState ? (i = (a = t.builderContextSignal).rootSetState) == null || i.call(a, e) : t.builderContextSignal.rootState = e;
|
|
31
31
|
}
|
|
32
32
|
function b(n) {
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
...
|
|
33
|
+
var a, i, r, o, s;
|
|
34
|
+
const e = {
|
|
35
|
+
...t.builderContextSignal.content,
|
|
36
36
|
...n,
|
|
37
37
|
data: {
|
|
38
|
-
...(
|
|
38
|
+
...(a = t.builderContextSignal.content) == null ? void 0 : a.data,
|
|
39
39
|
...n == null ? void 0 : n.data
|
|
40
40
|
},
|
|
41
41
|
meta: {
|
|
42
|
-
...(i =
|
|
42
|
+
...(i = t.builderContextSignal.content) == null ? void 0 : i.meta,
|
|
43
43
|
...n == null ? void 0 : n.meta,
|
|
44
|
-
breakpoints: ((
|
|
44
|
+
breakpoints: ((r = n == null ? void 0 : n.meta) == null ? void 0 : r.breakpoints) || ((s = (o = t.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : s.breakpoints)
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
z({
|
|
48
|
-
value:
|
|
49
|
-
key:
|
|
48
|
+
value: e,
|
|
49
|
+
key: e.id
|
|
50
50
|
}).then(() => {
|
|
51
|
-
|
|
51
|
+
W.refresh();
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
function q() {
|
|
55
|
+
return t.showContent ? {} : {
|
|
56
56
|
hidden: !0,
|
|
57
57
|
"aria-hidden": !0
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
const [T, Z] = m(
|
|
61
|
-
() =>
|
|
61
|
+
() => t.contentWrapper || "div"
|
|
62
62
|
);
|
|
63
63
|
function v(n) {
|
|
64
64
|
return $({
|
|
65
|
-
model:
|
|
66
|
-
trustedHosts:
|
|
65
|
+
model: t.model,
|
|
66
|
+
trustedHosts: t.trustedHosts,
|
|
67
67
|
callbacks: {
|
|
68
|
-
configureSdk: (
|
|
69
|
-
var
|
|
70
|
-
const { breakpoints:
|
|
71
|
-
!i || i !== ((
|
|
68
|
+
configureSdk: (e) => {
|
|
69
|
+
var r;
|
|
70
|
+
const { breakpoints: a, contentId: i } = e;
|
|
71
|
+
!i || i !== ((r = t.builderContextSignal.content) == null ? void 0 : r.id) || a && b({
|
|
72
72
|
meta: {
|
|
73
|
-
breakpoints:
|
|
73
|
+
breakpoints: a
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
},
|
|
77
|
-
animation: (
|
|
78
|
-
Q(
|
|
77
|
+
animation: (e) => {
|
|
78
|
+
Q(e);
|
|
79
79
|
},
|
|
80
|
-
contentUpdate: (
|
|
81
|
-
b(
|
|
80
|
+
contentUpdate: (e) => {
|
|
81
|
+
b(e);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
})(n);
|
|
85
85
|
}
|
|
86
|
-
const [h, p] = m(() => ({})), [S,
|
|
86
|
+
const [h, p] = m(() => ({})), [S, tt] = m(() => ({})), [x, V] = m(() => !1);
|
|
87
87
|
function M(n) {
|
|
88
|
-
var
|
|
89
|
-
if (
|
|
90
|
-
const i = (
|
|
91
|
-
|
|
88
|
+
var e, a;
|
|
89
|
+
if (t.builderContextSignal.content) {
|
|
90
|
+
const i = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId, r = (a = t.builderContextSignal.content) == null ? void 0 : a.id;
|
|
91
|
+
y({
|
|
92
|
+
apiHost: t.apiHost,
|
|
92
93
|
type: "click",
|
|
93
|
-
canTrack:
|
|
94
|
-
contentId:
|
|
95
|
-
apiKey:
|
|
96
|
-
variationId: i !==
|
|
94
|
+
canTrack: K(t.canTrack),
|
|
95
|
+
contentId: r,
|
|
96
|
+
apiKey: t.apiKey,
|
|
97
|
+
variationId: i !== r ? i : void 0,
|
|
97
98
|
...F(n),
|
|
98
99
|
unique: !x
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
x || V(!0);
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
-
var
|
|
105
|
-
const n = (i = (
|
|
106
|
-
Object.entries(n).forEach(([
|
|
107
|
-
if (!o || S[
|
|
104
|
+
function N() {
|
|
105
|
+
var e, a, i;
|
|
106
|
+
const n = (i = (a = (e = t.builderContextSignal.content) == null ? void 0 : e.data) == null ? void 0 : a.httpRequests) != null ? i : {};
|
|
107
|
+
Object.entries(n).forEach(([r, o]) => {
|
|
108
|
+
if (!o || S[r] || h[r] && !f())
|
|
108
109
|
return;
|
|
109
|
-
S[
|
|
110
|
+
S[r] = !0;
|
|
110
111
|
const s = o.replace(
|
|
111
112
|
/{{([^}]+)}}/g,
|
|
112
|
-
(l,
|
|
113
|
+
(l, j) => String(
|
|
113
114
|
U({
|
|
114
|
-
code:
|
|
115
|
-
context:
|
|
115
|
+
code: j,
|
|
116
|
+
context: t.context || {},
|
|
116
117
|
localState: void 0,
|
|
117
|
-
rootState:
|
|
118
|
-
rootSetState:
|
|
118
|
+
rootState: t.builderContextSignal.rootState,
|
|
119
|
+
rootSetState: t.builderContextSignal.rootSetState
|
|
119
120
|
})
|
|
120
121
|
)
|
|
121
122
|
);
|
|
122
123
|
fetch(s).then((l) => l.json()).then((l) => {
|
|
123
124
|
g({
|
|
124
|
-
[
|
|
125
|
-
}), h[
|
|
125
|
+
[r]: l
|
|
126
|
+
}), h[r] = !0;
|
|
126
127
|
}).catch((l) => {
|
|
127
128
|
console.error("error fetching dynamic data", o, l);
|
|
128
129
|
}).finally(() => {
|
|
129
|
-
S[
|
|
130
|
+
S[r] = !1;
|
|
130
131
|
});
|
|
131
132
|
});
|
|
132
133
|
}
|
|
@@ -136,9 +137,9 @@ function Ce(e) {
|
|
|
136
137
|
"builder:component:stateChange",
|
|
137
138
|
{
|
|
138
139
|
detail: {
|
|
139
|
-
state: _(
|
|
140
|
+
state: _(t.builderContextSignal.rootState),
|
|
140
141
|
ref: {
|
|
141
|
-
name:
|
|
142
|
+
name: t.model
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
}
|
|
@@ -147,47 +148,47 @@ function Ce(e) {
|
|
|
147
148
|
}
|
|
148
149
|
function C(n) {
|
|
149
150
|
window.addEventListener("message", v), G(), J({
|
|
150
|
-
...
|
|
151
|
-
locale:
|
|
151
|
+
...t.locale ? {
|
|
152
|
+
locale: t.locale
|
|
152
153
|
} : {},
|
|
153
|
-
...
|
|
154
|
-
enrich:
|
|
154
|
+
...t.enrich ? {
|
|
155
|
+
enrich: t.enrich
|
|
155
156
|
} : {},
|
|
156
|
-
...
|
|
157
|
-
trustedHosts:
|
|
157
|
+
...t.trustedHosts ? {
|
|
158
|
+
trustedHosts: t.trustedHosts
|
|
158
159
|
} : {}
|
|
159
160
|
}), Object.values(
|
|
160
|
-
|
|
161
|
-
).forEach((
|
|
161
|
+
t.builderContextSignal.componentInfos
|
|
162
|
+
).forEach((e) => {
|
|
162
163
|
var i;
|
|
163
|
-
const
|
|
164
|
-
(i = window.parent) == null || i.postMessage(
|
|
164
|
+
const a = B(e);
|
|
165
|
+
(i = window.parent) == null || i.postMessage(a, "*");
|
|
165
166
|
}), window.addEventListener(
|
|
166
167
|
"builder:component:stateChangeListenerActivated",
|
|
167
168
|
u
|
|
168
169
|
);
|
|
169
170
|
}
|
|
170
171
|
function E(n) {
|
|
171
|
-
const
|
|
172
|
-
`builder.overrides.${
|
|
173
|
-
),
|
|
174
|
-
|
|
175
|
-
model:
|
|
176
|
-
apiKey:
|
|
177
|
-
apiVersion:
|
|
172
|
+
const e = new URL(location.href).searchParams, a = e.get("builder.preview"), i = e.get(
|
|
173
|
+
`builder.overrides.${a}`
|
|
174
|
+
), r = e.get("apiKey") || e.get("builder.space");
|
|
175
|
+
a === t.model && r === t.apiKey && (!t.content || i === t.content.id) && D({
|
|
176
|
+
model: t.model,
|
|
177
|
+
apiKey: t.apiKey,
|
|
178
|
+
apiVersion: t.builderContextSignal.apiVersion
|
|
178
179
|
}).then((o) => {
|
|
179
180
|
o && b(o);
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
|
-
const
|
|
183
|
-
return I.current || (
|
|
183
|
+
const W = Y(), I = H(!1);
|
|
184
|
+
return I.current || (N(), u(), I.current = !0), c(() => {
|
|
184
185
|
var n;
|
|
185
186
|
return (n = d.current) == null || n.addEventListener(
|
|
186
187
|
"initeditingbldr",
|
|
187
188
|
C
|
|
188
189
|
), () => {
|
|
189
|
-
var
|
|
190
|
-
return (
|
|
190
|
+
var e;
|
|
191
|
+
return (e = d.current) == null ? void 0 : e.removeEventListener(
|
|
191
192
|
"initeditingbldr",
|
|
192
193
|
C
|
|
193
194
|
);
|
|
@@ -198,57 +199,58 @@ function Ce(e) {
|
|
|
198
199
|
"initpreviewingbldr",
|
|
199
200
|
E
|
|
200
201
|
), () => {
|
|
201
|
-
var
|
|
202
|
-
return (
|
|
202
|
+
var e;
|
|
203
|
+
return (e = d.current) == null ? void 0 : e.removeEventListener(
|
|
203
204
|
"initpreviewingbldr",
|
|
204
205
|
E
|
|
205
206
|
);
|
|
206
207
|
};
|
|
207
208
|
}, []), c(() => {
|
|
208
|
-
var n,
|
|
209
|
-
if (
|
|
210
|
-
if (f() && d.current && d.current.dispatchEvent(new CustomEvent("initeditingbldr")),
|
|
211
|
-
const i = (n =
|
|
212
|
-
|
|
209
|
+
var n, e;
|
|
210
|
+
if (L()) {
|
|
211
|
+
if (f() && !t.isNestedRender && d.current && d.current.dispatchEvent(new CustomEvent("initeditingbldr")), t.builderContextSignal.content && K(t.canTrack)) {
|
|
212
|
+
const i = (n = t.builderContextSignal.content) == null ? void 0 : n.testVariationId, r = (e = t.builderContextSignal.content) == null ? void 0 : e.id, o = t.apiKey;
|
|
213
|
+
y({
|
|
214
|
+
apiHost: t.apiHost,
|
|
213
215
|
type: "impression",
|
|
214
216
|
canTrack: !0,
|
|
215
|
-
contentId:
|
|
217
|
+
contentId: r,
|
|
216
218
|
apiKey: o,
|
|
217
|
-
variationId: i !==
|
|
219
|
+
variationId: i !== r ? i : void 0
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
O() && f();
|
|
221
223
|
}
|
|
222
224
|
}, []), c(() => {
|
|
223
|
-
}, [
|
|
225
|
+
}, [t.content]), c(() => {
|
|
224
226
|
u();
|
|
225
|
-
}, [
|
|
226
|
-
|
|
227
|
-
}, [
|
|
228
|
-
|
|
229
|
-
locale:
|
|
227
|
+
}, [t.builderContextSignal.rootState]), c(() => {
|
|
228
|
+
t.data && g(t.data);
|
|
229
|
+
}, [t.data]), c(() => {
|
|
230
|
+
t.locale && g({
|
|
231
|
+
locale: t.locale
|
|
230
232
|
});
|
|
231
|
-
}, [
|
|
232
|
-
|
|
233
|
+
}, [t.locale]), c(() => () => {
|
|
234
|
+
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
233
235
|
"builder:component:stateChangeListenerActivated",
|
|
234
236
|
u
|
|
235
237
|
));
|
|
236
|
-
}, []), /* @__PURE__ */ R(
|
|
238
|
+
}, []), /* @__PURE__ */ R(A.Provider, { value: t.builderContextSignal, children: t.builderContextSignal.content ? /* @__PURE__ */ R(
|
|
237
239
|
T,
|
|
238
240
|
{
|
|
239
241
|
ref: d,
|
|
240
242
|
onClick: (n) => M(n),
|
|
241
|
-
"builder-content-id": (w =
|
|
242
|
-
"builder-model":
|
|
243
|
+
"builder-content-id": (w = t.builderContextSignal.content) == null ? void 0 : w.id,
|
|
244
|
+
"builder-model": t.model,
|
|
243
245
|
className: X(
|
|
244
|
-
((k =
|
|
246
|
+
((k = t.content) == null ? void 0 : k.testVariationId) || ((P = t.content) == null ? void 0 : P.id)
|
|
245
247
|
),
|
|
246
|
-
...
|
|
247
|
-
...
|
|
248
|
-
children:
|
|
248
|
+
...q(),
|
|
249
|
+
...t.contentWrapperProps,
|
|
250
|
+
children: t.children
|
|
249
251
|
}
|
|
250
252
|
) : null });
|
|
251
253
|
}
|
|
252
254
|
export {
|
|
253
|
-
|
|
255
|
+
Ct as default
|
|
254
256
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),y=require("../../constants/builder-registered-components.cjs"),R=require("../../functions/evaluate/evaluate.cjs"),f=require("../../functions/register-component.cjs"),W=require("../../helpers/logger.cjs"),j=require("../blocks/blocks.cjs"),P=require("../content-variants/helpers.cjs"),V=require("../inlined-script.cjs"),K=require("./components/enable-editor.cjs"),T=require("./components/styles.cjs"),q=require("./content.helpers.cjs");function N(e){var a,r,s,l,d,u,g,C,S,m,k,x,b;const v=P.getUpdateVariantVisibilityScript({variationId:(a=e.content)==null?void 0:a.testVariationId,contentId:(r=e.content)==null?void 0:r.id}),I=[...y.getDefaultRegisteredComponents(),...((s=e.customComponents)==null?void 0:s.filter(({models:t})=>!(t!=null&&t.length)||!e.model?!0:t.includes(e.model)))||[]].reduce((t,{component:h,...o})=>({...t,[o.name]:{component:h,...f.serializeIncludingFunctions(o)}}),{}),n={content:q.getContentInitialValue({content:e.content,data:e.data}),localState:void 0,rootState:q.getRootStateInitialValue({content:e.content,data:e.data,locale:e.locale}),rootSetState:void 0,context:e.context||{},canTrack:e.canTrack,apiKey:e.apiKey,apiVersion:e.apiVersion,componentInfos:[...y.getDefaultRegisteredComponents(),...((l=e.customComponents)==null?void 0:l.filter(({models:t})=>!(t!=null&&t.length)||!e.model?!0:t.includes(e.model)))||[]].reduce((t,{component:h,...o})=>({...t,[o.name]:f.serializeIncludingFunctions(o)}),{}),inheritedStyles:{},BlocksWrapper:e.blocksWrapper||"div",BlocksWrapperProps:e.blocksWrapperProps||{},nonce:e.nonce||""};e.apiKey||W.logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");const c=(u=(d=n.content)==null?void 0:d.data)==null?void 0:u.jsCode;return c&&R.evaluate({code:c,context:e.context||{},localState:void 0,rootState:n.rootState,rootSetState:t=>{n.rootState=t},isExpression:!1}),i.jsxs(K,{apiHost:e.apiHost,nonce:e.nonce,content:e.content,data:e.data,model:e.model,context:e.context,apiKey:e.apiKey,canTrack:e.canTrack,locale:e.locale,enrich:e.enrich,showContent:e.showContent,builderContextSignal:n,contentWrapper:e.contentWrapper,contentWrapperProps:e.contentWrapperProps,trustedHosts:e.trustedHosts,isNestedRender:e.isNestedRender,children:[e.isSsrAbTest?i.jsx(V,{id:"builderio-variant-visibility",scriptStr:v,nonce:e.nonce||""}):null,i.jsx(T,{nonce:e.nonce||"",isNestedRender:e.isNestedRender,contentId:(g=n.content)==null?void 0:g.id,cssCode:(S=(C=n.content)==null?void 0:C.data)==null?void 0:S.cssCode,customFonts:(k=(m=n.content)==null?void 0:m.data)==null?void 0:k.customFonts}),i.jsx(j,{blocks:(b=(x=n.content)==null?void 0:x.data)==null?void 0:b.blocks,context:n,registeredComponents:I,linkComponent:e.linkComponent})]})}module.exports=N;
|