@builder.io/sdk-react 2.0.2 → 2.0.3
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 +25 -25
- package/lib/browser/blocks-exports.mjs +120 -119
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +1 -1
- package/lib/browser/server-entry-02cecfb7.cjs +2 -0
- package/lib/browser/server-entry-0687830a.js +688 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-ca081054.js → accordion-0eca9b08.js} +1 -1
- package/lib/edge/{accordion-4f96554c.cjs → accordion-368a2cf8.cjs} +1 -1
- package/lib/edge/{blocks-f55c7d3e.js → blocks-db3cfcac.js} +130 -129
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{blocks-078044bc.cjs → blocks-f524a758.cjs} +13 -13
- package/lib/edge/{button-5d140f8e.cjs → button-3ed29654.cjs} +1 -1
- package/lib/edge/{button-41169061.js → button-e852700f.js} +2 -2
- package/lib/edge/columns-1f84e26e.cjs +28 -0
- package/lib/edge/{columns-f8916a18.js → columns-ee464f6c.js} +49 -48
- package/lib/edge/{content-variants-89a9389a.cjs → content-variants-42f2495b.cjs} +4 -4
- package/lib/edge/{content-variants-71ee0c76.js → content-variants-c0257a99.js} +23 -23
- package/lib/edge/{form-f2d2c2bf.cjs → form-4444faf2.cjs} +1 -1
- package/lib/edge/{form-ac2f2a0e.js → form-8191004e.js} +3 -3
- package/lib/edge/{get-class-prop-name-a9b4959e.cjs → get-class-prop-name-5fc98fcc.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-a677d7a5.js → get-class-prop-name-d18337d2.js} +1 -1
- package/lib/edge/{img-b91cb4fd.cjs → img-10ef20a5.cjs} +1 -1
- package/lib/edge/{img-8fc26395.js → img-a24ed75f.js} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +1 -1
- package/lib/edge/{input-549f090e.js → input-3876429d.js} +1 -1
- package/lib/edge/{input-ec7c695a.cjs → input-6325bfc0.cjs} +1 -1
- package/lib/edge/{select-3ffa9294.cjs → select-3f0f00f3.cjs} +1 -1
- package/lib/edge/{select-6a5a28ac.js → select-5dc1c7d1.js} +1 -1
- package/lib/edge/server-entry-805b9266.cjs +2 -0
- package/lib/edge/server-entry-ff728468.js +689 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-40de071b.js → slot-20fe5e4f.js} +3 -3
- package/lib/edge/{slot-8b27e15e.cjs → slot-a64b535f.cjs} +1 -1
- package/lib/edge/{symbol-76e76298.cjs → symbol-5012ed02.cjs} +1 -1
- package/lib/edge/{symbol-e6515a5f.js → symbol-e95082e1.js} +2 -2
- package/lib/edge/{tabs-b75be82d.js → tabs-261e8cd4.js} +3 -3
- package/lib/edge/{tabs-9c5af0ec.cjs → tabs-d672f816.cjs} +1 -1
- package/lib/node/blocks-exports.cjs +11 -11
- package/lib/node/blocks-exports.mjs +74 -73
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +2 -2
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +2 -2
- package/lib/node/{node-runtime-0e37d6f7.cjs → node-runtime-160b6846.cjs} +2 -2
- package/lib/node/{node-runtime-0f3a5df1.js → node-runtime-405effc5.js} +3 -2
- package/lib/node/server-entry-02cecfb7.cjs +2 -0
- package/lib/node/server-entry-0687830a.js +688 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/register-component.d.ts +2 -2
- package/lib/browser/server-entry-419c051e.cjs +0 -2
- package/lib/browser/server-entry-825b4408.js +0 -695
- package/lib/edge/columns-354bf349.cjs +0 -28
- package/lib/edge/server-entry-966ac144.cjs +0 -2
- package/lib/edge/server-entry-d2020acf.js +0 -695
- package/lib/node/server-entry-5ebd1c9b.js +0 -695
- package/lib/node/server-entry-8002325b.cjs +0 -2
|
@@ -3,9 +3,9 @@ var He = Object.defineProperty;
|
|
|
3
3
|
var qe = (e, t, n) => t in e ? He(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
4
4
|
var ie = (e, t, n) => (qe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
5
5
|
import { jsx as s, Fragment as R, jsxs as P } from "react/jsx-runtime";
|
|
6
|
-
import { TARGET as K, checkIsDefined as Y, logger as Z, isBrowser as G,
|
|
6
|
+
import { TARGET as K, checkIsDefined as Y, logger as Z, isBrowser as G, isEditing as $, registerInsertMenu as Ke, setupBrowserForEditing as ze, createRegisterComponentMessage as _e, getDefaultCanTrack as Q, _track as he, isPreviewing as Je, fetchOneEntry as Ie, createEditorListener as Ye, fetch as Ge, serializeComponentInfo as ge, handleABTestingSync as Qe } from "./server-entry-0687830a.js";
|
|
7
7
|
import { createContext as we, useState as T, useEffect as V, useContext as be, useRef as ee, createElement as Re } from "react";
|
|
8
|
-
import { getFunctionArguments as Xe, runInNode as Ze, parseCode as et, getBuilderGlobals as tt, set as Ee } from "./node-runtime-
|
|
8
|
+
import { getFunctionArguments as Xe, runInNode as Ze, parseCode as et, getBuilderGlobals as tt, fastClone as de, set as Ee } from "./node-runtime-405effc5.js";
|
|
9
9
|
const nt = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), it = (e) => typeof e == "string" && nt.has(e.toLowerCase());
|
|
10
10
|
function ue(e) {
|
|
11
11
|
return /* @__PURE__ */ s(R, { children: it(e.TagName) ? /* @__PURE__ */ s(R, { children: /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes }) }) : /* @__PURE__ */ s(R, { children: typeof e.TagName == "string" ? /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) : /* @__PURE__ */ s(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) }) });
|
|
@@ -974,28 +974,28 @@ function $t(e) {
|
|
|
974
974
|
), [i, o] = T(() => e.columns || []), [l, a] = T(
|
|
975
975
|
() => e.stackColumnsAt || "tablet"
|
|
976
976
|
);
|
|
977
|
-
function r(
|
|
978
|
-
return
|
|
977
|
+
function r(x) {
|
|
978
|
+
return x.link ? e.builderLinkComponent || "a" : "div";
|
|
979
979
|
}
|
|
980
|
-
function c(
|
|
980
|
+
function c(x) {
|
|
981
981
|
var w;
|
|
982
|
-
return ((w = i[
|
|
982
|
+
return ((w = i[x]) == null ? void 0 : w.width) || 100 / i.length;
|
|
983
983
|
}
|
|
984
|
-
function u(
|
|
985
|
-
const w = c(
|
|
984
|
+
function u(x) {
|
|
985
|
+
const w = c(x), N = t * (i.length - 1) * (w / 100);
|
|
986
986
|
return `calc(${w}% - ${N}px)`;
|
|
987
987
|
}
|
|
988
988
|
function f({
|
|
989
|
-
stackedStyle:
|
|
989
|
+
stackedStyle: x,
|
|
990
990
|
desktopStyle: w
|
|
991
991
|
}) {
|
|
992
|
-
return l === "tablet" ?
|
|
992
|
+
return l === "tablet" ? x : w;
|
|
993
993
|
}
|
|
994
994
|
function d({
|
|
995
|
-
stackedStyle:
|
|
995
|
+
stackedStyle: x,
|
|
996
996
|
desktopStyle: w
|
|
997
997
|
}) {
|
|
998
|
-
return l === "never" ? w :
|
|
998
|
+
return l === "never" ? w : x;
|
|
999
999
|
}
|
|
1000
1000
|
const [m, g] = T(
|
|
1001
1001
|
() => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
@@ -1009,8 +1009,8 @@ function $t(e) {
|
|
|
1009
1009
|
})
|
|
1010
1010
|
};
|
|
1011
1011
|
}
|
|
1012
|
-
function C(
|
|
1013
|
-
const w =
|
|
1012
|
+
function C(x) {
|
|
1013
|
+
const w = x === 0 ? 0 : t, N = u(x), b = `${w}px`, h = "100%", v = 0;
|
|
1014
1014
|
return {
|
|
1015
1015
|
...{
|
|
1016
1016
|
display: "flex",
|
|
@@ -1024,7 +1024,7 @@ function $t(e) {
|
|
|
1024
1024
|
desktopStyle: N
|
|
1025
1025
|
}),
|
|
1026
1026
|
"--column-margin-left-mobile": d({
|
|
1027
|
-
stackedStyle:
|
|
1027
|
+
stackedStyle: v,
|
|
1028
1028
|
desktopStyle: b
|
|
1029
1029
|
}),
|
|
1030
1030
|
"--column-width-tablet": f({
|
|
@@ -1032,18 +1032,19 @@ function $t(e) {
|
|
|
1032
1032
|
desktopStyle: N
|
|
1033
1033
|
}),
|
|
1034
1034
|
"--column-margin-left-tablet": f({
|
|
1035
|
-
stackedStyle:
|
|
1035
|
+
stackedStyle: v,
|
|
1036
1036
|
desktopStyle: b
|
|
1037
1037
|
})
|
|
1038
1038
|
};
|
|
1039
1039
|
}
|
|
1040
|
-
function p(
|
|
1040
|
+
function p(x) {
|
|
1041
1041
|
var N, b;
|
|
1042
1042
|
return De(
|
|
1043
1043
|
((b = (N = e.builderContext.content) == null ? void 0 : N.meta) == null ? void 0 : b.breakpoints) || {}
|
|
1044
|
-
)[
|
|
1044
|
+
)[x].max;
|
|
1045
1045
|
}
|
|
1046
1046
|
function B() {
|
|
1047
|
+
const x = `.${e.builderBlock.id}-breakpoints > .builder-column`;
|
|
1047
1048
|
return `
|
|
1048
1049
|
@media (max-width: ${p("medium")}px) {
|
|
1049
1050
|
.${e.builderBlock.id}-breakpoints {
|
|
@@ -1051,7 +1052,7 @@ function $t(e) {
|
|
|
1051
1052
|
align-items: stretch;
|
|
1052
1053
|
}
|
|
1053
1054
|
|
|
1054
|
-
|
|
1055
|
+
${x} {
|
|
1055
1056
|
width: var(--column-width-tablet) !important;
|
|
1056
1057
|
margin-left: var(--column-margin-left-tablet) !important;
|
|
1057
1058
|
}
|
|
@@ -1063,17 +1064,17 @@ function $t(e) {
|
|
|
1063
1064
|
align-items: stretch;
|
|
1064
1065
|
}
|
|
1065
1066
|
|
|
1066
|
-
|
|
1067
|
+
${x} {
|
|
1067
1068
|
width: var(--column-width-mobile) !important;
|
|
1068
1069
|
margin-left: var(--column-margin-left-mobile) !important;
|
|
1069
1070
|
}
|
|
1070
1071
|
},
|
|
1071
1072
|
`;
|
|
1072
1073
|
}
|
|
1073
|
-
function E(
|
|
1074
|
+
function E(x, w) {
|
|
1074
1075
|
return {
|
|
1075
|
-
...
|
|
1076
|
-
href:
|
|
1076
|
+
...x.link ? {
|
|
1077
|
+
href: x.link
|
|
1077
1078
|
} : {},
|
|
1078
1079
|
[H()]: "builder-column",
|
|
1079
1080
|
style: Fe(C(w))
|
|
@@ -1083,7 +1084,7 @@ function $t(e) {
|
|
|
1083
1084
|
/* @__PURE__ */ P(
|
|
1084
1085
|
"div",
|
|
1085
1086
|
{
|
|
1086
|
-
className: Ft((A = e.builderBlock) == null ? void 0 : A.id) + " div-
|
|
1087
|
+
className: Ft((A = e.builderBlock) == null ? void 0 : A.id) + " div-34f576bb",
|
|
1087
1088
|
style: y(),
|
|
1088
1089
|
children: [
|
|
1089
1090
|
/* @__PURE__ */ s(
|
|
@@ -1094,12 +1095,12 @@ function $t(e) {
|
|
|
1094
1095
|
nonce: e.builderContext.nonce
|
|
1095
1096
|
}
|
|
1096
1097
|
),
|
|
1097
|
-
(O = e.columns) == null ? void 0 : O.map((
|
|
1098
|
+
(O = e.columns) == null ? void 0 : O.map((x, w) => /* @__PURE__ */ s(
|
|
1098
1099
|
ue,
|
|
1099
1100
|
{
|
|
1100
|
-
TagName: r(
|
|
1101
|
+
TagName: r(x),
|
|
1101
1102
|
actionAttributes: {},
|
|
1102
|
-
attributes: E(
|
|
1103
|
+
attributes: E(x, w),
|
|
1103
1104
|
children: /* @__PURE__ */ s(
|
|
1104
1105
|
D,
|
|
1105
1106
|
{
|
|
@@ -1111,7 +1112,7 @@ function $t(e) {
|
|
|
1111
1112
|
context: e.builderContext,
|
|
1112
1113
|
registeredComponents: e.builderComponents,
|
|
1113
1114
|
linkComponent: e.builderLinkComponent,
|
|
1114
|
-
blocks:
|
|
1115
|
+
blocks: x.blocks
|
|
1115
1116
|
}
|
|
1116
1117
|
)
|
|
1117
1118
|
},
|
|
@@ -1120,7 +1121,7 @@ function $t(e) {
|
|
|
1120
1121
|
]
|
|
1121
1122
|
}
|
|
1122
1123
|
),
|
|
1123
|
-
/* @__PURE__ */ s("style", { children: `.div-
|
|
1124
|
+
/* @__PURE__ */ s("style", { children: `.div-34f576bb {
|
|
1124
1125
|
display: flex;
|
|
1125
1126
|
line-height: normal;
|
|
1126
1127
|
}` })
|
|
@@ -2606,40 +2607,40 @@ function fn(e) {
|
|
|
2606
2607
|
let E;
|
|
2607
2608
|
const A = new FormData(p), O = Array.from(p.querySelectorAll("input,select,textarea")).filter((b) => !!b.name).map((b) => {
|
|
2608
2609
|
let h;
|
|
2609
|
-
const
|
|
2610
|
+
const v = b.name;
|
|
2610
2611
|
if (b instanceof HTMLInputElement)
|
|
2611
2612
|
if (b.type === "radio") {
|
|
2612
2613
|
if (b.checked)
|
|
2613
2614
|
return h = b.name, {
|
|
2614
|
-
key:
|
|
2615
|
+
key: v,
|
|
2615
2616
|
value: h
|
|
2616
2617
|
};
|
|
2617
2618
|
} else if (b.type === "checkbox")
|
|
2618
2619
|
h = b.checked;
|
|
2619
2620
|
else if (b.type === "number" || b.type === "range") {
|
|
2620
|
-
const
|
|
2621
|
-
isNaN(
|
|
2621
|
+
const S = b.valueAsNumber;
|
|
2622
|
+
isNaN(S) || (h = S);
|
|
2622
2623
|
} else
|
|
2623
2624
|
b.type === "file" ? h = b.files : h = b.value;
|
|
2624
2625
|
else
|
|
2625
2626
|
h = b.value;
|
|
2626
2627
|
return {
|
|
2627
|
-
key:
|
|
2628
|
+
key: v,
|
|
2628
2629
|
value: h
|
|
2629
2630
|
};
|
|
2630
2631
|
});
|
|
2631
|
-
let
|
|
2632
|
-
if (e.sendSubmissionsTo === "email" && (
|
|
2633
|
-
(b instanceof File || Array.isArray(b) && b[0] instanceof File || b instanceof FileList) && (
|
|
2634
|
-
}),
|
|
2632
|
+
let x = e.contentType;
|
|
2633
|
+
if (e.sendSubmissionsTo === "email" && (x = "multipart/form-data"), Array.from(O).forEach(({ value: b }) => {
|
|
2634
|
+
(b instanceof File || Array.isArray(b) && b[0] instanceof File || b instanceof FileList) && (x = "multipart/form-data");
|
|
2635
|
+
}), x !== "application/json")
|
|
2635
2636
|
E = A;
|
|
2636
2637
|
else {
|
|
2637
2638
|
const b = {};
|
|
2638
|
-
Array.from(O).forEach(({ value: h, key:
|
|
2639
|
-
Ee(b,
|
|
2639
|
+
Array.from(O).forEach(({ value: h, key: v }) => {
|
|
2640
|
+
Ee(b, v, h);
|
|
2640
2641
|
}), E = JSON.stringify(b);
|
|
2641
2642
|
}
|
|
2642
|
-
|
|
2643
|
+
x && x !== "multipart/form-data" && (y && ((C = e.action) != null && C.includes("zapier.com")) || (B["content-type"] = x));
|
|
2643
2644
|
const w = new CustomEvent("presubmit", { detail: { body: E } });
|
|
2644
2645
|
if (t.current && (t.current.dispatchEvent(w), w.defaultPrevented))
|
|
2645
2646
|
return;
|
|
@@ -2653,17 +2654,17 @@ function fn(e) {
|
|
|
2653
2654
|
).then(
|
|
2654
2655
|
async (b) => {
|
|
2655
2656
|
let h;
|
|
2656
|
-
const
|
|
2657
|
-
if (
|
|
2658
|
-
let
|
|
2659
|
-
|
|
2657
|
+
const v = b.headers.get("content-type");
|
|
2658
|
+
if (v && v.indexOf("application/json") !== -1 ? h = await b.json() : h = await b.text(), !b.ok && e.errorMessagePath) {
|
|
2659
|
+
let S = mn(h, e.errorMessagePath);
|
|
2660
|
+
S && (typeof S != "string" && (S = JSON.stringify(S)), r(S), c({ formErrorMessage: S }));
|
|
2660
2661
|
}
|
|
2661
2662
|
if (l(h), i(b.ok ? "success" : "error"), b.ok) {
|
|
2662
|
-
const
|
|
2663
|
+
const S = new CustomEvent("submit:success", {
|
|
2663
2664
|
detail: { res: b, body: h }
|
|
2664
2665
|
});
|
|
2665
2666
|
if (t.current) {
|
|
2666
|
-
if (t.current.dispatchEvent(
|
|
2667
|
+
if (t.current.dispatchEvent(S), S.defaultPrevented)
|
|
2667
2668
|
return;
|
|
2668
2669
|
e.resetFormOnSubmit !== !1 && t.current.reset();
|
|
2669
2670
|
}
|
|
@@ -3433,26 +3434,26 @@ font-weight: ${r};
|
|
|
3433
3434
|
}
|
|
3434
3435
|
`, Mn = (e) => e ? "" : jn, Un = (e) => `variant-${e}`;
|
|
3435
3436
|
function Hn(e) {
|
|
3436
|
-
var E, A, O,
|
|
3437
|
+
var E, A, O, x, w, N, b;
|
|
3437
3438
|
const t = ee(null);
|
|
3438
3439
|
function n(h) {
|
|
3439
|
-
var
|
|
3440
|
-
const
|
|
3440
|
+
var S, k;
|
|
3441
|
+
const v = {
|
|
3441
3442
|
...e.builderContextSignal.rootState,
|
|
3442
3443
|
...h
|
|
3443
3444
|
};
|
|
3444
|
-
e.builderContextSignal.rootSetState ? (k = (
|
|
3445
|
+
e.builderContextSignal.rootSetState ? (k = (S = e.builderContextSignal).rootSetState) == null || k.call(S, v) : e.setBuilderContextSignal((I) => ({
|
|
3445
3446
|
...I,
|
|
3446
|
-
rootState:
|
|
3447
|
+
rootState: v
|
|
3447
3448
|
}));
|
|
3448
3449
|
}
|
|
3449
3450
|
function i(h) {
|
|
3450
|
-
var
|
|
3451
|
-
const
|
|
3451
|
+
var S, k, I, W, j;
|
|
3452
|
+
const v = {
|
|
3452
3453
|
...e.builderContextSignal.content,
|
|
3453
3454
|
...h,
|
|
3454
3455
|
data: {
|
|
3455
|
-
...(
|
|
3456
|
+
...(S = e.builderContextSignal.content) == null ? void 0 : S.data,
|
|
3456
3457
|
...h == null ? void 0 : h.data
|
|
3457
3458
|
},
|
|
3458
3459
|
meta: {
|
|
@@ -3463,7 +3464,7 @@ function Hn(e) {
|
|
|
3463
3464
|
};
|
|
3464
3465
|
e.setBuilderContextSignal((F) => ({
|
|
3465
3466
|
...F,
|
|
3466
|
-
content:
|
|
3467
|
+
content: v
|
|
3467
3468
|
}));
|
|
3468
3469
|
}
|
|
3469
3470
|
function o() {
|
|
@@ -3480,27 +3481,27 @@ function Hn(e) {
|
|
|
3480
3481
|
model: e.model,
|
|
3481
3482
|
trustedHosts: e.trustedHosts,
|
|
3482
3483
|
callbacks: {
|
|
3483
|
-
configureSdk: (
|
|
3484
|
+
configureSdk: (v) => {
|
|
3484
3485
|
var I;
|
|
3485
|
-
const { breakpoints:
|
|
3486
|
-
!k || k !== ((I = e.builderContextSignal.content) == null ? void 0 : I.id) ||
|
|
3486
|
+
const { breakpoints: S, contentId: k } = v;
|
|
3487
|
+
!k || k !== ((I = e.builderContextSignal.content) == null ? void 0 : I.id) || S && i({
|
|
3487
3488
|
meta: {
|
|
3488
|
-
breakpoints:
|
|
3489
|
+
breakpoints: S
|
|
3489
3490
|
}
|
|
3490
3491
|
});
|
|
3491
3492
|
},
|
|
3492
|
-
animation: (
|
|
3493
|
-
Ne(
|
|
3493
|
+
animation: (v) => {
|
|
3494
|
+
Ne(v);
|
|
3494
3495
|
},
|
|
3495
|
-
contentUpdate: (
|
|
3496
|
-
i(
|
|
3496
|
+
contentUpdate: (v) => {
|
|
3497
|
+
i(v);
|
|
3497
3498
|
}
|
|
3498
3499
|
}
|
|
3499
3500
|
})(h);
|
|
3500
3501
|
}
|
|
3501
3502
|
function c() {
|
|
3502
|
-
var
|
|
3503
|
-
const h = (
|
|
3503
|
+
var v, S;
|
|
3504
|
+
const h = (S = (v = e.builderContextSignal.content) == null ? void 0 : v.data) == null ? void 0 : S.jsCode;
|
|
3504
3505
|
h && q({
|
|
3505
3506
|
code: h,
|
|
3506
3507
|
context: e.context || {},
|
|
@@ -3515,9 +3516,9 @@ function Hn(e) {
|
|
|
3515
3516
|
}
|
|
3516
3517
|
const [u, f] = T(() => ({})), [d, m] = T(() => ({})), [g, y] = T(() => !1);
|
|
3517
3518
|
function C(h) {
|
|
3518
|
-
var
|
|
3519
|
+
var v, S;
|
|
3519
3520
|
if (e.builderContextSignal.content) {
|
|
3520
|
-
const k = (
|
|
3521
|
+
const k = (v = e.builderContextSignal.content) == null ? void 0 : v.testVariationId, I = (S = e.builderContextSignal.content) == null ? void 0 : S.id;
|
|
3521
3522
|
he({
|
|
3522
3523
|
type: "click",
|
|
3523
3524
|
canTrack: Q(e.canTrack),
|
|
@@ -3531,8 +3532,8 @@ function Hn(e) {
|
|
|
3531
3532
|
g || y(!0);
|
|
3532
3533
|
}
|
|
3533
3534
|
function p() {
|
|
3534
|
-
var
|
|
3535
|
-
const h = (k = (
|
|
3535
|
+
var v, S, k;
|
|
3536
|
+
const h = (k = (S = (v = e.builderContextSignal.content) == null ? void 0 : v.data) == null ? void 0 : S.httpRequests) != null ? k : {};
|
|
3536
3537
|
Object.entries(h).forEach(([I, W]) => {
|
|
3537
3538
|
if (!W || d[I] || u[I] && !$())
|
|
3538
3539
|
return;
|
|
@@ -3577,7 +3578,7 @@ function Hn(e) {
|
|
|
3577
3578
|
);
|
|
3578
3579
|
}
|
|
3579
3580
|
return V(() => {
|
|
3580
|
-
var h,
|
|
3581
|
+
var h, v;
|
|
3581
3582
|
if (G()) {
|
|
3582
3583
|
if ($() && (window.addEventListener("message", r), Ke(), ze({
|
|
3583
3584
|
...e.locale ? {
|
|
@@ -3599,7 +3600,7 @@ function Hn(e) {
|
|
|
3599
3600
|
"builder:component:stateChangeListenerActivated",
|
|
3600
3601
|
B
|
|
3601
3602
|
)), e.builderContextSignal.content && Q(e.canTrack)) {
|
|
3602
|
-
const k = (h = e.builderContextSignal.content) == null ? void 0 : h.testVariationId, I = (
|
|
3603
|
+
const k = (h = e.builderContextSignal.content) == null ? void 0 : h.testVariationId, I = (v = e.builderContextSignal.content) == null ? void 0 : v.id, W = e.apiKey;
|
|
3603
3604
|
he({
|
|
3604
3605
|
type: "impression",
|
|
3605
3606
|
canTrack: !0,
|
|
@@ -3631,7 +3632,7 @@ function Hn(e) {
|
|
|
3631
3632
|
c();
|
|
3632
3633
|
}, [(A = (E = e.builderContextSignal.content) == null ? void 0 : E.data) == null ? void 0 : A.jsCode]), V(() => {
|
|
3633
3634
|
p();
|
|
3634
|
-
}, [(
|
|
3635
|
+
}, [(x = (O = e.builderContextSignal.content) == null ? void 0 : O.data) == null ? void 0 : x.httpRequests]), V(() => {
|
|
3635
3636
|
B();
|
|
3636
3637
|
}, [e.builderContextSignal.rootState]), V(() => {
|
|
3637
3638
|
e.data && n(e.data);
|
package/lib/node/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-02cecfb7.cjs");require("react/jsx-runtime");require("react");require("./node-runtime-160b6846.cjs");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/node/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Blocks as s, BuilderContext as n, Button as m, Columns as c, Content as g, Fragment as a, Image as p, Section as d, Symbol as l, Text as u, Video as f } from "./blocks-exports.mjs";
|
|
2
|
-
import { _processContentResult as C, createRegisterComponentMessage as E, fetchBuilderProps as h, fetchEntries as x, fetchOneEntry as S, getBuilderSearchParams as b, isEditing as P, isPreviewing as k, register as y, setEditorSettings as R, subscribeToEditor as T, track as v } from "./server-entry-
|
|
2
|
+
import { _processContentResult as C, createRegisterComponentMessage as E, fetchBuilderProps as h, fetchEntries as x, fetchOneEntry as S, getBuilderSearchParams as b, isEditing as P, isPreviewing as k, register as y, setEditorSettings as R, subscribeToEditor as T, track as v } from "./server-entry-0687830a.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
|
-
import "./node-runtime-
|
|
5
|
+
import "./node-runtime-405effc5.js";
|
|
6
6
|
export {
|
|
7
7
|
s as Blocks,
|
|
8
8
|
n as BuilderContext,
|
package/lib/node/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("isolated-vm"),n=require("./node-runtime-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("isolated-vm"),n=require("./node-runtime-160b6846.cjs");require("./server-entry-02cecfb7.cjs");const o=e=>{const{ivmIsolateOptions:i}=e||{};n.setIvm(t,i)};exports.initializeNodeRuntime=o;
|
package/lib/node/init.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import t from "isolated-vm";
|
|
2
|
-
import { setIvm as m } from "./node-runtime-
|
|
3
|
-
import "./server-entry-
|
|
2
|
+
import { setIvm as m } from "./node-runtime-405effc5.js";
|
|
3
|
+
import "./server-entry-0687830a.js";
|
|
4
4
|
const p = (i) => {
|
|
5
5
|
const {
|
|
6
6
|
ivmIsolateOptions: o
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const serverEntry=require("./server-entry-
|
|
1
|
+
"use strict";const serverEntry=require("./server-entry-02cecfb7.cjs"),getFunctionArguments=({builder:e,context:t,event:s,state:r})=>Object.entries({state:r,Builder:e,builder:e,context:t,event:s}),getBuilderGlobals=()=>({isEditing:serverEntry.isEditing(),isBrowser:serverEntry.isBrowser(),isServer:!serverEntry.isBrowser(),getUserAttributes:()=>serverEntry.getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e,SDK_NAME_FOR_TARGET=(()=>{switch(serverEntry.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return serverEntry.TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,s)=>{if(Object(e)!==e)return e;const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return r.slice(0,-1).reduce((n,o,c)=>Object(n[o])===n[o]?n[o]:n[o]=Math.abs(Number(r[c+1]))>>0===+r[c+1]?[]:{},e)[r[r.length-1]]=s,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=eval("require")}catch(e){}const getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -45,4 +45,4 @@ if (typeof output === 'object' && output !== null) {
|
|
|
45
45
|
${SHOULD_MENTION_INITIALIZE_SCRIPT?'- import and call `initializeNodeRuntime()` from "${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(e)};function setIsolateContext(e={memoryLimit:128}){const t=getIvm(),r=new t.Isolate(e).createContextSync(),n=r.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...o){console.log(...o)}),n.setSync(INJECTED_IVM_GLOBAL,t),IVM_CONTEXT=r,r}const getIsolateContext=()=>IVM_CONTEXT||setIsolateContext(),runInNode=({code:e,builder:t,context:s,event:r,localState:n,rootSetState:o,rootState:c})=>{const I=getIvm(),_=
|
|
48
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(e)};function setIsolateContext(e={memoryLimit:128}){const t=getIvm(),r=new t.Isolate(e).createContextSync(),n=r.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...o){console.log(...o)}),n.setSync(INJECTED_IVM_GLOBAL,t),IVM_CONTEXT=r,r}const getIsolateContext=()=>IVM_CONTEXT||setIsolateContext(),runInNode=({code:e,builder:t,context:s,event:r,localState:n,rootSetState:o,rootState:c})=>{const I=getIvm(),_=fastClone({...c,...n}),l=getFunctionArguments({builder:t,context:s,event:r,state:_}),a=getIsolateContext(),y=a.global;y.setSync(BUILDER_SET_STATE_NAME,function(i,u){set(c,i,u),o==null||o(c)}),l.forEach(([i,u])=>{const N=typeof u=="object"?new I.Reference(i==="builder"?{...u,getUserAttributes:()=>u.getUserAttributes()}:u):null;y.setSync(getSyncValName(i),N)});const g=processCode({code:e,args:l}),E=a.evalClosureSync(g);try{return JSON.parse(E)}catch{return E}};exports.fastClone=fastClone;exports.getBuilderGlobals=getBuilderGlobals;exports.getFunctionArguments=getFunctionArguments;exports.parseCode=parseCode;exports.runInNode=runInNode;exports.set=set;exports.setIvm=setIvm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX
|
|
1
|
+
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-0687830a.js";
|
|
2
2
|
const getFunctionArguments = ({
|
|
3
3
|
builder: e,
|
|
4
4
|
context: t,
|
|
@@ -27,7 +27,7 @@ const getFunctionArguments = ({
|
|
|
27
27
|
default:
|
|
28
28
|
return TARGET;
|
|
29
29
|
}
|
|
30
|
-
})(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, set = (e, t, s) => {
|
|
30
|
+
})(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, s) => {
|
|
31
31
|
if (Object(e) !== e)
|
|
32
32
|
return e;
|
|
33
33
|
const n = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
@@ -158,6 +158,7 @@ const getIsolateContext = () => IVM_CONTEXT || setIsolateContext(), runInNode =
|
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
160
|
export {
|
|
161
|
+
fastClone,
|
|
161
162
|
getBuilderGlobals,
|
|
162
163
|
getFunctionArguments,
|
|
163
164
|
parseCode,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const I="react",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?ce(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ue(){return c()&&window.self!==window.top}function U(e){return ue()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const de=()=>{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},le=()=>typeof navigator=="object"&&navigator.userAgent||"",F=()=>{const e=le(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=de();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,fe=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},N=({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){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},D=async e=>N(e),ge=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),he=[["secure",""],["SameSite","None"]],pe=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?he:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",fe(window.location.hostname)],...o];return ge(a)},j=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=pe({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},me="builder.tests",k=e=>`${me}.${e}`,ye=({contentId:e})=>D({name:k(e),canTrack:!0}),Se=({contentId:e})=>N({name:k(e),canTrack:!0}),we=({contentId:e,value:t})=>j({name:k(e),value:t,canTrack:!0}),K=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,be=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},_=e=>{const t=be(e);return we({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},W=({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":"")}},Ie=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!K(e))return e;const n=Se({contentId:e.id})||_({variations:e.variations,id:e.id}),r=W({item:e,testGroupId:n});return{...e,...r}},ve=async({item:e,canTrack:t})=>{if(!t||!K(e))return e;const r=await ye({contentId:e.id})||_({variations:e.variations,id:e.id}),o=W({item:e,testGroupId:r});return{...e,...o}},$=e=>p(e)?e:!0,Ee=e=>({type:"builder.registerComponent",data:G(e)}),ke=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function G(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ke(n):n))}function Pe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Ce(){const e=Pe().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 z=Ce();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,a,n)}:{...r,[a]:s}},{})}function J(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(a=>a.startsWith("$"))?J(o,s,n):n[s]=o}return n}const Oe="v3",T="builder.",Ae="options.",P=e=>{if(!e)return{};const t=V(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(T)){const o=r.replace(T,"").replace(Ae,"");n[o]=t[r]}}),n},Te=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},x=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Oe,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:O}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ie=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(ie)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof O=="boolean"&&i.searchParams.set("includeUnpublished",String(O)),g&&x(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&x(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ae={...Te(),...V(e.options||{})},A=E(ae);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=J({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},xe=e=>"results"in e;async function H(e){const t=await q({...e,limit:1});return t&&t[0]||null}const Re=async e=>{var s;const t=C(e);return await(await((s=e.fetch)!=null?s:z)(t.href,e.fetchOptions)).json()},X=async(e,t,n=C(e))=>{const r=$(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await ve({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function q(e){try{const t=C(e),n=await Re(e);return xe(n)?X(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}function Le(){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 Q(){return Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await D({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>Q(),Ue=({id:e,canTrack:t})=>j({name:Y,value:e,canTrack:t}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({key:e,canTrack:t})=>{var n;try{return t?(n=Z())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ne=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=Z())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},ee="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:ee,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>Q(),Ke=({id:e,canTrack:t})=>Ne({key:ee,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:F(),ownerId:n}});async function te(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!U()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>te({...e,canTrack:!0}),Ge=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function ne(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const ze="2.0.3",R={};function re(e,t){let n=R[e];if(n||(n=R[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 Je=()=>{re("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 B=!1;const oe=(e={})=>{var t,n;B||(B=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:ze,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!ne(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(l);let u,g=null;try{u=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(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,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},He=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};oe();const r=se({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},L={};function Xe(e){if(c()){Object.assign(L,e);const t={type:"builder.settingsChange",data:L};parent.postMessage(t,"*")}}const qe=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 H(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=X;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=Ee;exports.fetch=z;exports.fetchBuilderProps=qe;exports.fetchEntries=q;exports.fetchOneEntry=H;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=$;exports.getUserAttributes=F;exports.handleABTestingSync=Ie;exports.isBrowser=c;exports.isEditing=U;exports.isPreviewing=Be;exports.logger=d;exports.register=re;exports.registerInsertMenu=Je;exports.serializeComponentInfo=G;exports.setEditorSettings=Xe;exports.setupBrowserForEditing=oe;exports.subscribeToEditor=He;exports.track=$e;
|