@builder.io/sdk-react 2.0.25 → 2.0.27
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-exports.cjs +5 -5
- package/lib/browser/blocks-exports.mjs +47 -41
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/server-entry-b2eed856.cjs +2 -0
- package/lib/browser/{server-entry-350f7ecc.js → server-entry-fea90db1.js} +138 -135
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-e2aeca0a.js → accordion-6557fd47.js} +1 -1
- package/lib/edge/{accordion-d14d05aa.cjs → accordion-c7ebd14b.cjs} +1 -1
- package/lib/edge/{blocks-5a60a8fa.cjs → blocks-00d9b985.cjs} +1 -1
- package/lib/edge/{blocks-9a763eda.js → blocks-b7b78f6f.js} +3 -3
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-265653d5.js → button-07555543.js} +2 -2
- package/lib/edge/{button-6ab0c490.cjs → button-ca865fd7.cjs} +1 -1
- package/lib/edge/{columns-449335a4.cjs → columns-1d6d0f14.cjs} +1 -1
- package/lib/edge/{columns-346d4ab7.js → columns-a8fb6e6e.js} +4 -4
- package/lib/edge/{content-variants-71459280.cjs → content-variants-5de0e605.cjs} +8 -8
- package/lib/edge/{content-variants-bdb3d738.js → content-variants-f7aadfcc.js} +51 -45
- package/lib/edge/{evaluate-db1f9237.cjs → evaluate-2596ffe5.cjs} +1 -1
- package/lib/edge/{evaluate-be86a5d8.js → evaluate-3fbf8291.js} +1 -1
- package/lib/edge/{form-90310cab.cjs → form-7f214547.cjs} +1 -1
- package/lib/edge/{form-41305e00.js → form-be8d48c0.js} +4 -4
- package/lib/edge/{get-class-prop-name-711d58eb.cjs → get-class-prop-name-00a9606b.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-b49b7684.js → get-class-prop-name-35810f43.js} +1 -1
- package/lib/edge/{img-a75bf17b.js → img-1c578e3b.js} +1 -1
- package/lib/edge/{img-1ab7ba48.cjs → img-3eab09f2.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-137d07aa.cjs → input-0d7c1c27.cjs} +1 -1
- package/lib/edge/{input-6c50146c.js → input-9c1e8a98.js} +1 -1
- package/lib/edge/{select-55d2c8fa.cjs → select-c58218b7.cjs} +1 -1
- package/lib/edge/{select-b6c2fdd5.js → select-fd1e4221.js} +1 -1
- package/lib/edge/{server-entry-e914f16e.js → server-entry-72a543d1.js} +138 -135
- package/lib/edge/server-entry-f03cbcfe.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-8d3b7707.cjs → slot-864f8ee7.cjs} +1 -1
- package/lib/edge/{slot-84e40920.js → slot-ec9f4a5e.js} +4 -4
- package/lib/edge/{symbol-468348d8.cjs → symbol-68340c52.cjs} +1 -1
- package/lib/edge/{symbol-7436ff06.js → symbol-78fe0b05.js} +2 -2
- package/lib/edge/{tabs-802a32f0.cjs → tabs-b0f30ed3.cjs} +1 -1
- package/lib/edge/{tabs-65d455da.js → tabs-c847b763.js} +4 -4
- package/lib/edge/{text-423e3303.js → text-5ed7f583.js} +2 -2
- package/lib/edge/{text-450bf7e4.cjs → text-ff0134a1.cjs} +1 -1
- package/lib/node/blocks-exports.cjs +21 -21
- package/lib/node/blocks-exports.mjs +53 -46
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +26 -25
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +6 -5
- package/lib/node/server-entry-b19b6f07.cjs +2 -0
- package/lib/node/{server-entry-569f32b2.js → server-entry-bac0a183.js} +138 -135
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-3f610831.js → setIvm-22947995.js} +45 -57
- package/lib/node/setIvm-e38cb38e.cjs +48 -0
- package/lib/node/setIvm.cjs +1 -0
- package/lib/node/setIvm.mjs +5 -0
- package/lib/node/should-force-browser-runtime-in-node-0d7217c7.cjs +1 -0
- package/lib/node/should-force-browser-runtime-in-node-5458ba48.js +17 -0
- package/package.json +8 -2
- package/types/components/content/components/enable-editor.d.ts +1 -1
- package/types/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/evaluate/node-runtime/setIvm.d.ts +1 -0
- package/types/functions/get-content/types.d.ts +4 -0
- package/types/functions/track/index.d.ts +3 -1
- package/lib/browser/server-entry-f8b08c1e.cjs +0 -2
- package/lib/edge/server-entry-ae44ef40.cjs +0 -2
- package/lib/node/server-entry-781dde88.cjs +0 -2
- package/lib/node/should-force-browser-runtime-in-node-13070d3a.cjs +0 -48
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as l, Fragment as w, jsxs as V } from "react/jsx-runtime";
|
|
3
|
-
import { TARGET as D, isEditing as W, isBrowser as L, getUserAttributes as Ue, checkIsDefined as q, logger as z, isPreviewing as ve, registerInsertMenu as
|
|
3
|
+
import { TARGET as D, isEditing as W, isBrowser as L, getUserAttributes as Ue, checkIsDefined as q, logger as z, isPreviewing as ve, registerInsertMenu as He, setupBrowserForEditing as je, createRegisterComponentMessage as Me, getDefaultCanTrack as K, _track as le, fetchOneEntry as Se, createEditorListener as _e, serializeIncludingFunctions as se, handleABTestingSync as qe } from "./server-entry-fea90db1.js";
|
|
4
4
|
import { createContext as ke, useEffect as B, useState as T, useRef as $, useContext as ce, createElement as Ce } from "react";
|
|
5
5
|
const Ke = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), ze = (e) => typeof e == "string" && Ke.has(e.toLowerCase());
|
|
6
6
|
function ie(e) {
|
|
7
7
|
return /* @__PURE__ */ l(w, { children: ze(e.TagName) ? /* @__PURE__ */ l(w, { children: /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes }) }) : /* @__PURE__ */ l(w, { children: typeof e.TagName == "string" ? /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) : /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) }) });
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const H = () => {
|
|
10
10
|
switch (D) {
|
|
11
11
|
case "react":
|
|
12
12
|
case "reactNative":
|
|
@@ -24,7 +24,7 @@ function Je(e) {
|
|
|
24
24
|
function t() {
|
|
25
25
|
return {
|
|
26
26
|
...e.attributes,
|
|
27
|
-
[
|
|
27
|
+
[H()]: `${e.link ? "" : "builder-button"} ${e.attributes[H()] || ""}`,
|
|
28
28
|
...e.link ? {
|
|
29
29
|
href: e.link,
|
|
30
30
|
target: e.openLinkInNewTab ? "_blank" : void 0,
|
|
@@ -382,7 +382,7 @@ const Ve = (e) => Object.entries(e).map(([n, i]) => {
|
|
|
382
382
|
if (typeof i == "string")
|
|
383
383
|
return `${J(n)}: ${i};`;
|
|
384
384
|
}).filter(q), ht = (e) => Ve(e).join(`
|
|
385
|
-
`),
|
|
385
|
+
`), M = ({
|
|
386
386
|
mediaQuery: e,
|
|
387
387
|
className: t,
|
|
388
388
|
styles: n
|
|
@@ -553,17 +553,17 @@ function Ct(e) {
|
|
|
553
553
|
), s = o == null ? void 0 : o.large, d = o == null ? void 0 : o.medium, c = o == null ? void 0 : o.small, h = i.id;
|
|
554
554
|
if (!h)
|
|
555
555
|
return "";
|
|
556
|
-
const b = s ?
|
|
556
|
+
const b = s ? M({
|
|
557
557
|
className: h,
|
|
558
558
|
styles: s
|
|
559
|
-
}) : "", f = d ?
|
|
559
|
+
}) : "", f = d ? M({
|
|
560
560
|
className: h,
|
|
561
561
|
styles: d,
|
|
562
562
|
mediaQuery: ue(
|
|
563
563
|
"medium",
|
|
564
564
|
r
|
|
565
565
|
)
|
|
566
|
-
}) : "", v = c ?
|
|
566
|
+
}) : "", v = c ? M({
|
|
567
567
|
className: h,
|
|
568
568
|
styles: c,
|
|
569
569
|
mediaQuery: ue(
|
|
@@ -574,7 +574,7 @@ function Ct(e) {
|
|
|
574
574
|
let S = "";
|
|
575
575
|
if (g) {
|
|
576
576
|
const k = ((C = (R = g.steps) == null ? void 0 : R[1]) == null ? void 0 : C.styles) || {};
|
|
577
|
-
S =
|
|
577
|
+
S = M({
|
|
578
578
|
className: `${h}:hover`,
|
|
579
579
|
styles: {
|
|
580
580
|
...k,
|
|
@@ -655,7 +655,7 @@ function re({
|
|
|
655
655
|
block: e,
|
|
656
656
|
context: t
|
|
657
657
|
}),
|
|
658
|
-
[
|
|
658
|
+
[H()]: [e.id, "builder-block", e.class, (i = e.properties) == null ? void 0 : i.class].filter(Boolean).join(" ")
|
|
659
659
|
};
|
|
660
660
|
return Et({
|
|
661
661
|
properties: n,
|
|
@@ -764,7 +764,7 @@ function me(e) {
|
|
|
764
764
|
contextValue: e.context
|
|
765
765
|
}),
|
|
766
766
|
children: (i = e.blockChildren) == null ? void 0 : i.map((o) => /* @__PURE__ */ l(
|
|
767
|
-
|
|
767
|
+
j,
|
|
768
768
|
{
|
|
769
769
|
block: o,
|
|
770
770
|
context: e.context,
|
|
@@ -779,7 +779,7 @@ function me(e) {
|
|
|
779
779
|
function fe(e) {
|
|
780
780
|
const [t, n] = T(() => e.repeatContext);
|
|
781
781
|
return /* @__PURE__ */ l(oe.Provider, { value: t, children: /* @__PURE__ */ l(
|
|
782
|
-
|
|
782
|
+
j,
|
|
783
783
|
{
|
|
784
784
|
block: e.block,
|
|
785
785
|
context: t,
|
|
@@ -788,7 +788,7 @@ function fe(e) {
|
|
|
788
788
|
}
|
|
789
789
|
) });
|
|
790
790
|
}
|
|
791
|
-
function
|
|
791
|
+
function j(e) {
|
|
792
792
|
var h, b, f, v;
|
|
793
793
|
function t() {
|
|
794
794
|
return yt({
|
|
@@ -923,7 +923,7 @@ function M(e) {
|
|
|
923
923
|
}
|
|
924
924
|
),
|
|
925
925
|
(b = d()) == null ? void 0 : b.map((g) => /* @__PURE__ */ l(
|
|
926
|
-
|
|
926
|
+
j,
|
|
927
927
|
{
|
|
928
928
|
block: g,
|
|
929
929
|
registeredComponents: e.registeredComponents,
|
|
@@ -1011,7 +1011,7 @@ function F(e) {
|
|
|
1011
1011
|
BlocksWrapper: ((i = e.context) == null ? void 0 : i.BlocksWrapper) || (t == null ? void 0 : t.BlocksWrapper),
|
|
1012
1012
|
BlocksWrapperProps: ((o = e.context) == null ? void 0 : o.BlocksWrapperProps) || (t == null ? void 0 : t.BlocksWrapperProps),
|
|
1013
1013
|
children: e.blocks ? /* @__PURE__ */ l(w, { children: (a = e.blocks) == null ? void 0 : a.map((r) => /* @__PURE__ */ l(
|
|
1014
|
-
|
|
1014
|
+
j,
|
|
1015
1015
|
{
|
|
1016
1016
|
block: r,
|
|
1017
1017
|
linkComponent: e.linkComponent,
|
|
@@ -1133,7 +1133,7 @@ function Ft(e) {
|
|
|
1133
1133
|
...m.link ? {
|
|
1134
1134
|
href: m.link
|
|
1135
1135
|
} : {},
|
|
1136
|
-
[
|
|
1136
|
+
[H()]: "builder-column",
|
|
1137
1137
|
style: Ae(S(y))
|
|
1138
1138
|
};
|
|
1139
1139
|
}
|
|
@@ -1385,7 +1385,7 @@ const Q = {
|
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
1387
|
}]
|
|
1388
|
-
},
|
|
1388
|
+
}, Ht = {
|
|
1389
1389
|
name: "Builder:Accordion",
|
|
1390
1390
|
canHaveChildren: !0,
|
|
1391
1391
|
image: "https://cdn.builder.io/api/v1/image/assets%2FagZ9n5CUKRfbL9t6CaJOyVSK4Es2%2Ffab6c1fd3fe542408cbdec078bca7f35",
|
|
@@ -1450,7 +1450,7 @@ const Q = {
|
|
|
1450
1450
|
builderLinkComponent: !0
|
|
1451
1451
|
}
|
|
1452
1452
|
}, ge = (e) => e.toString();
|
|
1453
|
-
function
|
|
1453
|
+
function jt(e) {
|
|
1454
1454
|
var b;
|
|
1455
1455
|
const [t, n] = T(() => []);
|
|
1456
1456
|
function i() {
|
|
@@ -1573,7 +1573,7 @@ function Mt(e) {
|
|
|
1573
1573
|
) : null
|
|
1574
1574
|
] })) });
|
|
1575
1575
|
}
|
|
1576
|
-
const
|
|
1576
|
+
const Mt = {
|
|
1577
1577
|
name: "Core:Button",
|
|
1578
1578
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
1579
1579
|
defaultStyles: {
|
|
@@ -1609,7 +1609,7 @@ const _t = {
|
|
|
1609
1609
|
shouldReceiveBuilderProps: {
|
|
1610
1610
|
builderLinkComponent: !0
|
|
1611
1611
|
}
|
|
1612
|
-
},
|
|
1612
|
+
}, _t = {
|
|
1613
1613
|
// TODO: ways to statically preprocess JSON for references, functions, etc
|
|
1614
1614
|
name: "Columns",
|
|
1615
1615
|
isRSC: !0,
|
|
@@ -2777,7 +2777,7 @@ function un(e) {
|
|
|
2777
2777
|
...e.attributes,
|
|
2778
2778
|
children: [
|
|
2779
2779
|
e.builderBlock && e.builderBlock.children ? /* @__PURE__ */ l(w, { children: (f = (b = e.builderBlock) == null ? void 0 : b.children) == null ? void 0 : f.map((v, g) => /* @__PURE__ */ l(
|
|
2780
|
-
|
|
2780
|
+
j,
|
|
2781
2781
|
{
|
|
2782
2782
|
block: v,
|
|
2783
2783
|
context: e.builderContext,
|
|
@@ -3268,10 +3268,10 @@ const Tn = () => [{
|
|
|
3268
3268
|
...kn
|
|
3269
3269
|
}], be = () => [{
|
|
3270
3270
|
component: Je,
|
|
3271
|
-
...
|
|
3271
|
+
...Mt
|
|
3272
3272
|
}, {
|
|
3273
3273
|
component: Ft,
|
|
3274
|
-
...
|
|
3274
|
+
..._t
|
|
3275
3275
|
}, {
|
|
3276
3276
|
component: $t,
|
|
3277
3277
|
...qt
|
|
@@ -3294,8 +3294,8 @@ const Tn = () => [{
|
|
|
3294
3294
|
component: Xt,
|
|
3295
3295
|
...Qt
|
|
3296
3296
|
}, {
|
|
3297
|
-
component:
|
|
3298
|
-
...
|
|
3297
|
+
component: jt,
|
|
3298
|
+
...Ht
|
|
3299
3299
|
}, ...Tn()], In = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
|
|
3300
3300
|
function getAndSetVariantId() {
|
|
3301
3301
|
function setCookie(name, value, days) {
|
|
@@ -3386,14 +3386,14 @@ const Tn = () => [{
|
|
|
3386
3386
|
thisScriptEl?.remove();
|
|
3387
3387
|
}
|
|
3388
3388
|
return;
|
|
3389
|
-
}`, $e = "builderIoAbTest", De = "builderIoRenderContent",
|
|
3389
|
+
}`, $e = "builderIoAbTest", De = "builderIoRenderContent", _ = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
|
|
3390
3390
|
...t,
|
|
3391
3391
|
testVariationId: t.id,
|
|
3392
3392
|
id: e == null ? void 0 : e.id
|
|
3393
3393
|
})), En = ({
|
|
3394
3394
|
canTrack: e,
|
|
3395
3395
|
content: t
|
|
3396
|
-
}) => !(!(
|
|
3396
|
+
}) => !(!(_(t).length > 0) || !e || L()), Rn = (e) => e === "react" || e === "reactNative", Le = Rn(D), Pn = () => `
|
|
3397
3397
|
window.${$e} = ${In}
|
|
3398
3398
|
window.${De} = ${wn}
|
|
3399
3399
|
`, Bn = (e, t) => `
|
|
@@ -3509,7 +3509,7 @@ font-weight: ${s};
|
|
|
3509
3509
|
font-family: inherit;
|
|
3510
3510
|
}
|
|
3511
3511
|
`, On = (e) => e ? "" : Ln, Un = (e) => `variant-${e}`;
|
|
3512
|
-
function
|
|
3512
|
+
function Hn(e) {
|
|
3513
3513
|
var C, k, N;
|
|
3514
3514
|
const t = $(null);
|
|
3515
3515
|
function n(m) {
|
|
@@ -3553,7 +3553,7 @@ function jn(e) {
|
|
|
3553
3553
|
() => e.contentWrapper || "div"
|
|
3554
3554
|
);
|
|
3555
3555
|
function s(m) {
|
|
3556
|
-
return
|
|
3556
|
+
return _e({
|
|
3557
3557
|
model: e.model,
|
|
3558
3558
|
trustedHosts: e.trustedHosts,
|
|
3559
3559
|
callbacks: {
|
|
@@ -3581,6 +3581,7 @@ function jn(e) {
|
|
|
3581
3581
|
if (e.builderContextSignal.content) {
|
|
3582
3582
|
const u = (y = e.builderContextSignal.content) == null ? void 0 : y.testVariationId, p = (I = e.builderContextSignal.content) == null ? void 0 : I.id;
|
|
3583
3583
|
le({
|
|
3584
|
+
apiHost: e.apiHost,
|
|
3584
3585
|
type: "click",
|
|
3585
3586
|
canTrack: K(e.canTrack),
|
|
3586
3587
|
contentId: p,
|
|
@@ -3641,7 +3642,7 @@ function jn(e) {
|
|
|
3641
3642
|
return R.current || (S(), x(), R.current = !0), B(() => {
|
|
3642
3643
|
var m, y;
|
|
3643
3644
|
if (L()) {
|
|
3644
|
-
if (W() && (window.addEventListener("message", s),
|
|
3645
|
+
if (W() && !e.isNestedRender && (window.addEventListener("message", s), He(), je({
|
|
3645
3646
|
...e.locale ? {
|
|
3646
3647
|
locale: e.locale
|
|
3647
3648
|
} : {},
|
|
@@ -3655,7 +3656,7 @@ function jn(e) {
|
|
|
3655
3656
|
e.builderContextSignal.componentInfos
|
|
3656
3657
|
).forEach((u) => {
|
|
3657
3658
|
var E;
|
|
3658
|
-
const p =
|
|
3659
|
+
const p = Me(u);
|
|
3659
3660
|
(E = window.parent) == null || E.postMessage(p, "*");
|
|
3660
3661
|
}), window.addEventListener(
|
|
3661
3662
|
"builder:component:stateChangeListenerActivated",
|
|
@@ -3663,6 +3664,7 @@ function jn(e) {
|
|
|
3663
3664
|
)), e.builderContextSignal.content && K(e.canTrack)) {
|
|
3664
3665
|
const u = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, p = (y = e.builderContextSignal.content) == null ? void 0 : y.id, E = e.apiKey;
|
|
3665
3666
|
le({
|
|
3667
|
+
apiHost: e.apiHost,
|
|
3666
3668
|
type: "impression",
|
|
3667
3669
|
canTrack: !0,
|
|
3668
3670
|
contentId: p,
|
|
@@ -3714,7 +3716,7 @@ function jn(e) {
|
|
|
3714
3716
|
}
|
|
3715
3717
|
) : null });
|
|
3716
3718
|
}
|
|
3717
|
-
function
|
|
3719
|
+
function jn(e) {
|
|
3718
3720
|
const [t, n] = T(
|
|
3719
3721
|
() => `
|
|
3720
3722
|
${Dn({
|
|
@@ -3736,7 +3738,7 @@ ${On(e.isNestedRender)}
|
|
|
3736
3738
|
}
|
|
3737
3739
|
);
|
|
3738
3740
|
}
|
|
3739
|
-
const
|
|
3741
|
+
const Mn = ({
|
|
3740
3742
|
content: e,
|
|
3741
3743
|
data: t,
|
|
3742
3744
|
locale: n
|
|
@@ -3753,7 +3755,7 @@ const _n = ({
|
|
|
3753
3755
|
locale: n
|
|
3754
3756
|
} : {}
|
|
3755
3757
|
};
|
|
3756
|
-
},
|
|
3758
|
+
}, _n = ({
|
|
3757
3759
|
content: e,
|
|
3758
3760
|
data: t
|
|
3759
3761
|
}) => e ? {
|
|
@@ -3803,12 +3805,12 @@ function xe(e) {
|
|
|
3803
3805
|
), [r, s] = T(() => {
|
|
3804
3806
|
var C;
|
|
3805
3807
|
return {
|
|
3806
|
-
content:
|
|
3808
|
+
content: _n({
|
|
3807
3809
|
content: e.content,
|
|
3808
3810
|
data: e.data
|
|
3809
3811
|
}),
|
|
3810
3812
|
localState: void 0,
|
|
3811
|
-
rootState:
|
|
3813
|
+
rootState: Mn({
|
|
3812
3814
|
content: e.content,
|
|
3813
3815
|
data: e.data,
|
|
3814
3816
|
locale: e.locale
|
|
@@ -3857,8 +3859,9 @@ function xe(e) {
|
|
|
3857
3859
|
registeredComponents: o
|
|
3858
3860
|
},
|
|
3859
3861
|
children: /* @__PURE__ */ V(
|
|
3860
|
-
|
|
3862
|
+
Hn,
|
|
3861
3863
|
{
|
|
3864
|
+
apiHost: e.apiHost,
|
|
3862
3865
|
nonce: e.nonce,
|
|
3863
3866
|
content: e.content,
|
|
3864
3867
|
data: e.data,
|
|
@@ -3873,6 +3876,7 @@ function xe(e) {
|
|
|
3873
3876
|
contentWrapper: e.contentWrapper,
|
|
3874
3877
|
contentWrapperProps: e.contentWrapperProps,
|
|
3875
3878
|
trustedHosts: e.trustedHosts,
|
|
3879
|
+
isNestedRender: e.isNestedRender,
|
|
3876
3880
|
setBuilderContextSignal: s,
|
|
3877
3881
|
children: [
|
|
3878
3882
|
e.isSsrAbTest ? /* @__PURE__ */ l(
|
|
@@ -3884,7 +3888,7 @@ function xe(e) {
|
|
|
3884
3888
|
}
|
|
3885
3889
|
) : null,
|
|
3886
3890
|
/* @__PURE__ */ l(
|
|
3887
|
-
|
|
3891
|
+
jn,
|
|
3888
3892
|
{
|
|
3889
3893
|
nonce: e.nonce || "",
|
|
3890
3894
|
isNestedRender: e.isNestedRender,
|
|
@@ -3919,7 +3923,7 @@ function qn(e) {
|
|
|
3919
3923
|
function i() {
|
|
3920
3924
|
var s;
|
|
3921
3925
|
return Bn(
|
|
3922
|
-
|
|
3926
|
+
_(e.content).map((d) => ({
|
|
3923
3927
|
id: d.testVariationId,
|
|
3924
3928
|
testRatio: d.testRatio
|
|
3925
3929
|
})),
|
|
@@ -3927,7 +3931,7 @@ function qn(e) {
|
|
|
3927
3931
|
);
|
|
3928
3932
|
}
|
|
3929
3933
|
function o() {
|
|
3930
|
-
return
|
|
3934
|
+
return _(e.content).map((s) => `.variant-${s.testVariationId} { display: none; } `).join("");
|
|
3931
3935
|
}
|
|
3932
3936
|
function a() {
|
|
3933
3937
|
var s;
|
|
@@ -3966,9 +3970,10 @@ function qn(e) {
|
|
|
3966
3970
|
nonce: e.nonce || ""
|
|
3967
3971
|
}
|
|
3968
3972
|
),
|
|
3969
|
-
(r =
|
|
3973
|
+
(r = _(e.content)) == null ? void 0 : r.map((s) => /* @__PURE__ */ l(
|
|
3970
3974
|
xe,
|
|
3971
3975
|
{
|
|
3976
|
+
apiHost: e.apiHost,
|
|
3972
3977
|
isNestedRender: e.isNestedRender,
|
|
3973
3978
|
nonce: e.nonce,
|
|
3974
3979
|
content: s,
|
|
@@ -3996,6 +4001,7 @@ function qn(e) {
|
|
|
3996
4001
|
/* @__PURE__ */ l(
|
|
3997
4002
|
xe,
|
|
3998
4003
|
{
|
|
4004
|
+
apiHost: e.apiHost,
|
|
3999
4005
|
nonce: e.nonce,
|
|
4000
4006
|
isNestedRender: e.isNestedRender,
|
|
4001
4007
|
content: a(),
|
|
@@ -4050,7 +4056,7 @@ function zn(e) {
|
|
|
4050
4056
|
function i() {
|
|
4051
4057
|
var b, f;
|
|
4052
4058
|
return [
|
|
4053
|
-
e.attributes[
|
|
4059
|
+
e.attributes[H()],
|
|
4054
4060
|
"builder-symbol",
|
|
4055
4061
|
(b = e.symbol) != null && b.inline ? "builder-inline-symbol" : void 0,
|
|
4056
4062
|
(f = e.symbol) != null && f.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
|
package/lib/browser/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-b2eed856.cjs");require("react/jsx-runtime");require("react");exports.Blocks=t.Blocks;exports.BuilderContext=t.BuilderContext;exports.Button=t.Button;exports.Columns=t.Columns;exports.Content=t.Content;exports.Fragment=t.Fragment;exports.Image=t.Image;exports.Section=t.Section;exports.Symbol=t.Symbol;exports.Text=t.Text;exports.Video=t.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Blocks as i, BuilderContext as s, Button as n, Columns as c, Content as m, Fragment as g, Image as a, Section as d, Symbol as l, Text as p, Video as u } from "./blocks-exports.mjs";
|
|
2
|
-
import { _processContentResult as B, createRegisterComponentMessage as C, fetchBuilderProps as E, fetchEntries as h, fetchOneEntry as x, getBuilderSearchParams as S, isEditing as b, isPreviewing as P, register as k, setEditorSettings as y, subscribeToEditor as R, track as T } from "./server-entry-
|
|
2
|
+
import { _processContentResult as B, createRegisterComponentMessage as C, fetchBuilderProps as E, fetchEntries as h, fetchOneEntry as x, getBuilderSearchParams as S, isEditing as b, isPreviewing as P, register as k, setEditorSettings as y, subscribeToEditor as R, track as T } from "./server-entry-fea90db1.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
export {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const y="react",I="[Builder.io]: ",l={log:(...e)=>console.log(I,...e),error:(...e)=>console.error(I,...e),warn:(...e)=>console.warn(I,...e),debug:(...e)=>console.debug(I,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const le=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?le(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function fe(){return c()&&window.self!==window.top}function F(e){return fe()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const ge=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},he=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=he(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=ge();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function pe(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const me=e=>({type:"builder.registerComponent",data:k(e)}),ye=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ye(n):n))}const x={};function D(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const B={};function Se(e){if(c()){Object.assign(B,e);const t={type:"builder.settingsChange",data:B};parent.postMessage(t,"*")}}const R="builder.",we="options.",P=e=>{if(!e)return{};const t=V(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(R)){const o=r.replace(R,"").replace(we,"");n[o]=t[r]}}),n},be=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},K="2.0.27",j=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":K}),Ie=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},W=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},$=async e=>W(e),ve=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ee=[["secure",""],["SameSite","None"]],ke=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Ee:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",Ie(window.location.hostname)],...o];return ve(i)},_=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ke({name:e,value:t,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function Pe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function G(){return Pe().replace(/-/g,"")}const H="builderSessionId",Oe=async({canTrack:e})=>{if(!e)return;const t=await $({name:H,canTrack:e});if(p(t))return t;{const n=Ce();return Ae({id:n,canTrack:e}),n}},Ce=()=>G(),Ae=({id:e,canTrack:t})=>_({name:H,value:e,canTrack:t}),X=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Te=({key:e,canTrack:t})=>{var n;try{return t?(n=X())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},xe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=X())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Be=({canTrack:e})=>{if(!e)return;const t=Te({key:z,canTrack:e});if(p(t))return t;{const n=Re();return Le({id:n,canTrack:e}),n}},Re=()=>G(),Le=({id:e,canTrack:t})=>xe({key:z,value:e,canTrack:t}),Ue=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Oe({canTrack:e}),n=Be({canTrack:e});return{sessionId:t,visitorId:n}},Ve=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Ue({canTrack:t}),userAttributes:N(),ownerId:n}});async function J({apiHost:e,...t}){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||F()||!(c()||y==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await Ve(t)]}),headers:{"content-type":"application/json",...j()},mode:"cors"}).catch(r=>{console.error("Failed to track: ",r)})}const Me=e=>J({...e,canTrack:!0}),Fe=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function q(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Fe).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Ne=()=>{D("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let L=!1;const Q=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:K,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,i;if(!q(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const u=o.data.text,S=o.data.arguments||[],m=o.data.id,v=new Function(u);let d,g=null;try{d=v.apply(null,S)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):d&&typeof d.then=="function"?d.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:m}},"*");break}}})))},Y=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!q(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,i=s.key||s.alias||s.entry||s.modelName,u=s.data;i===e&&n.contentUpdate(u);break}}},De=(e,t,n)=>{if(!c)return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};Q();const r=Y({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ke="builder.tests",O=e=>`${Ke}.${e}`,je=({contentId:e})=>$({name:O(e),canTrack:!0}),We=({contentId:e})=>W({name:O(e),canTrack:!0}),$e=({contentId:e,value:t})=>_({name:O(e),value:t,canTrack:!0}),Z=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,_e=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const i=(o=t[s])==null?void 0:o.testRatio;if(n+=i,r<n)return s}return e},ee=e=>{const t=_e(e);return $e({contentId:e.id,value:t}).catch(n=>{l.error("could not store A/B test variation: ",n)}),t},te=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Ge=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Z(e))return e;const n=We({contentId:e.id})||ee({variations:e.variations,id:e.id}),r=te({item:e,testGroupId:n});return{...e,...r}},He=async({item:e,canTrack:t})=>{if(!t||!Z(e))return e;const r=await je({contentId:e.id})||ee({variations:e.variations,id:e.id}),o=te({item:e,testGroupId:r});return{...e,...o}},ne=e=>p(e)?e:!0;function Xe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=Xe().fetch;if(typeof e=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return e}const Je=ze();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],i=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,i,n)}:{...r,[i]:s}},{})}function re(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(i=>i.startsWith("$"))?re(o,s,n):n[s]=o}return n}const qe="v3",U=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:i,locale:u,apiVersion:S=qe,fields:m,omit:v,offset:d,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:A,apiHost:ae}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ce=t!==1,ue=ae||"https://cdn.builder.io",a=new URL(`${ue}/api/${S}/content/${o}`);if(a.searchParams.set("apiKey",s),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(ce)),a.searchParams.set("includeRefs",String(!0)),u&&a.searchParams.set("locale",u),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",v||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(d)&&d>-1&&a.searchParams.set("offset",String(Math.floor(d))),typeof A=="boolean"&&a.searchParams.set("includeUnpublished",String(A)),g&&U(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&U(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=E({sort:w});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}const de={...be(),...V(e.options||{})},T=E(de);for(const f in T)a.searchParams.set(f,String(T[f]));if(n&&a.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=re({query:r});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}return a},Qe=e=>"results"in e;async function oe(e){const t=await ie({...e,limit:1});return t&&t[0]||null}const Ye=async e=>{var i,u;const t=C(e),n=(i=e.fetch)!=null?i:Je,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...j()}};return await(await n(t.href,r)).json()},se=async(e,t,n=C(e))=>{const r=ne(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await He({item:s,canTrack:r}));t.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return t.results};async function ie(e){try{const t=C(e),n=await Ye(e);return Qe(n)?se(e,n):(l.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return l.error("Error fetching data. ",t),null}}const Ze=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:P(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await oe(n)}};exports.TARGET=y;exports._processContentResult=se;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=Y;exports.createRegisterComponentMessage=me;exports.fetchBuilderProps=Ze;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ne;exports.getUserAttributes=N;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=pe;exports.logger=l;exports.register=D;exports.registerInsertMenu=Ne;exports.serializeIncludingFunctions=k;exports.setEditorSettings=Se;exports.setupBrowserForEditing=Q;exports.subscribeToEditor=De;exports.track=Me;
|