@builder.io/sdk-react-nextjs 0.16.19 → 0.16.23
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/columns/columns.cjs +3 -3
- package/lib/browser/blocks/columns/columns.mjs +42 -34
- package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/browser/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +58 -57
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.mjs +16 -14
- package/lib/browser/functions/log-fetch.cjs +1 -0
- package/lib/browser/functions/log-fetch.mjs +8 -0
- package/lib/browser/functions/track/index.cjs +1 -1
- package/lib/browser/functions/track/index.mjs +18 -14
- package/lib/edge/blocks/columns/columns.cjs +3 -3
- package/lib/edge/blocks/columns/columns.mjs +42 -34
- package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/edge/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +58 -57
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.mjs +16 -14
- package/lib/edge/functions/log-fetch.cjs +1 -0
- package/lib/edge/functions/log-fetch.mjs +8 -0
- package/lib/edge/functions/track/index.cjs +1 -1
- package/lib/edge/functions/track/index.mjs +18 -14
- package/lib/node/blocks/columns/columns.cjs +3 -3
- package/lib/node/blocks/columns/columns.mjs +42 -34
- package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/node/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +58 -57
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/evaluate/node-runtime/node-runtime.cjs +6 -6
- package/lib/node/functions/evaluate/node-runtime/node-runtime.mjs +20 -18
- package/lib/node/functions/log-fetch.cjs +1 -0
- package/lib/node/functions/log-fetch.mjs +8 -0
- package/lib/node/functions/track/index.cjs +1 -1
- package/lib/node/functions/track/index.mjs +18 -14
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/evaluate/node-runtime/setIvm.d.ts +1 -0
- package/types/cjs/functions/log-fetch.d.ts +1 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/evaluate/node-runtime/setIvm.d.ts +1 -0
- package/types/esm/functions/log-fetch.d.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const a=require("react/jsx-runtime"),l=require("react"),s=require("../../functions/is-editing.cjs");function d(e){const c=l.useRef(null);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function i(){if(!e.path)return;const t="component.options.";return e.path.startsWith(t)?e.path:`${t}${e.path||""}`}function r(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:i()}},"*"))}function u(){var t,n;s.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:i()}},"*"))}return l.useEffect(()=>{},[]),a.jsxs(a.Fragment,{children:[a.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-215a41e0","builder-path":i(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>r(),onMouseEnter:t=>u(),onKeyPress:t=>r(),...e.BlocksWrapperProps,children:e.children}),a.jsx("style",{children:`.props-blocks-wrapper-215a41e0 {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: stretch;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { isEditing as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
function
|
|
2
|
+
import { jsxs as d, Fragment as u, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as f, useEffect as h } from "react";
|
|
4
|
+
import { isEditing as i } from "../../functions/is-editing.mjs";
|
|
5
|
+
function b(e) {
|
|
6
|
+
const o = f(null);
|
|
7
|
+
function c() {
|
|
8
8
|
var t;
|
|
9
9
|
return [
|
|
10
10
|
"builder-blocks",
|
|
@@ -12,50 +12,56 @@ function h(e) {
|
|
|
12
12
|
e.classNameProp
|
|
13
13
|
].filter(Boolean).join(" ");
|
|
14
14
|
}
|
|
15
|
+
function a() {
|
|
16
|
+
if (!e.path)
|
|
17
|
+
return;
|
|
18
|
+
const t = "component.options.";
|
|
19
|
+
return e.path.startsWith(t) ? e.path : `${t}${e.path || ""}`;
|
|
20
|
+
}
|
|
15
21
|
function l() {
|
|
16
22
|
var t, n;
|
|
17
|
-
|
|
23
|
+
i() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
18
24
|
{
|
|
19
25
|
type: "builder.clickEmptyBlocks",
|
|
20
26
|
data: {
|
|
21
27
|
parentElementId: e.parent,
|
|
22
|
-
dataPath:
|
|
28
|
+
dataPath: a()
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
31
|
"*"
|
|
26
32
|
));
|
|
27
33
|
}
|
|
28
|
-
function
|
|
34
|
+
function s() {
|
|
29
35
|
var t, n;
|
|
30
|
-
|
|
36
|
+
i() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
31
37
|
{
|
|
32
38
|
type: "builder.hoverEmptyBlocks",
|
|
33
39
|
data: {
|
|
34
40
|
parentElementId: e.parent,
|
|
35
|
-
dataPath:
|
|
41
|
+
dataPath: a()
|
|
36
42
|
}
|
|
37
43
|
},
|
|
38
44
|
"*"
|
|
39
45
|
));
|
|
40
46
|
}
|
|
41
|
-
return
|
|
42
|
-
}, []), /* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
47
|
+
return h(() => {
|
|
48
|
+
}, []), /* @__PURE__ */ d(u, { children: [
|
|
49
|
+
/* @__PURE__ */ r(
|
|
44
50
|
e.BlocksWrapper,
|
|
45
51
|
{
|
|
46
|
-
ref:
|
|
47
|
-
className:
|
|
48
|
-
"builder-path":
|
|
52
|
+
ref: o,
|
|
53
|
+
className: c() + " props-blocks-wrapper-215a41e0",
|
|
54
|
+
"builder-path": a(),
|
|
49
55
|
"builder-parent-id": e.parent,
|
|
50
56
|
style: e.styleProp,
|
|
51
57
|
onClick: (t) => l(),
|
|
52
|
-
onMouseEnter: (t) =>
|
|
58
|
+
onMouseEnter: (t) => s(),
|
|
53
59
|
onKeyPress: (t) => l(),
|
|
54
60
|
...e.BlocksWrapperProps,
|
|
55
61
|
children: e.children
|
|
56
62
|
}
|
|
57
63
|
),
|
|
58
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-215a41e0 {
|
|
59
65
|
display: flex;
|
|
60
66
|
flex-direction: column;
|
|
61
67
|
align-items: stretch;
|
|
@@ -63,5 +69,5 @@ function h(e) {
|
|
|
63
69
|
] });
|
|
64
70
|
}
|
|
65
71
|
export {
|
|
66
|
-
|
|
72
|
+
b as default
|
|
67
73
|
};
|
|
@@ -1 +1 @@
|
|
|
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")
|
|
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"),F=require("../../../functions/log-fetch.cjs"),U=require("../../../functions/register-component.cjs"),P=require("../../../functions/track/index.cjs"),O=require("../../../functions/track/interaction.cjs"),y=require("../../../helpers/canTrack.cjs"),$=require("../../../helpers/preview-lru-cache/set.cjs"),z=require("../../../helpers/subscribe-to-editor.cjs"),H=require("../../../scripts/init-editing.cjs"),G=require("../../block/animator.cjs"),J=require("./styles.helpers.cjs"),Q=require("next/navigation");function X(e){var q,w,I;const s=o.useRef(null);function f(n){var r,i;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(i=(r=e.builderContextSignal).rootSetState)==null||i.call(r,t):e.builderContextSignal.rootState=t}function b(n){var r,i,a,c,l;const t={...e.builderContextSignal.content,...n,data:{...(r=e.builderContextSignal.content)==null?void 0:r.data,...n==null?void 0:n.data},meta:{...(i=e.builderContextSignal.content)==null?void 0:i.meta,...n==null?void 0:n.meta,breakpoints:((a=n==null?void 0:n.meta)==null?void 0:a.breakpoints)||((l=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:l.breakpoints)}};$.postPreviewContent({value:t,key:t.id}).then(()=>{V.refresh()})}function L(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[K,Y]=o.useState(()=>e.contentWrapper||"div");function S(n){return z.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var a;const{breakpoints:r,contentId:i}=t;!i||i!==((a=e.builderContextSignal.content)==null?void 0:a.id)||r&&b({meta:{breakpoints:r}})},animation:t=>{G.triggerAnimation(t)},contentUpdate:t=>{b(t)}}})(n)}const[v,Z]=o.useState(()=>({})),[m,p]=o.useState(()=>({})),[h,T]=o.useState(()=>!1);function _(n){var t,r;if(e.builderContextSignal.content){const i=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,a=(r=e.builderContextSignal.content)==null?void 0:r.id;P._track({apiHost:e.apiHost,type:"click",canTrack:y.getDefaultCanTrack(e.canTrack),contentId:a,apiKey:e.apiKey,variationId:i!==a?i:void 0,...O.getInteractionPropertiesForEvent(n),unique:!h})}h||T(!0)}function j(){var t,r,i;const n=(i=(r=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:r.httpRequests)!=null?i:{};Object.entries(n).forEach(([a,c])=>{if(!c||m[a]||v[a]&&!g.isEditing())return;m[a]=!0;const l=c.replace(/{{([^}]+)}}/g,(d,M)=>String(W.evaluate({code:M,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));F.logFetch(l),fetch(l).then(d=>d.json()).then(d=>{f({[a]:d}),v[a]=!0}).catch(d=>{console.error("error fetching dynamic data",c,d)}).finally(()=>{m[a]=!1})})}function u(){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 r=U.createRegisterComponentMessage(t);(i=window.parent)==null||i.postMessage(r,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",u)}function x(n){const t=new URL(location.href).searchParams,r=t.get("builder.preview"),i=t.get(`builder.overrides.${r}`),a=t.get("apiKey")||t.get("builder.space");r===e.model&&a===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=Q.useRouter(),C=o.useRef(!1);return C.current||(j(),u(),C.current=!0),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(R.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&s.current&&s.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&y.getDefaultCanTrack(e.canTrack)){const i=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,a=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;P._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:a,apiKey:c,variationId:i!==a?i:void 0})}D.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{u()},[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",u))},[]),k.jsx(N.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?k.jsx(K,{ref:s,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:J.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=X;
|
|
@@ -7,44 +7,45 @@ import { fastClone as _ } from "../../../functions/fast-clone.mjs";
|
|
|
7
7
|
import { fetchOneEntry as D } from "../../../functions/get-content/index.mjs";
|
|
8
8
|
import { isBrowser as L } from "../../../functions/is-browser.mjs";
|
|
9
9
|
import { isEditing as f } from "../../../functions/is-editing.mjs";
|
|
10
|
-
import { isPreviewing as
|
|
10
|
+
import { isPreviewing as F } from "../../../functions/is-previewing.mjs";
|
|
11
|
+
import { logFetch as O } from "../../../functions/log-fetch.mjs";
|
|
11
12
|
import { createRegisterComponentMessage as B } from "../../../functions/register-component.mjs";
|
|
12
13
|
import { _track as y } from "../../../functions/track/index.mjs";
|
|
13
|
-
import { getInteractionPropertiesForEvent as
|
|
14
|
+
import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
|
|
14
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
15
|
-
import { postPreviewContent as
|
|
16
|
-
import { createEditorListener as
|
|
17
|
-
import { registerInsertMenu as
|
|
18
|
-
import { triggerAnimation as
|
|
19
|
-
import { getWrapperClassName as
|
|
20
|
-
import { useRouter as
|
|
21
|
-
function
|
|
16
|
+
import { postPreviewContent as $ } from "../../../helpers/preview-lru-cache/set.mjs";
|
|
17
|
+
import { createEditorListener as G } from "../../../helpers/subscribe-to-editor.mjs";
|
|
18
|
+
import { registerInsertMenu as J, setupBrowserForEditing as Q } from "../../../scripts/init-editing.mjs";
|
|
19
|
+
import { triggerAnimation as X } from "../../block/animator.mjs";
|
|
20
|
+
import { getWrapperClassName as Y } from "./styles.helpers.mjs";
|
|
21
|
+
import { useRouter as Z } from "next/navigation";
|
|
22
|
+
function It(t) {
|
|
22
23
|
var w, k, P;
|
|
23
24
|
const d = H(null);
|
|
24
25
|
function g(n) {
|
|
25
|
-
var
|
|
26
|
+
var r, i;
|
|
26
27
|
const e = {
|
|
27
28
|
...t.builderContextSignal.rootState,
|
|
28
29
|
...n
|
|
29
30
|
};
|
|
30
|
-
t.builderContextSignal.rootSetState ? (i = (
|
|
31
|
+
t.builderContextSignal.rootSetState ? (i = (r = t.builderContextSignal).rootSetState) == null || i.call(r, e) : t.builderContextSignal.rootState = e;
|
|
31
32
|
}
|
|
32
33
|
function b(n) {
|
|
33
|
-
var
|
|
34
|
+
var r, i, a, o, u;
|
|
34
35
|
const e = {
|
|
35
36
|
...t.builderContextSignal.content,
|
|
36
37
|
...n,
|
|
37
38
|
data: {
|
|
38
|
-
...(
|
|
39
|
+
...(r = t.builderContextSignal.content) == null ? void 0 : r.data,
|
|
39
40
|
...n == null ? void 0 : n.data
|
|
40
41
|
},
|
|
41
42
|
meta: {
|
|
42
43
|
...(i = t.builderContextSignal.content) == null ? void 0 : i.meta,
|
|
43
44
|
...n == null ? void 0 : n.meta,
|
|
44
|
-
breakpoints: ((
|
|
45
|
+
breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((u = (o = t.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : u.breakpoints)
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
$({
|
|
48
49
|
value: e,
|
|
49
50
|
key: e.id
|
|
50
51
|
}).then(() => {
|
|
@@ -57,25 +58,25 @@ function Ct(t) {
|
|
|
57
58
|
"aria-hidden": !0
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
const [T,
|
|
61
|
+
const [T, p] = m(
|
|
61
62
|
() => t.contentWrapper || "div"
|
|
62
63
|
);
|
|
63
64
|
function v(n) {
|
|
64
|
-
return
|
|
65
|
+
return G({
|
|
65
66
|
model: t.model,
|
|
66
67
|
trustedHosts: t.trustedHosts,
|
|
67
68
|
callbacks: {
|
|
68
69
|
configureSdk: (e) => {
|
|
69
|
-
var
|
|
70
|
-
const { breakpoints:
|
|
71
|
-
!i || i !== ((
|
|
70
|
+
var a;
|
|
71
|
+
const { breakpoints: r, contentId: i } = e;
|
|
72
|
+
!i || i !== ((a = t.builderContextSignal.content) == null ? void 0 : a.id) || r && b({
|
|
72
73
|
meta: {
|
|
73
|
-
breakpoints:
|
|
74
|
+
breakpoints: r
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
},
|
|
77
78
|
animation: (e) => {
|
|
78
|
-
|
|
79
|
+
X(e);
|
|
79
80
|
},
|
|
80
81
|
contentUpdate: (e) => {
|
|
81
82
|
b(e);
|
|
@@ -83,32 +84,32 @@ function Ct(t) {
|
|
|
83
84
|
}
|
|
84
85
|
})(n);
|
|
85
86
|
}
|
|
86
|
-
const [h,
|
|
87
|
+
const [h, tt] = m(() => ({})), [S, et] = m(() => ({})), [x, V] = m(() => !1);
|
|
87
88
|
function M(n) {
|
|
88
|
-
var e,
|
|
89
|
+
var e, r;
|
|
89
90
|
if (t.builderContextSignal.content) {
|
|
90
|
-
const i = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId,
|
|
91
|
+
const i = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId, a = (r = t.builderContextSignal.content) == null ? void 0 : r.id;
|
|
91
92
|
y({
|
|
92
93
|
apiHost: t.apiHost,
|
|
93
94
|
type: "click",
|
|
94
95
|
canTrack: K(t.canTrack),
|
|
95
|
-
contentId:
|
|
96
|
+
contentId: a,
|
|
96
97
|
apiKey: t.apiKey,
|
|
97
|
-
variationId: i !==
|
|
98
|
-
...
|
|
98
|
+
variationId: i !== a ? i : void 0,
|
|
99
|
+
...z(n),
|
|
99
100
|
unique: !x
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
x || V(!0);
|
|
103
104
|
}
|
|
104
105
|
function N() {
|
|
105
|
-
var e,
|
|
106
|
-
const n = (i = (
|
|
107
|
-
Object.entries(n).forEach(([
|
|
108
|
-
if (!o || S[
|
|
106
|
+
var e, r, i;
|
|
107
|
+
const n = (i = (r = (e = t.builderContextSignal.content) == null ? void 0 : e.data) == null ? void 0 : r.httpRequests) != null ? i : {};
|
|
108
|
+
Object.entries(n).forEach(([a, o]) => {
|
|
109
|
+
if (!o || S[a] || h[a] && !f())
|
|
109
110
|
return;
|
|
110
|
-
S[
|
|
111
|
-
const
|
|
111
|
+
S[a] = !0;
|
|
112
|
+
const u = o.replace(
|
|
112
113
|
/{{([^}]+)}}/g,
|
|
113
114
|
(l, j) => String(
|
|
114
115
|
U({
|
|
@@ -120,18 +121,18 @@ function Ct(t) {
|
|
|
120
121
|
})
|
|
121
122
|
)
|
|
122
123
|
);
|
|
123
|
-
fetch(
|
|
124
|
+
O(u), fetch(u).then((l) => l.json()).then((l) => {
|
|
124
125
|
g({
|
|
125
|
-
[
|
|
126
|
-
}), h[
|
|
126
|
+
[a]: l
|
|
127
|
+
}), h[a] = !0;
|
|
127
128
|
}).catch((l) => {
|
|
128
129
|
console.error("error fetching dynamic data", o, l);
|
|
129
130
|
}).finally(() => {
|
|
130
|
-
S[
|
|
131
|
+
S[a] = !1;
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
function
|
|
135
|
+
function s() {
|
|
135
136
|
f() && window.dispatchEvent(
|
|
136
137
|
new CustomEvent(
|
|
137
138
|
"builder:component:stateChange",
|
|
@@ -147,7 +148,7 @@ function Ct(t) {
|
|
|
147
148
|
);
|
|
148
149
|
}
|
|
149
150
|
function C(n) {
|
|
150
|
-
window.addEventListener("message", v),
|
|
151
|
+
window.addEventListener("message", v), J(), Q({
|
|
151
152
|
...t.locale ? {
|
|
152
153
|
locale: t.locale
|
|
153
154
|
} : {},
|
|
@@ -161,18 +162,18 @@ function Ct(t) {
|
|
|
161
162
|
t.builderContextSignal.componentInfos
|
|
162
163
|
).forEach((e) => {
|
|
163
164
|
var i;
|
|
164
|
-
const
|
|
165
|
-
(i = window.parent) == null || i.postMessage(
|
|
165
|
+
const r = B(e);
|
|
166
|
+
(i = window.parent) == null || i.postMessage(r, "*");
|
|
166
167
|
}), window.addEventListener(
|
|
167
168
|
"builder:component:stateChangeListenerActivated",
|
|
168
|
-
|
|
169
|
+
s
|
|
169
170
|
);
|
|
170
171
|
}
|
|
171
172
|
function E(n) {
|
|
172
|
-
const e = new URL(location.href).searchParams,
|
|
173
|
-
`builder.overrides.${
|
|
174
|
-
),
|
|
175
|
-
|
|
173
|
+
const e = new URL(location.href).searchParams, r = e.get("builder.preview"), i = e.get(
|
|
174
|
+
`builder.overrides.${r}`
|
|
175
|
+
), a = e.get("apiKey") || e.get("builder.space");
|
|
176
|
+
r === t.model && a === t.apiKey && (!t.content || i === t.content.id) && D({
|
|
176
177
|
model: t.model,
|
|
177
178
|
apiKey: t.apiKey,
|
|
178
179
|
apiVersion: t.builderContextSignal.apiVersion
|
|
@@ -180,8 +181,8 @@ function Ct(t) {
|
|
|
180
181
|
o && b(o);
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
|
-
const W =
|
|
184
|
-
return I.current || (N(),
|
|
184
|
+
const W = Z(), I = H(!1);
|
|
185
|
+
return I.current || (N(), s(), I.current = !0), c(() => {
|
|
185
186
|
var n;
|
|
186
187
|
return (n = d.current) == null || n.addEventListener(
|
|
187
188
|
"initeditingbldr",
|
|
@@ -209,21 +210,21 @@ function Ct(t) {
|
|
|
209
210
|
var n, e;
|
|
210
211
|
if (L()) {
|
|
211
212
|
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,
|
|
213
|
+
const i = (n = t.builderContextSignal.content) == null ? void 0 : n.testVariationId, a = (e = t.builderContextSignal.content) == null ? void 0 : e.id, o = t.apiKey;
|
|
213
214
|
y({
|
|
214
215
|
apiHost: t.apiHost,
|
|
215
216
|
type: "impression",
|
|
216
217
|
canTrack: !0,
|
|
217
|
-
contentId:
|
|
218
|
+
contentId: a,
|
|
218
219
|
apiKey: o,
|
|
219
|
-
variationId: i !==
|
|
220
|
+
variationId: i !== a ? i : void 0
|
|
220
221
|
});
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
F() && f();
|
|
223
224
|
}
|
|
224
225
|
}, []), c(() => {
|
|
225
226
|
}, [t.content]), c(() => {
|
|
226
|
-
|
|
227
|
+
s();
|
|
227
228
|
}, [t.builderContextSignal.rootState]), c(() => {
|
|
228
229
|
t.data && g(t.data);
|
|
229
230
|
}, [t.data]), c(() => {
|
|
@@ -233,7 +234,7 @@ function Ct(t) {
|
|
|
233
234
|
}, [t.locale]), c(() => () => {
|
|
234
235
|
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
235
236
|
"builder:component:stateChangeListenerActivated",
|
|
236
|
-
|
|
237
|
+
s
|
|
237
238
|
));
|
|
238
239
|
}, []), /* @__PURE__ */ R(A.Provider, { value: t.builderContextSignal, children: t.builderContextSignal.content ? /* @__PURE__ */ R(
|
|
239
240
|
T,
|
|
@@ -242,7 +243,7 @@ function Ct(t) {
|
|
|
242
243
|
onClick: (n) => M(n),
|
|
243
244
|
"builder-content-id": (w = t.builderContextSignal.content) == null ? void 0 : w.id,
|
|
244
245
|
"builder-model": t.model,
|
|
245
|
-
className:
|
|
246
|
+
className: Y(
|
|
246
247
|
((k = t.content) == null ? void 0 : k.testVariationId) || ((P = t.content) == null ? void 0 : P.id)
|
|
247
248
|
),
|
|
248
249
|
...q(),
|
|
@@ -252,5 +253,5 @@ function Ct(t) {
|
|
|
252
253
|
) : null });
|
|
253
254
|
}
|
|
254
255
|
export {
|
|
255
|
-
|
|
256
|
+
It as default
|
|
256
257
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.23";exports.SDK_VERSION=e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../constants/sdk-name.cjs"),m=require("../../../helpers/logger.cjs"),A=require("../../fast-clone.cjs"),R=require("../../set.cjs"),M=require("../helpers.cjs"),k=require("./safeDynamicRequire.cjs"),g=t=>`bldr_${t}_sync`,b="BUILDER_SET_STATE",I="BUILDER_IVM",h=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -24,8 +24,8 @@ var refToProxy = (obj) => {
|
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
28
|
-
${
|
|
27
|
+
`,x=({code:t,args:e})=>{const u=e.map(([o])=>`var ${o} = refToProxy(${g(o)}); `).join("");return`
|
|
28
|
+
${h}
|
|
29
29
|
${u}
|
|
30
30
|
function theFunction() {
|
|
31
31
|
${t}
|
|
@@ -38,11 +38,11 @@ if (typeof output === 'object' && output !== null) {
|
|
|
38
38
|
} else {
|
|
39
39
|
return output;
|
|
40
40
|
}
|
|
41
|
-
`};let
|
|
41
|
+
`};let l=null,y=null;const C=(t,e={})=>{l||(l=t,E(e))},D=c.SDK_NAME==="@builder.io/sdk-react-nextjs"||c.SDK_NAME==="@builder.io/sdk-react"||c.SDK_NAME==="@builder.io/sdk-qwik"||c.SDK_NAME==="@builder.io/sdk-vue",S=()=>{try{if(l)return l;const e=k.safeDynamicRequire("isolated-vm");if(e)return e}catch(e){m.logger.error("isolated-vm import error.",e)}const t=`${m.MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
42
42
|
|
|
43
43
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
44
44
|
|
|
45
|
-
${D?`- import and call \`initializeNodeRuntime()\` from "${
|
|
45
|
+
${D?`- import and call \`initializeNodeRuntime()\` from "${c.SDK_NAME}/node/init".`:""}
|
|
46
46
|
- add the following import: \`await import('isolated-vm')\`.
|
|
47
47
|
|
|
48
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)};function E(t={memoryLimit:128}){const e=S(),o=new e.Isolate(t).createContextSync(),n=o.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...
|
|
48
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)};function E(t={memoryLimit:128}){if(y)return y;const e=S(),o=new e.Isolate(t).createContextSync(),n=o.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...i){console.log(...i)}),n.setSync(I,e),y=o,o}const O=()=>E(),w=({code:t,builder:e,context:u,event:o,localState:n,rootSetState:i,rootState:a})=>{const _=S(),N=A.fastClone({...a,...n}),d=M.getFunctionArguments({builder:e,context:u,event:o,state:N}),f=O(),p=f.global;p.setSync(b,function(r,s){R.set(a,r,s),i==null||i(a)}),d.forEach(([r,s])=>{const j=typeof s=="object"?new _.Reference(r==="builder"?{...s,getUserAttributes:()=>s.getUserAttributes()}:s):null;p.setSync(g(r),j)});const T=x({code:t,args:d}),v=f.evalClosureSync(T);try{return JSON.parse(v)}catch{return v}};exports.runInNode=w;exports.setIvm=C;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SDK_NAME as
|
|
2
|
-
import { logger as j, MSG_PREFIX as
|
|
3
|
-
import { fastClone as
|
|
1
|
+
import { SDK_NAME as c } from "../../../constants/sdk-name.mjs";
|
|
2
|
+
import { logger as j, MSG_PREFIX as R } from "../../../helpers/logger.mjs";
|
|
3
|
+
import { fastClone as x } from "../../fast-clone.mjs";
|
|
4
4
|
import { set as k } from "../../set.mjs";
|
|
5
5
|
import { getFunctionArguments as A } from "../helpers.mjs";
|
|
6
6
|
import { safeDynamicRequire as h } from "./safeDynamicRequire.mjs";
|
|
@@ -51,24 +51,24 @@ if (typeof output === 'object' && output !== null) {
|
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
53
|
};
|
|
54
|
-
let
|
|
54
|
+
let u = null, y = null;
|
|
55
55
|
const V = (e, t = {}) => {
|
|
56
|
-
|
|
57
|
-
}, O =
|
|
56
|
+
u || (u = e, E(t));
|
|
57
|
+
}, O = c === "@builder.io/sdk-react-nextjs" || c === "@builder.io/sdk-react" || c === "@builder.io/sdk-qwik" || c === "@builder.io/sdk-vue", g = () => {
|
|
58
58
|
try {
|
|
59
|
-
if (
|
|
60
|
-
return
|
|
59
|
+
if (u)
|
|
60
|
+
return u;
|
|
61
61
|
const t = h("isolated-vm");
|
|
62
62
|
if (t)
|
|
63
63
|
return t;
|
|
64
64
|
} catch (t) {
|
|
65
65
|
j.error("isolated-vm import error.", t);
|
|
66
66
|
}
|
|
67
|
-
const e = `${
|
|
67
|
+
const e = `${R}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
68
68
|
|
|
69
69
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
70
70
|
|
|
71
|
-
${O ? `- import and call \`initializeNodeRuntime()\` from "${
|
|
71
|
+
${O ? `- import and call \`initializeNodeRuntime()\` from "${c}/node/init".` : ""}
|
|
72
72
|
- add the following import: \`await import('isolated-vm')\`.
|
|
73
73
|
|
|
74
74
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
@@ -77,22 +77,24 @@ const V = (e, t = {}) => {
|
|
|
77
77
|
function E(e = {
|
|
78
78
|
memoryLimit: 128
|
|
79
79
|
}) {
|
|
80
|
+
if (y)
|
|
81
|
+
return y;
|
|
80
82
|
const t = g(), o = new t.Isolate(e).createContextSync(), n = o.global;
|
|
81
|
-
return n.setSync("global", n.derefInto()), n.setSync("log", function(...
|
|
82
|
-
console.log(...
|
|
83
|
+
return n.setSync("global", n.derefInto()), n.setSync("log", function(...s) {
|
|
84
|
+
console.log(...s);
|
|
83
85
|
}), n.setSync(I, t), y = o, o;
|
|
84
86
|
}
|
|
85
|
-
const $ = () =>
|
|
87
|
+
const $ = () => E(), B = ({
|
|
86
88
|
code: e,
|
|
87
89
|
builder: t,
|
|
88
90
|
context: l,
|
|
89
91
|
event: o,
|
|
90
92
|
localState: n,
|
|
91
|
-
rootSetState:
|
|
92
|
-
rootState:
|
|
93
|
+
rootSetState: s,
|
|
94
|
+
rootState: a
|
|
93
95
|
}) => {
|
|
94
|
-
const S = g(), _ =
|
|
95
|
-
...
|
|
96
|
+
const S = g(), _ = x({
|
|
97
|
+
...a,
|
|
96
98
|
...n
|
|
97
99
|
}), f = A({
|
|
98
100
|
builder: t,
|
|
@@ -101,7 +103,7 @@ const $ = () => y || E(), B = ({
|
|
|
101
103
|
state: _
|
|
102
104
|
}), m = $(), p = m.global;
|
|
103
105
|
p.setSync(b, function(r, i) {
|
|
104
|
-
k(
|
|
106
|
+
k(a, r, i), s == null || s(a);
|
|
105
107
|
}), f.forEach(([r, i]) => {
|
|
106
108
|
const N = typeof i == "object" ? new S.Reference(
|
|
107
109
|
// workaround: methods with default values for arguments is not being cloned over
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../helpers/logger.cjs");function t(o){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&r.logger.log(o)}exports.logFetch=t;
|
|
@@ -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"),
|
|
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"),l=require("../is-browser.cjs"),g=require("../is-editing.cjs"),y=require("../log-fetch.cjs"),I=require("./helpers.cjs"),k=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}},f=async({type:e,canTrack:t,apiKey:r,metadata:s,...i})=>({type:e,data:{...i,metadata:{url:location.href,...s},...await k({canTrack:t}),userAttributes:I.getUserAttributes(),ownerId:r}});async function o({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||g.isEditing()||!(l.isBrowser()||n.TARGET==="reactNative"))return;const s=`${e||"https://cdn.builder.io"}/api/v1/track`;return y.logFetch(s),fetch(s,{method:"POST",body:JSON.stringify({events:[await f(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const v=e=>o({...e,canTrack:!0});exports._track=o;exports.track=v;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { TARGET as
|
|
2
|
-
import { logger as
|
|
1
|
+
import { TARGET as s } from "../../constants/target.mjs";
|
|
2
|
+
import { logger as a } from "../../helpers/logger.mjs";
|
|
3
3
|
import { getSdkHeaders as n } from "../../helpers/sdk-headers.mjs";
|
|
4
4
|
import { getSessionId as c } from "../../helpers/sessionId.mjs";
|
|
5
5
|
import { getVisitorId as d } from "../../helpers/visitorId.mjs";
|
|
6
6
|
import { isBrowser as m } from "../is-browser.mjs";
|
|
7
7
|
import { isEditing as f } from "../is-editing.mjs";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { logFetch as p } from "../log-fetch.mjs";
|
|
9
|
+
import { getUserAttributes as u } from "./helpers.mjs";
|
|
10
|
+
const l = async ({
|
|
10
11
|
canTrack: t
|
|
11
12
|
}) => {
|
|
12
13
|
if (!t)
|
|
@@ -23,7 +24,7 @@ const u = async ({
|
|
|
23
24
|
sessionId: r,
|
|
24
25
|
visitorId: e
|
|
25
26
|
};
|
|
26
|
-
},
|
|
27
|
+
}, g = async ({
|
|
27
28
|
type: t,
|
|
28
29
|
canTrack: r,
|
|
29
30
|
apiKey: e,
|
|
@@ -37,10 +38,10 @@ const u = async ({
|
|
|
37
38
|
url: location.href,
|
|
38
39
|
...o
|
|
39
40
|
},
|
|
40
|
-
...await
|
|
41
|
+
...await l({
|
|
41
42
|
canTrack: r
|
|
42
43
|
}),
|
|
43
|
-
userAttributes:
|
|
44
|
+
userAttributes: u(),
|
|
44
45
|
ownerId: e
|
|
45
46
|
}
|
|
46
47
|
});
|
|
@@ -49,28 +50,31 @@ async function y({
|
|
|
49
50
|
...r
|
|
50
51
|
}) {
|
|
51
52
|
if (!r.apiKey) {
|
|
52
|
-
|
|
53
|
+
a.error("Missing API key for track call. Please provide your API key.");
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
if (!r.canTrack || f() || !(m() || s === "reactNative"))
|
|
57
|
+
return;
|
|
58
|
+
const o = `${t || "https://cdn.builder.io"}/api/v1/track`;
|
|
59
|
+
return p(o), fetch(o, {
|
|
56
60
|
method: "POST",
|
|
57
61
|
body: JSON.stringify({
|
|
58
|
-
events: [await
|
|
62
|
+
events: [await g(r)]
|
|
59
63
|
}),
|
|
60
64
|
headers: {
|
|
61
65
|
"content-type": "application/json",
|
|
62
66
|
...n()
|
|
63
67
|
},
|
|
64
68
|
mode: "cors"
|
|
65
|
-
}).catch((
|
|
66
|
-
console.error("Failed to track: ",
|
|
69
|
+
}).catch((i) => {
|
|
70
|
+
console.error("Failed to track: ", i);
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
|
-
const
|
|
73
|
+
const T = (t) => y({
|
|
70
74
|
...t,
|
|
71
75
|
canTrack: !0
|
|
72
76
|
});
|
|
73
77
|
export {
|
|
74
78
|
y as _track,
|
|
75
|
-
|
|
79
|
+
T as track
|
|
76
80
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-nextjs",
|
|
3
3
|
"description": "Builder.io RSC SDK for NextJS App Directory",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.23",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|