@builder.io/sdk-react-nextjs 0.18.2 → 0.18.8
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/custom-code/custom-code.cjs +1 -1
- package/lib/browser/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/browser/blocks/embed/embed.cjs +1 -1
- package/lib/browser/blocks/embed/embed.mjs +16 -15
- package/lib/browser/blocks/image/component-info.cjs +1 -1
- package/lib/browser/blocks/image/component-info.mjs +12 -8
- package/lib/browser/blocks/image/image.cjs +4 -4
- package/lib/browser/blocks/image/image.mjs +14 -13
- package/lib/browser/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/browser/components/blocks/blocks-wrapper.mjs +18 -16
- package/lib/browser/components/content-variants/helpers.cjs +9 -9
- package/lib/browser/components/content-variants/helpers.mjs +16 -16
- package/lib/browser/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/browser/components/content-variants/inlined-fns.mjs +5 -2
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/edge/blocks/custom-code/custom-code.cjs +1 -1
- package/lib/edge/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/edge/blocks/embed/embed.cjs +1 -1
- package/lib/edge/blocks/embed/embed.mjs +16 -15
- package/lib/edge/blocks/image/component-info.cjs +1 -1
- package/lib/edge/blocks/image/component-info.mjs +12 -8
- package/lib/edge/blocks/image/image.cjs +4 -4
- package/lib/edge/blocks/image/image.mjs +14 -13
- package/lib/edge/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/edge/components/blocks/blocks-wrapper.mjs +18 -16
- package/lib/edge/components/content-variants/helpers.cjs +9 -9
- package/lib/edge/components/content-variants/helpers.mjs +16 -16
- package/lib/edge/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/edge/components/content-variants/inlined-fns.mjs +5 -2
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/node/blocks/custom-code/custom-code.cjs +1 -1
- package/lib/node/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/node/blocks/embed/embed.cjs +1 -1
- package/lib/node/blocks/embed/embed.mjs +16 -15
- package/lib/node/blocks/image/component-info.cjs +1 -1
- package/lib/node/blocks/image/component-info.mjs +12 -8
- package/lib/node/blocks/image/image.cjs +4 -4
- package/lib/node/blocks/image/image.mjs +14 -13
- package/lib/node/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/node/components/blocks/blocks-wrapper.mjs +18 -16
- package/lib/node/components/content-variants/helpers.cjs +9 -9
- package/lib/node/components/content-variants/helpers.mjs +16 -16
- package/lib/node/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/node/components/content-variants/inlined-fns.mjs +5 -2
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/package.json +1 -1
- package/types/cjs/blocks/image/image.types.d.ts +1 -0
- package/types/cjs/components/content-variants/inlined-fns.d.ts +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/esm/blocks/image/image.types.d.ts +1 -0
- package/types/esm/components/content-variants/inlined-fns.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IMAGE_FILE_TYPES as
|
|
2
|
-
const
|
|
1
|
+
import { IMAGE_FILE_TYPES as p } from "../../constants/file-types.mjs";
|
|
2
|
+
const c = {
|
|
3
3
|
name: "Image",
|
|
4
4
|
static: !0,
|
|
5
5
|
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
|
|
@@ -14,19 +14,19 @@ const g = {
|
|
|
14
14
|
name: "image",
|
|
15
15
|
type: "file",
|
|
16
16
|
bubble: !0,
|
|
17
|
-
allowedFileTypes:
|
|
17
|
+
allowedFileTypes: p,
|
|
18
18
|
required: !0,
|
|
19
19
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
20
20
|
onChange: (t) => {
|
|
21
21
|
t.delete("srcset"), t.delete("noWebp");
|
|
22
|
-
function
|
|
22
|
+
function d(e, o = 6e4) {
|
|
23
23
|
return new Promise((u, n) => {
|
|
24
24
|
const i = document.createElement("img");
|
|
25
25
|
let l = !1;
|
|
26
26
|
i.onload = () => {
|
|
27
27
|
l = !0, u(i);
|
|
28
|
-
}, i.addEventListener("error", (
|
|
29
|
-
console.warn("Image load failed",
|
|
28
|
+
}, i.addEventListener("error", (h) => {
|
|
29
|
+
console.warn("Image load failed", h.error), n(h.error);
|
|
30
30
|
}), i.src = e, setTimeout(() => {
|
|
31
31
|
l || n(new Error("Image load timed out"));
|
|
32
32
|
}, o);
|
|
@@ -39,7 +39,7 @@ const g = {
|
|
|
39
39
|
if (fetch(a).then((e) => e.blob()).then((e) => {
|
|
40
40
|
e.type.includes("svg") && t.set("noWebp", !0);
|
|
41
41
|
}), a && (!r || r === 0.7041))
|
|
42
|
-
return
|
|
42
|
+
return d(a).then((e) => {
|
|
43
43
|
const o = t.get("aspectRatio");
|
|
44
44
|
t.get("image") === a && (!o || o === 0.7041) && e.width && e.height && (t.set("aspectRatio", s(e.height / e.width)), t.set("height", e.height), t.set("width", e.width));
|
|
45
45
|
});
|
|
@@ -66,6 +66,10 @@ const g = {
|
|
|
66
66
|
name: "altText",
|
|
67
67
|
type: "string",
|
|
68
68
|
helperText: "Text to display when the user has images off"
|
|
69
|
+
}, {
|
|
70
|
+
name: "title",
|
|
71
|
+
type: "string",
|
|
72
|
+
helperText: "Text to display when hovering over the asset"
|
|
69
73
|
}, {
|
|
70
74
|
name: "height",
|
|
71
75
|
type: "number",
|
|
@@ -109,5 +113,5 @@ const g = {
|
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
export {
|
|
112
|
-
|
|
116
|
+
c as componentInfo
|
|
113
117
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use client";"use strict";const t=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";const t=require("react/jsx-runtime"),l=require("./image.helpers.cjs");function f(e){var s,r,u,d,o,g;function n(){var h;const i=e.image||e.src;if(!i||!(typeof i=="string"&&(i.match(/builder\.io/)||i.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((h=e.image)!=null&&h.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),l.getSrcSet(i)}else if(e.image&&!e.srcset)return l.getSrcSet(i);return l.getSrcSet(i)}}function a(){var c;return(c=n==null?void 0:n())!=null&&c.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function m(){const c={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?c:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[a()?t.jsx("source",{type:"image/webp",srcSet:a()}):null,t.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,title:e.title,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...m()},className:"builder-image"+(e.className?" "+e.className:"")+" img-0525a549",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(s=e.builderBlock)==null?void 0:s.children)!=null&&r.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-0525a549",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(d=(u=e.builderBlock)==null?void 0:u.children)!=null&&d.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((g=(o=e.builderBlock)==null?void 0:o.children)!=null&&g.length)?t.jsx("div",{className:"div-0525a549-2",children:e.children}):null]}),t.jsx("style",{children:`.img-0525a549 {
|
|
2
2
|
opacity: 1;
|
|
3
3
|
transition: opacity 0.2s ease-in-out;
|
|
4
|
-
}.div-
|
|
4
|
+
}.div-0525a549 {
|
|
5
5
|
width: 100%;
|
|
6
6
|
pointer-events: none;
|
|
7
7
|
font-size: 0;
|
|
8
|
-
}.div-
|
|
8
|
+
}.div-0525a549-2 {
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
align-items: stretch;
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
left: 0;
|
|
15
15
|
width: 100%;
|
|
16
16
|
height: 100%;
|
|
17
|
-
}`})]})}module.exports=
|
|
17
|
+
}`})]})}module.exports=f;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { jsxs as a, Fragment as c, jsx as t } from "react/jsx-runtime";
|
|
3
3
|
import { getSrcSet as o } from "./image.helpers.mjs";
|
|
4
4
|
function x(e) {
|
|
5
|
-
var d,
|
|
5
|
+
var d, u, s, g, h, m;
|
|
6
6
|
function n() {
|
|
7
|
-
var
|
|
7
|
+
var f;
|
|
8
8
|
const i = e.image || e.src;
|
|
9
9
|
if (!i || // We can auto add srcset for cdn.builder.io and shopify
|
|
10
10
|
// images, otherwise you can supply this prop manually
|
|
11
11
|
!(typeof i == "string" && (i.match(/builder\.io/) || i.match(/cdn\.shopify\.com/))))
|
|
12
12
|
return e.srcset;
|
|
13
13
|
if (!e.noWebp) {
|
|
14
|
-
if (e.srcset && ((
|
|
14
|
+
if (e.srcset && ((f = e.image) != null && f.includes("builder.io/api/v1/image"))) {
|
|
15
15
|
if (!e.srcset.includes(e.image.split("?")[0]))
|
|
16
16
|
return console.debug("Removed given srcset"), o(i);
|
|
17
17
|
} else if (e.image && !e.srcset)
|
|
@@ -23,7 +23,7 @@ function x(e) {
|
|
|
23
23
|
var l;
|
|
24
24
|
return (l = n == null ? void 0 : n()) != null && l.match(/builder\.io/) && !e.noWebp ? n().replace(/\?/g, "?format=webp&") : "";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function b() {
|
|
27
27
|
const l = {
|
|
28
28
|
position: "absolute",
|
|
29
29
|
height: "100%",
|
|
@@ -43,39 +43,40 @@ function x(e) {
|
|
|
43
43
|
loading: e.highPriority ? "eager" : "lazy",
|
|
44
44
|
fetchPriority: e.highPriority ? "high" : "auto",
|
|
45
45
|
alt: e.altText,
|
|
46
|
+
title: e.title,
|
|
46
47
|
role: e.altText ? void 0 : "presentation",
|
|
47
48
|
style: {
|
|
48
49
|
objectPosition: e.backgroundPosition || "center",
|
|
49
50
|
objectFit: e.backgroundSize || "cover",
|
|
50
|
-
...
|
|
51
|
+
...b()
|
|
51
52
|
},
|
|
52
|
-
className: "builder-image" + (e.className ? " " + e.className : "") + " img-
|
|
53
|
+
className: "builder-image" + (e.className ? " " + e.className : "") + " img-0525a549",
|
|
53
54
|
src: e.image,
|
|
54
55
|
srcSet: n(),
|
|
55
56
|
sizes: e.sizes
|
|
56
57
|
}
|
|
57
58
|
)
|
|
58
59
|
] }),
|
|
59
|
-
e.aspectRatio && !((
|
|
60
|
+
e.aspectRatio && !((u = (d = e.builderBlock) == null ? void 0 : d.children) != null && u.length && e.fitContent) ? /* @__PURE__ */ t(
|
|
60
61
|
"div",
|
|
61
62
|
{
|
|
62
|
-
className: "builder-image-sizer div-
|
|
63
|
+
className: "builder-image-sizer div-0525a549",
|
|
63
64
|
style: {
|
|
64
65
|
paddingTop: e.aspectRatio * 100 + "%"
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
) : null,
|
|
68
|
-
(g = (
|
|
69
|
-
!e.fitContent && ((m = (h = e.builderBlock) == null ? void 0 : h.children) != null && m.length) ? /* @__PURE__ */ t("div", { className: "div-
|
|
69
|
+
(g = (s = e.builderBlock) == null ? void 0 : s.children) != null && g.length && e.fitContent ? /* @__PURE__ */ t(c, { children: e.children }) : null,
|
|
70
|
+
!e.fitContent && ((m = (h = e.builderBlock) == null ? void 0 : h.children) != null && m.length) ? /* @__PURE__ */ t("div", { className: "div-0525a549-2", children: e.children }) : null
|
|
70
71
|
] }),
|
|
71
|
-
/* @__PURE__ */ t("style", { children: `.img-
|
|
72
|
+
/* @__PURE__ */ t("style", { children: `.img-0525a549 {
|
|
72
73
|
opacity: 1;
|
|
73
74
|
transition: opacity 0.2s ease-in-out;
|
|
74
|
-
}.div-
|
|
75
|
+
}.div-0525a549 {
|
|
75
76
|
width: 100%;
|
|
76
77
|
pointer-events: none;
|
|
77
78
|
font-size: 0;
|
|
78
|
-
}.div-
|
|
79
|
+
}.div-0525a549-2 {
|
|
79
80
|
display: flex;
|
|
80
81
|
flex-direction: column;
|
|
81
82
|
align-items: stretch;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const a=require("react/jsx-runtime"),i=require("react"),r=require("../../functions/is-editing.cjs");function d(e){const c=i.useRef(null);i.useState(()=>!1);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function s(){if(!e.path)return;const t="this.",n="component.options.";return e.path.startsWith(t)?e.path.replace(t,""):e.path.startsWith(n)?e.path:`${n}${e.path||""}`}function l(){var t,n;r.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:s()}},"*"))}function u(){var t,n;r.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:s()}},"*"))}return i.useEffect(()=>{},[]),i.useEffect(()=>{},[e.blocks]),a.jsxs(a.Fragment,{children:[a.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-2b05e766","builder-path":s(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>l(),onMouseEnter:t=>u(),onKeyPress:t=>l(),...e.BlocksWrapperProps,children:e.children}),a.jsx("style",{children:`.props-blocks-wrapper-2b05e766 {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: stretch;
|
|
5
|
-
}`})]})}module.exports=
|
|
5
|
+
}`})]})}module.exports=d;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { isEditing as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
2
|
+
import { jsxs as h, Fragment as f, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as u, useState as k, useEffect as i } from "react";
|
|
4
|
+
import { isEditing as s } from "../../functions/is-editing.mjs";
|
|
5
|
+
function y(e) {
|
|
6
|
+
const c = u(null);
|
|
7
|
+
k(() => !1);
|
|
8
|
+
function o() {
|
|
8
9
|
var t;
|
|
9
10
|
return [
|
|
10
11
|
"builder-blocks",
|
|
@@ -20,7 +21,7 @@ function k(e) {
|
|
|
20
21
|
}
|
|
21
22
|
function l() {
|
|
22
23
|
var t, n;
|
|
23
|
-
|
|
24
|
+
s() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
24
25
|
{
|
|
25
26
|
type: "builder.clickEmptyBlocks",
|
|
26
27
|
data: {
|
|
@@ -31,9 +32,9 @@ function k(e) {
|
|
|
31
32
|
"*"
|
|
32
33
|
));
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function d() {
|
|
35
36
|
var t, n;
|
|
36
|
-
|
|
37
|
+
s() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
37
38
|
{
|
|
38
39
|
type: "builder.hoverEmptyBlocks",
|
|
39
40
|
data: {
|
|
@@ -44,24 +45,25 @@ function k(e) {
|
|
|
44
45
|
"*"
|
|
45
46
|
));
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
-
}, []),
|
|
48
|
+
return i(() => {
|
|
49
|
+
}, []), i(() => {
|
|
50
|
+
}, [e.blocks]), /* @__PURE__ */ h(f, { children: [
|
|
49
51
|
/* @__PURE__ */ r(
|
|
50
52
|
e.BlocksWrapper,
|
|
51
53
|
{
|
|
52
|
-
ref:
|
|
53
|
-
className:
|
|
54
|
+
ref: c,
|
|
55
|
+
className: o() + " props-blocks-wrapper-2b05e766",
|
|
54
56
|
"builder-path": a(),
|
|
55
57
|
"builder-parent-id": e.parent,
|
|
56
58
|
style: e.styleProp,
|
|
57
59
|
onClick: (t) => l(),
|
|
58
|
-
onMouseEnter: (t) =>
|
|
60
|
+
onMouseEnter: (t) => d(),
|
|
59
61
|
onKeyPress: (t) => l(),
|
|
60
62
|
...e.BlocksWrapperProps,
|
|
61
63
|
children: e.children
|
|
62
64
|
}
|
|
63
65
|
),
|
|
64
|
-
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-
|
|
66
|
+
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-2b05e766 {
|
|
65
67
|
display: flex;
|
|
66
68
|
flex-direction: column;
|
|
67
69
|
align-items: stretch;
|
|
@@ -69,5 +71,5 @@ function k(e) {
|
|
|
69
71
|
] });
|
|
70
72
|
}
|
|
71
73
|
export {
|
|
72
|
-
|
|
74
|
+
y as default
|
|
73
75
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
window.${
|
|
3
|
-
window.${
|
|
4
|
-
`,
|
|
5
|
-
window.${
|
|
6
|
-
"${t}",${JSON.stringify(i)}, ${
|
|
7
|
-
)`,
|
|
8
|
-
"${t}", "${i}", ${
|
|
9
|
-
)`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/target.cjs"),S=require("../../functions/is-browser.cjs"),r=require("./inlined-fns.cjs"),s="builderIoAbTest",a="builderIoRenderContent",n=i=>Object.values((i==null?void 0:i.variations)||{}).map(t=>({...t,testVariationId:t.id,id:i==null?void 0:i.id})),d=({canTrack:i,content:t})=>!(!(n(t).length>0)||!i||S.isBrowser()),I=i=>i==="react"||i==="reactNative",T=e.TARGET==="angular",o=I(e.TARGET),c=()=>`
|
|
2
|
+
window.${s} = ${r.UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
3
|
+
window.${a} = ${r.UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
4
|
+
`,g=(i,t)=>`
|
|
5
|
+
window.${s}(
|
|
6
|
+
"${t}",${JSON.stringify(i)}, ${o}, ${T}
|
|
7
|
+
)`,l=({contentId:i,variationId:t})=>`window.${a}(
|
|
8
|
+
"${t}", "${i}", ${o}
|
|
9
|
+
)`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=c;exports.getUpdateCookieAndStylesScript=g;exports.getUpdateVariantVisibilityScript=l;exports.getVariants=n;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { TARGET as
|
|
1
|
+
import { TARGET as t } from "../../constants/target.mjs";
|
|
2
2
|
import { isBrowser as o } from "../../functions/is-browser.mjs";
|
|
3
|
-
import { UPDATE_COOKIES_AND_STYLES_SCRIPT as
|
|
4
|
-
const
|
|
3
|
+
import { UPDATE_COOKIES_AND_STYLES_SCRIPT as n, UPDATE_VARIANT_VISIBILITY_SCRIPT as I } from "./inlined-fns.mjs";
|
|
4
|
+
const s = "builderIoAbTest", a = "builderIoRenderContent", S = (i) => Object.values((i == null ? void 0 : i.variations) || {}).map((r) => ({
|
|
5
5
|
...r,
|
|
6
6
|
testVariationId: r.id,
|
|
7
7
|
id: i == null ? void 0 : i.id
|
|
8
|
-
})),
|
|
8
|
+
})), V = ({
|
|
9
9
|
canTrack: i,
|
|
10
10
|
content: r
|
|
11
|
-
}) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative",
|
|
12
|
-
window.${t} = ${I}
|
|
11
|
+
}) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative", d = t === "angular", e = T(t), g = () => `
|
|
13
12
|
window.${s} = ${n}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
window.${a} = ${I}
|
|
14
|
+
`, u = (i, r) => `
|
|
15
|
+
window.${s}(
|
|
16
|
+
"${r}",${JSON.stringify(i)}, ${e}, ${d}
|
|
17
|
+
)`, E = ({
|
|
18
18
|
contentId: i,
|
|
19
19
|
variationId: r
|
|
20
|
-
}) => `window.${
|
|
21
|
-
"${r}", "${i}", ${
|
|
20
|
+
}) => `window.${a}(
|
|
21
|
+
"${r}", "${i}", ${e}
|
|
22
22
|
)`;
|
|
23
23
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
V as checkShouldRenderVariants,
|
|
25
|
+
g as getInitVariantsFnsScriptString,
|
|
26
|
+
u as getUpdateCookieAndStylesScript,
|
|
27
|
+
E as getUpdateVariantVisibilityScript,
|
|
28
28
|
S as getVariants
|
|
29
29
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
|
|
2
2
|
function getAndSetVariantId() {
|
|
3
3
|
function setCookie(name, value, days) {
|
|
4
4
|
let expires = '';
|
|
@@ -40,7 +40,10 @@
|
|
|
40
40
|
return contentId;
|
|
41
41
|
}
|
|
42
42
|
const winningVariantId = getAndSetVariantId();
|
|
43
|
-
|
|
43
|
+
let styleEl = document.currentScript?.previousElementSibling;
|
|
44
|
+
if (isAngularSDK) {
|
|
45
|
+
styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
|
|
46
|
+
}
|
|
44
47
|
if (isHydrationTarget) {
|
|
45
48
|
styleEl.remove();
|
|
46
49
|
const thisScriptEl = document.currentScript;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
|
|
1
|
+
const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
|
|
2
2
|
function getAndSetVariantId() {
|
|
3
3
|
function setCookie(name, value, days) {
|
|
4
4
|
let expires = '';
|
|
@@ -40,7 +40,10 @@ const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarge
|
|
|
40
40
|
return contentId;
|
|
41
41
|
}
|
|
42
42
|
const winningVariantId = getAndSetVariantId();
|
|
43
|
-
|
|
43
|
+
let styleEl = document.currentScript?.previousElementSibling;
|
|
44
|
+
if (isAngularSDK) {
|
|
45
|
+
styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
|
|
46
|
+
}
|
|
44
47
|
if (isHydrationTarget) {
|
|
45
48
|
styleEl.remove();
|
|
46
49
|
const thisScriptEl = document.currentScript;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.8";exports.SDK_VERSION=e;
|
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.18.
|
|
4
|
+
"version": "0.18.8",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* For more information on how this works,
|
|
11
11
|
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
|
|
12
12
|
*/
|
|
13
|
-
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n
|
|
13
|
+
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
14
14
|
export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
1
|
+
export declare const SDK_VERSION = "0.18.8";
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* For more information on how this works,
|
|
11
11
|
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
|
|
12
12
|
*/
|
|
13
|
-
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n
|
|
13
|
+
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
14
14
|
export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
1
|
+
export declare const SDK_VERSION = "0.18.8";
|