@builder.io/sdk-react-nextjs 0.7.0 → 0.7.1-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.
Files changed (37) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-7a3bf41a.mjs +657 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-9195e6a5.js +23 -0
  3. package/lib/{edge/USE_SERVER_BUNDLE-105e9ef3.js → browser/USE_SERVER_BUNDLE-d7b13097.js} +1 -1
  4. package/lib/browser/USE_SERVER_BUNDLE-e5c2279a.mjs +11 -0
  5. package/lib/browser/{bundle-0fae602b.js → bundle-620ae296.js} +5 -5
  6. package/lib/browser/{bundle-3b073b16.mjs → bundle-7285a09d.mjs} +265 -268
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +7 -7
  9. package/lib/edge/USE_CLIENT_BUNDLE-3cca560e.js +23 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-4a0cfa69.mjs +657 -0
  11. package/lib/{node/USE_SERVER_BUNDLE-d8c698c8.js → edge/USE_SERVER_BUNDLE-3f12faf4.js} +1 -1
  12. package/lib/edge/USE_SERVER_BUNDLE-f184d7eb.mjs +11 -0
  13. package/lib/edge/{bundle-0c1d9099.js → bundle-a0f5cad2.js} +5 -5
  14. package/lib/edge/{bundle-ed178c62.mjs → bundle-a5949d33.mjs} +265 -268
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +7 -7
  17. package/lib/node/USE_CLIENT_BUNDLE-63c7fe77.js +61 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-d9e90ed7.mjs +747 -0
  19. package/lib/node/USE_SERVER_BUNDLE-22e86776.mjs +11 -0
  20. package/lib/{browser/USE_SERVER_BUNDLE-d8c698c8.js → node/USE_SERVER_BUNDLE-cd844269.js} +1 -1
  21. package/lib/node/{bundle-3b073b16.mjs → bundle-0358b224.mjs} +415 -444
  22. package/lib/node/bundle-630ffe6d.js +76 -0
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +23 -22
  25. package/package.json +5 -3
  26. package/types/blocks/image/image.d.ts +1 -1
  27. package/types/constants/sdk-version.d.ts +1 -1
  28. package/lib/browser/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  29. package/lib/browser/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  30. package/lib/browser/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  31. package/lib/edge/USE_CLIENT_BUNDLE-0e9f8e67.mjs +0 -618
  32. package/lib/edge/USE_CLIENT_BUNDLE-d48583e8.js +0 -23
  33. package/lib/edge/USE_SERVER_BUNDLE-f6a1e321.mjs +0 -11
  34. package/lib/node/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  35. package/lib/node/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  36. package/lib/node/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  37. package/lib/node/bundle-0fae602b.js +0 -76
@@ -1,10 +1,10 @@
1
- import { B as i, p as m, C as c, R as g, o as p, S as l, T as C, z as d, e as u, E as B, v as S, w as f, x as E, A as R, y as h, i as x, q as k, t as y, u as P, D as b } from "./bundle-ed178c62.mjs";
2
- import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-0e9f8e67.mjs";
1
+ import { B as i, t as m, C as c, R as g, q as p, S as l, T as C, z as d, m as f, E as u, w as B, n as S, x as E, A as R, y as h, i as x, f as k, u as y, v as P, D as b } from "./bundle-a5949d33.mjs";
2
+ import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-4a0cfa69.mjs";
3
3
  import "lru-cache";
4
4
  import "react/jsx-runtime";
5
5
  import "react";
6
6
  import "next/navigation";
7
- import "./USE_SERVER_BUNDLE-f6a1e321.mjs";
7
+ import "./USE_SERVER_BUNDLE-f184d7eb.mjs";
8
8
  export {
9
9
  i as Blocks,
10
10
  w as Button,
@@ -19,10 +19,10 @@ export {
19
19
  C as Text,
20
20
  V as Video,
21
21
  d as _processContentResult,
22
- u as createRegisterComponentMessage,
23
- B as fetchBuilderProps,
24
- S as fetchEntries,
25
- f as fetchOneEntry,
22
+ f as createRegisterComponentMessage,
23
+ u as fetchBuilderProps,
24
+ B as fetchEntries,
25
+ S as fetchOneEntry,
26
26
  E as getAllContent,
27
27
  R as getBuilderSearchParams,
28
28
  h as getContent,
@@ -0,0 +1,61 @@
1
+ "use client";"use strict";const t=require("react/jsx-runtime"),O=require("isolated-vm"),o=require("./bundle-630ffe6d.js"),l=require("react"),D=require("./USE_SERVER_BUNDLE-cd844269.js"),U=require("next/navigation");function V(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const f=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,f.get?f:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const A=V(O);function W(e){return t.jsxs(t.Fragment,{children:[e.link?t.jsx(t.Fragment,{children:t.jsx("a",{role:"button",...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,children:e.text})}):t.jsx(t.Fragment,{children:t.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-35669e6c",children:e.text})}),t.jsx("style",{children:`.button-35669e6c {
2
+ all: unset;
3
+ }`})]})}const q=e=>`bldr_${e}_sync`,K="BUILDER_SET_STATE",z=`
4
+ var refToProxy = (obj) => {
5
+ if (typeof obj !== 'object' || obj === null) {
6
+ return obj;
7
+ }
8
+ return new Proxy({}, {
9
+ get(target, key) {
10
+ if (key === 'copySync') {
11
+ return () => obj.copySync();
12
+ }
13
+ const val = obj.getSync(key);
14
+ if (typeof val?.getSync === 'function') {
15
+ return refToProxy(val);
16
+ }
17
+ return val;
18
+ },
19
+ set(target, key, value) {
20
+ obj.setSync(key, value);
21
+ ${K}(obj.copySync())
22
+ },
23
+ deleteProperty(target, key) {
24
+ obj.deleteSync(key);
25
+ }
26
+ })
27
+ }
28
+ `,$=({code:e,args:n})=>{const r=n.map(([f])=>`var ${f} = refToProxy(${q(f)}); `).join("");return`
29
+ ${z}
30
+ ${r}
31
+ function theFunction() {
32
+ ${e}
33
+ }
34
+
35
+ const output = theFunction()
36
+
37
+ if (typeof output === 'object' && output !== null) {
38
+ JSON.stringify(output.copySync ? output.copySync() : output);
39
+ }
40
+ output;
41
+ `},H=()=>new A.Isolate({memoryLimit:128}).createContextSync(),J=({code:e,builder:n,context:r,event:f,localState:s,rootSetState:h,rootState:v})=>{const x={...v,...s},b=o.getFunctionArguments({builder:n,context:r,event:f,state:x}),u=H(),m=u.global;m.setSync("global",m.derefInto()),m.setSync("log",function(...E){console.log(...E)}),m.setSync(K,function(E){h&&h(E)}),b.forEach(([E,j])=>{const w=typeof j=="object"?new A.Reference(E==="builder"?{...j,getUserAttributes:()=>j.getUserAttributes()}:j):null;m.setSync(q(E),w)});const y=$({code:e,args:b}),k=u.evalSync(y);try{return JSON.parse(k)}catch{return k}};function G(e){return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...o.getBlockProperties({block:e.block,context:e.context}),...o.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}function X(e){return t.jsxs(t.Fragment,{children:[" ",e.hasChildren?t.jsx(t.Fragment,{children:t.jsxs(e.Wrapper,{...o.getBlockProperties({block:e.block,context:e.context}),...o.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0}),children:[" ",e.children," "]})}):t.jsx(t.Fragment,{children:t.jsx(e.Wrapper,{...o.getBlockProperties({block:e.block,context:e.context}),...o.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function Y(e){function n(){var s;return"builder-blocks"+((s=e.blocks)!=null&&s.length?"":" no-blocks")}function r(){var s,h;o.isEditing()&&!((s=e.blocks)!=null&&s.length)&&((h=window.parent)==null||h.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function f(){var s,h;o.isEditing()&&!((s=e.blocks)!=null&&s.length)&&((h=window.parent)==null||h.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:n()+" div-02c7a115","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:s=>r(),onMouseEnter:s=>f(),onKeyPress:s=>r(),children:e.children}),t.jsx("style",{children:`.div-02c7a115 {
42
+ display: flex;
43
+ flex-direction: column;
44
+ align-items: stretch;
45
+ }`})]})}function Q(e){return t.jsx("span",{children:e.children})}function Z(e){var s,h,v,x;function n(){var m;const u=e.image||e.src;if(!u||!(u.match(/builder\.io/)||u.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((m=e.image)!=null&&m.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),o.getSrcSet(u)}else if(e.image&&!e.srcset)return o.getSrcSet(u);return o.getSrcSet(u)}function r(){var b;return(b=n==null?void 0:n())!=null&&b.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function f(){const b={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?b:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[r()?t.jsx(t.Fragment,{children:t.jsx("source",{type:"image/webp",srcSet:r()})}):null,t.jsx("img",{loading:"lazy",alt:e.altText,role:e.altText?"presentation":void 0,style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...f()},className:"builder-image"+(e.className?" "+e.className:"")+" img-497e0136",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((h=(s=e.builderBlock)==null?void 0:s.children)!=null&&h.length&&e.fitContent)?t.jsx(t.Fragment,{children:t.jsx("div",{className:"builder-image-sizer div-497e0136",style:{paddingTop:e.aspectRatio*100+"%"}})}):null,(x=(v=e.builderBlock)==null?void 0:v.children)!=null&&x.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&e.children?t.jsx(t.Fragment,{children:t.jsx("div",{className:"div-497e0136-2",children:e.children})}):null]}),t.jsx("style",{children:`.img-497e0136 {
46
+ opacity: 1;
47
+ transition: opacity 0.2s ease-in-out;
48
+ }.div-497e0136 {
49
+ width: 100%;
50
+ pointer-events: none;
51
+ font-size: 0;
52
+ }.div-497e0136-2 {
53
+ display: flex;
54
+ flex-direction: column;
55
+ align-items: stretch;
56
+ position: absolute;
57
+ top: 0;
58
+ left: 0;
59
+ width: 100%;
60
+ height: 100%;
61
+ }`})]})}function p(e){return t.jsx("section",{...e.attributes,style:{width:"100%",alignSelf:"stretch",flexGrow:1,boxSizing:"border-box",maxWidth:e.maxWidth||1200,display:"flex",flexDirection:"column",alignItems:"stretch",marginLeft:"auto",marginRight:"auto"},children:e.children})}function ee(e){var f;function n(){return{...e.autoPlay===!0?{autoPlay:!0}:{},...e.muted===!0?{muted:!0}:{},...e.controls===!0?{controls:!0}:{},...e.loop===!0?{loop:!0}:{},...e.playsInline===!0?{playsInline:!0}:{}}}function r(){return{...e.attributes,...n()}}return t.jsx("video",{...r(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(f=e.attributes)==null?void 0:f.style,objectFit:e.fit,objectPosition:e.position,borderRadius:1},src:e.video||"no-src",poster:e.posterImage})}function te(e){const n=l.useRef(null),[r,f]=l.useState(()=>[]),[s,h]=l.useState(()=>[]),[v,x]=l.useState(()=>!1);function b(){if(!n.current||!n.current.getElementsByTagName)return;const u=n.current.getElementsByTagName("script");for(let m=0;m<u.length;m++){const y=u[m];if(y.src&&!r.includes(y.src)){r.push(y.src);const k=document.createElement("script");k.async=!0,k.src=y.src,document.head.appendChild(k)}else if(o.isJsScript(y)&&!s.includes(y.innerText))try{s.push(y.innerText),new Function(y.innerText)()}catch(k){console.warn("`Embed`: Error running script:",k)}}}return l.useEffect(()=>{n.current&&!v&&(x(!0),b())},[n.current,v]),t.jsx("div",{className:"builder-embed",ref:n,dangerouslySetInnerHTML:{__html:e.content}})}function ne(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},o.isEditing()&&e.imgSrc||"default-key")}function ie(e){const n=l.useRef(null),[r,f]=l.useState(()=>[]),[s,h]=l.useState(()=>[]);return l.useEffect(()=>{var x;if(!((x=n.current)!=null&&x.getElementsByTagName)||typeof window>"u")return;const v=n.current.getElementsByTagName("script");for(let b=0;b<v.length;b++){const u=v[b];if(u.src){if(r.includes(u.src))continue;r.push(u.src);const m=document.createElement("script");m.async=!0,m.src=u.src,document.head.appendChild(m)}else if(!u.type||["text/javascript","application/javascript","application/ecmascript"].includes(u.type)){if(s.includes(u.innerText))continue;try{s.push(u.innerText),new Function(u.innerText)()}catch(m){console.warn("`CustomCode`: Error running script:",m)}}}},[]),t.jsx("div",{ref:n,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}const ce=l.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{}});function oe(e){var T,F,N,B,_;const n=l.useRef(null),[r,f]=l.useState(()=>0);function s(i){var a,d,g,S,L;const c={...e.builderContextSignal.content,...i,data:{...(a=e.builderContextSignal.content)==null?void 0:a.data,...i==null?void 0:i.data},meta:{...(d=e.builderContextSignal.content)==null?void 0:d.meta,...i==null?void 0:i.meta,breakpoints:((g=i==null?void 0:i.meta)==null?void 0:g.breakpoints)||((L=(S=e.builderContextSignal.content)==null?void 0:S.meta)==null?void 0:L.breakpoints)}};D.postPreviewContent({value:c,key:c.id}).then(()=>{M.refresh()})}l.useState(()=>0);const[h,v]=l.useState(()=>!1);function x(i){var a;const{data:c}=i;if(c)switch(c.type){case"builder.configureSdk":{const d=c.data,{breakpoints:g,contentId:S}=d;if(!S||S!==((a=e.builderContextSignal.content)==null?void 0:a.id))return;g&&s({meta:{breakpoints:g}}),f(r+1);break}case"builder.contentUpdate":{const d=c.data,g=d.key||d.alias||d.entry||d.modelName,S=d.data;g===e.model&&(s(S),f(r+1));break}}}function b(){var c,a;const i=(a=(c=e.builderContextSignal.content)==null?void 0:c.data)==null?void 0:a.jsCode;i&&o.evaluate({code:i,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[u,m]=l.useState(()=>({})),[y,k]=l.useState(()=>!1);function E(i){var c,a;if(e.builderContextSignal.content){const d=(c=e.builderContextSignal.content)==null?void 0:c.testVariationId,g=(a=e.builderContextSignal.content)==null?void 0:a.id;o._track({type:"click",canTrack:o.getDefaultCanTrack(e.canTrack),contentId:g,apiKey:e.apiKey,variationId:d!==g?d:void 0,...o.getInteractionPropertiesForEvent(i),unique:!y})}y||k(!0)}function j(i){return i.replace(/{{([^}]+)}}/g,(c,a)=>o.evaluate({code:a,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function w({url:i,key:c}){o.fetch(i).then(a=>a.json()).then(a=>{var g,S;const d={...e.builderContextSignal.rootState,[c]:a};(S=(g=e.builderContextSignal).rootSetState)==null||S.call(g,d),u[c]=!0}).catch(a=>{console.error("error fetching dynamic data",i,a)})}function R(){var c,a;const i=((a=(c=e.builderContextSignal.content)==null?void 0:c.data)==null?void 0:a.httpRequests)??{};Object.entries(i).forEach(([d,g])=>{if(g&&(!u[d]||o.isEditing())){const S=j(g);w({url:S,key:d})}})}function C(){o.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:o.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function I(i){f(r+1),window.addEventListener("message",x),o.registerInsertMenu(),o.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(c=>{var d;const a=o.createRegisterComponentMessage(c);(d=window.parent)==null||d.postMessage(a,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",C)}function P(i){const c=new URL(location.href).searchParams,a=c.get("builder.preview"),d=c.get(`builder.preview.${a}`),g=c.get("apiKey")||c.get("builder.space");a===e.model&&g===e.apiKey&&(!e.content||d===e.content.id)&&o.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(S=>{S&&s(S)})}const M=U.useRouter();return l.useEffect(()=>{var i;return(i=n.current)==null||i.addEventListener("initeditingbldr",I),()=>{var c;return(c=n.current)==null?void 0:c.removeEventListener("initeditingbldr",I)}},[]),l.useEffect(()=>{var i;return(i=n.current)==null||i.addEventListener("initpreviewingbldr",P),()=>{var c;return(c=n.current)==null?void 0:c.removeEventListener("initpreviewingbldr",P)}},[]),l.useEffect(()=>{var i,c;if(o.isBrowser()){if(o.isEditing()&&n.current&&n.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&o.getDefaultCanTrack(e.canTrack)){const d=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,g=(c=e.builderContextSignal.content)==null?void 0:c.id,S=e.apiKey;o._track({type:"impression",canTrack:!0,contentId:g,apiKey:S,variationId:d!==g?d:void 0})}o.isPreviewing()&&n.current}},[]),l.useEffect(()=>{e.apiKey||o.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),b(),R(),C()},[]),l.useEffect(()=>{},[e.content]),l.useEffect(()=>{o.isBrowser()&&(window.removeEventListener("message",x),window.addEventListener("message",x))},[h]),l.useEffect(()=>{b()},[(F=(T=e.builderContextSignal.content)==null?void 0:T.data)==null?void 0:F.jsCode,e.builderContextSignal.rootState]),l.useEffect(()=>{R()},[(B=(N=e.builderContextSignal.content)==null?void 0:N.data)==null?void 0:B.httpRequests]),l.useEffect(()=>{C()},[e.builderContextSignal.rootState]),l.useEffect(()=>()=>{o.isBrowser()&&(window.removeEventListener("message",x),window.removeEventListener("builder:component:stateChangeListenerActivated",C))},[]),t.jsx(ce.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(t.Fragment,{children:l.createElement("div",{key:r,ref:n,onClick:i=>E(i),"builder-content-id":(_=e.builderContextSignal.content)==null?void 0:_.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},className:e.classNameProp},e.children)}):null})}exports.BlockWrapper=X;exports.BlocksWrapper=Y;exports.Button=W;exports.CustomCode=ie;exports.Embed=te;exports.EnableEditor=oe;exports.FragmentComponent=Q;exports.Image=Z;exports.ImgComponent=ne;exports.InteractiveElement=G;exports.SectionComponent=p;exports.Video=ee;exports.evaluator=J;