@builder.io/sdk-react 3.0.1 → 3.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 +23 -23
- package/lib/browser/blocks-exports.mjs +678 -678
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/server-entry-5eafc5bd.cjs +2 -0
- package/lib/browser/server-entry-c904f136.js +748 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/accordion-032726a7.cjs +1 -0
- package/lib/edge/{accordion-1572cb0d.js → accordion-c786f197.js} +17 -16
- package/lib/edge/blocks-105e50e5.js +3534 -0
- package/lib/edge/blocks-827b0a87.cjs +30 -0
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-cf66cf8d.cjs → button-5cbfe22c.cjs} +1 -1
- package/lib/edge/{button-0709893d.js → button-f0e0ea72.js} +2 -2
- package/lib/edge/{columns-e234acc6.js → columns-9e187314.js} +14 -15
- package/lib/edge/columns-d07da61d.cjs +28 -0
- package/lib/edge/content-variants-0db90715.cjs +134 -0
- package/lib/edge/{content-variants-3ab9230f.js → content-variants-59dc0824.js} +209 -205
- package/lib/edge/{custom-code-6d9730ff.cjs → custom-code-8119ea3f.cjs} +1 -1
- package/lib/edge/form-79639135.cjs +1 -0
- package/lib/edge/{form-27bcc23a.js → form-7a7b98cf.js} +7 -8
- package/lib/edge/{get-class-prop-name-a3bd113c.js → get-class-prop-name-6b143ec7.js} +1 -1
- package/lib/edge/{get-class-prop-name-0b3d48a4.cjs → get-class-prop-name-8fb0e5ad.cjs} +1 -1
- package/lib/edge/{image-5c9e156f.js → image-2a2b26d2.js} +6 -6
- package/lib/edge/{image-94922c87.cjs → image-4db81d72.cjs} +3 -3
- package/lib/edge/{img-80be6914.js → img-2c4c6b78.js} +1 -1
- package/lib/edge/{img-e0c8f7f9.cjs → img-72bf9d21.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-f5ba6b1e.cjs → input-6eca8427.cjs} +1 -1
- package/lib/edge/{input-920922d5.js → input-752f3ce9.js} +1 -1
- package/lib/edge/{select-2ced1aca.cjs → select-49a73a0b.cjs} +1 -1
- package/lib/edge/{select-673864b7.js → select-a1d6e80e.js} +1 -1
- package/lib/edge/server-entry-35f12729.js +746 -0
- package/lib/edge/server-entry-6b2058e2.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/slot-2327e009.cjs +1 -0
- package/lib/edge/{slot-68f2b177.js → slot-b9bcbd41.js} +5 -6
- package/lib/edge/{symbol-7e260a70.js → symbol-33e7736f.js} +2 -2
- package/lib/edge/{symbol-ded9dba9.cjs → symbol-3527699b.cjs} +1 -1
- package/lib/edge/tabs-2df0eaa2.cjs +1 -0
- package/lib/edge/{tabs-5156494d.js → tabs-bc422e4c.js} +15 -16
- package/lib/edge/text-5915f038.js +17 -0
- package/lib/edge/text-e6dbb721.cjs +1 -0
- package/lib/node/blocks-exports.cjs +24 -24
- package/lib/node/blocks-exports.mjs +555 -555
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +3 -3
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/node/server-entry-606ce65a.cjs +2 -0
- package/lib/node/server-entry-d1ed35c5.js +749 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-8b303d4e.js → setIvm-6675714a.js} +1 -1
- package/lib/node/{setIvm-aba1bed8.cjs → setIvm-e4deba11.cjs} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-491a9b55.cjs → should-force-browser-runtime-in-node-03adae17.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-0a037bde.js → should-force-browser-runtime-in-node-75b2b3a0.js} +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/get-block-component-options.d.ts +2 -1
- package/types/functions/get-processed-block.d.ts +1 -6
- package/types/helpers/flatten.d.ts +6 -0
- package/types/server-index.d.ts +1 -1
- package/types/types/builder-content.d.ts +1 -0
- package/types/types/input.d.ts +10 -0
- package/lib/browser/server-entry-017b8439.js +0 -717
- package/lib/browser/server-entry-9f80066e.cjs +0 -2
- package/lib/edge/accordion-decb24cf.cjs +0 -1
- package/lib/edge/blocks-9c35be74.js +0 -916
- package/lib/edge/blocks-d3823063.cjs +0 -12
- package/lib/edge/columns-2fdf0656.cjs +0 -28
- package/lib/edge/content-variants-616a6c0f.cjs +0 -134
- package/lib/edge/evaluate-ccf1ad96.cjs +0 -19
- package/lib/edge/evaluate-f0b82ede.js +0 -2612
- package/lib/edge/form-7c61693d.cjs +0 -1
- package/lib/edge/server-entry-6c0047ea.js +0 -715
- package/lib/edge/server-entry-de142ee8.cjs +0 -2
- package/lib/edge/slot-cc8b4e5b.cjs +0 -1
- package/lib/edge/tabs-d422921f.cjs +0 -1
- package/lib/edge/text-27a917c0.js +0 -37
- package/lib/edge/text-5796f488.cjs +0 -1
- package/lib/node/server-entry-e91e06a3.cjs +0 -2
- package/lib/node/server-entry-fdedc1aa.js +0 -718
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
const b = "react", I = "[Builder.io]: ", f = {
|
|
2
|
-
log: (...e) => console.log(I, ...e),
|
|
3
|
-
error: (...e) => console.error(I, ...e),
|
|
4
|
-
warn: (...e) => console.warn(I, ...e),
|
|
5
|
-
debug: (...e) => console.debug(I, ...e)
|
|
6
|
-
};
|
|
7
|
-
function c() {
|
|
8
|
-
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
|
-
}
|
|
10
|
-
const re = (e) => {
|
|
11
|
-
const t = {};
|
|
12
|
-
return e.forEach((n, r) => {
|
|
13
|
-
t[r] = n;
|
|
14
|
-
}), t;
|
|
15
|
-
}, V = (e) => e instanceof URLSearchParams ? re(e) : e, F = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
|
|
16
|
-
function oe() {
|
|
17
|
-
return c() && window.self !== window.top;
|
|
18
|
-
}
|
|
19
|
-
function se(e) {
|
|
20
|
-
return oe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
21
|
-
F(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
22
|
-
}
|
|
23
|
-
const ie = () => {
|
|
24
|
-
if (c()) {
|
|
25
|
-
const e = new URL(location.href);
|
|
26
|
-
return e.pathname === "" && (e.pathname = "/"), e;
|
|
27
|
-
} else
|
|
28
|
-
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
29
|
-
}, ae = () => typeof navigator == "object" && navigator.userAgent || "", ce = () => {
|
|
30
|
-
const e = ae(), t = {
|
|
31
|
-
Android() {
|
|
32
|
-
return e.match(/Android/i);
|
|
33
|
-
},
|
|
34
|
-
BlackBerry() {
|
|
35
|
-
return e.match(/BlackBerry/i);
|
|
36
|
-
},
|
|
37
|
-
iOS() {
|
|
38
|
-
return e.match(/iPhone|iPod/i);
|
|
39
|
-
},
|
|
40
|
-
Opera() {
|
|
41
|
-
return e.match(/Opera Mini/i);
|
|
42
|
-
},
|
|
43
|
-
Windows() {
|
|
44
|
-
return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
|
|
45
|
-
},
|
|
46
|
-
any() {
|
|
47
|
-
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
|
|
48
|
-
}
|
|
49
|
-
}, n = e.match(/Tablet|iPad/i), r = ie();
|
|
50
|
-
return {
|
|
51
|
-
urlPath: r == null ? void 0 : r.pathname,
|
|
52
|
-
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
53
|
-
device: n ? "tablet" : t.any() ? "mobile" : "desktop"
|
|
54
|
-
};
|
|
55
|
-
}, m = (e) => e != null;
|
|
56
|
-
function Je(e) {
|
|
57
|
-
const t = e || (c() ? window.location.search : void 0);
|
|
58
|
-
return t ? F(t).indexOf("builder.preview=") !== -1 : !1;
|
|
59
|
-
}
|
|
60
|
-
const qe = (e) => ({
|
|
61
|
-
type: "builder.registerComponent",
|
|
62
|
-
data: M(e)
|
|
63
|
-
}), ue = (e) => {
|
|
64
|
-
const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t);
|
|
65
|
-
return `return (${!t.startsWith("function") && !t.startsWith("async") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`;
|
|
66
|
-
};
|
|
67
|
-
function M(e) {
|
|
68
|
-
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ue(n) : n));
|
|
69
|
-
}
|
|
70
|
-
const T = {};
|
|
71
|
-
function de(e, t) {
|
|
72
|
-
e === "plugin" && (t = M(t));
|
|
73
|
-
let n = T[e];
|
|
74
|
-
if (n || (n = T[e] = []), n.push(t), c()) {
|
|
75
|
-
const r = {
|
|
76
|
-
type: "builder.register",
|
|
77
|
-
data: {
|
|
78
|
-
type: e,
|
|
79
|
-
info: t
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
try {
|
|
83
|
-
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
84
|
-
} catch (o) {
|
|
85
|
-
console.debug("Could not postmessage", o);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const B = {};
|
|
90
|
-
function Qe(e) {
|
|
91
|
-
if (c()) {
|
|
92
|
-
Object.assign(B, e);
|
|
93
|
-
const t = {
|
|
94
|
-
type: "builder.settingsChange",
|
|
95
|
-
data: B
|
|
96
|
-
};
|
|
97
|
-
parent.postMessage(t, "*");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const R = "builder.", le = "options.", N = (e) => {
|
|
101
|
-
if (!e)
|
|
102
|
-
return {};
|
|
103
|
-
const t = V(e), n = {};
|
|
104
|
-
return Object.keys(t).forEach((r) => {
|
|
105
|
-
if (r.startsWith(R)) {
|
|
106
|
-
const o = r.replace(R, "").replace(le, "");
|
|
107
|
-
n[o] = t[r];
|
|
108
|
-
}
|
|
109
|
-
}), n;
|
|
110
|
-
}, fe = () => {
|
|
111
|
-
if (!c())
|
|
112
|
-
return {};
|
|
113
|
-
const e = new URLSearchParams(window.location.search);
|
|
114
|
-
return N(e);
|
|
115
|
-
}, D = "3.0.1", K = () => ({
|
|
116
|
-
"X-Builder-SDK": b,
|
|
117
|
-
"X-Builder-SDK-GEN": "2",
|
|
118
|
-
"X-Builder-SDK-Version": D
|
|
119
|
-
}), he = (e) => {
|
|
120
|
-
if (e === "localhost" || e === "127.0.0.1")
|
|
121
|
-
return e;
|
|
122
|
-
const t = e.split(".");
|
|
123
|
-
return t.length > 2 ? t.slice(1).join(".") : e;
|
|
124
|
-
}, j = ({
|
|
125
|
-
name: e,
|
|
126
|
-
canTrack: t
|
|
127
|
-
}) => {
|
|
128
|
-
var n;
|
|
129
|
-
try {
|
|
130
|
-
return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
|
|
131
|
-
} catch (r) {
|
|
132
|
-
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
}, W = async (e) => j(e), ge = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), pe = [["secure", ""], ["SameSite", "None"]], me = ({
|
|
136
|
-
name: e,
|
|
137
|
-
value: t,
|
|
138
|
-
expires: n
|
|
139
|
-
}) => {
|
|
140
|
-
const o = (c() ? location.protocol === "https:" : !0) ? pe : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", he(window.location.hostname)], ...o];
|
|
141
|
-
return ge(i);
|
|
142
|
-
}, $ = async ({
|
|
143
|
-
name: e,
|
|
144
|
-
value: t,
|
|
145
|
-
expires: n,
|
|
146
|
-
canTrack: r
|
|
147
|
-
}) => {
|
|
148
|
-
try {
|
|
149
|
-
if (!r)
|
|
150
|
-
return;
|
|
151
|
-
const o = me({
|
|
152
|
-
name: e,
|
|
153
|
-
value: t,
|
|
154
|
-
expires: n
|
|
155
|
-
});
|
|
156
|
-
document.cookie = o;
|
|
157
|
-
} catch (o) {
|
|
158
|
-
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
function ye() {
|
|
162
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
163
|
-
const t = Math.random() * 16 | 0;
|
|
164
|
-
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function G() {
|
|
168
|
-
return ye().replace(/-/g, "");
|
|
169
|
-
}
|
|
170
|
-
const _ = "builderSessionId", Se = async ({
|
|
171
|
-
canTrack: e
|
|
172
|
-
}) => {
|
|
173
|
-
if (!e)
|
|
174
|
-
return;
|
|
175
|
-
const t = await W({
|
|
176
|
-
name: _,
|
|
177
|
-
canTrack: e
|
|
178
|
-
});
|
|
179
|
-
if (m(t))
|
|
180
|
-
return t;
|
|
181
|
-
{
|
|
182
|
-
const n = we();
|
|
183
|
-
return be({
|
|
184
|
-
id: n,
|
|
185
|
-
canTrack: e
|
|
186
|
-
}), n;
|
|
187
|
-
}
|
|
188
|
-
}, we = () => G(), be = ({
|
|
189
|
-
id: e,
|
|
190
|
-
canTrack: t
|
|
191
|
-
}) => $({
|
|
192
|
-
name: _,
|
|
193
|
-
value: e,
|
|
194
|
-
canTrack: t
|
|
195
|
-
}), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ve = ({
|
|
196
|
-
key: e,
|
|
197
|
-
canTrack: t
|
|
198
|
-
}) => {
|
|
199
|
-
var n;
|
|
200
|
-
try {
|
|
201
|
-
return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
|
|
202
|
-
} catch (r) {
|
|
203
|
-
console.debug("[LocalStorage] GET error: ", r);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
}, Ie = ({
|
|
207
|
-
key: e,
|
|
208
|
-
canTrack: t,
|
|
209
|
-
value: n
|
|
210
|
-
}) => {
|
|
211
|
-
var r;
|
|
212
|
-
try {
|
|
213
|
-
t && ((r = H()) == null || r.setItem(e, n));
|
|
214
|
-
} catch (o) {
|
|
215
|
-
console.debug("[LocalStorage] SET error: ", o);
|
|
216
|
-
}
|
|
217
|
-
}, X = "builderVisitorId", ke = ({
|
|
218
|
-
canTrack: e
|
|
219
|
-
}) => {
|
|
220
|
-
if (!e)
|
|
221
|
-
return;
|
|
222
|
-
const t = ve({
|
|
223
|
-
key: X,
|
|
224
|
-
canTrack: e
|
|
225
|
-
});
|
|
226
|
-
if (m(t))
|
|
227
|
-
return t;
|
|
228
|
-
{
|
|
229
|
-
const n = Ee();
|
|
230
|
-
return Oe({
|
|
231
|
-
id: n,
|
|
232
|
-
canTrack: e
|
|
233
|
-
}), n;
|
|
234
|
-
}
|
|
235
|
-
}, Ee = () => G(), Oe = ({
|
|
236
|
-
id: e,
|
|
237
|
-
canTrack: t
|
|
238
|
-
}) => Ie({
|
|
239
|
-
key: X,
|
|
240
|
-
value: e,
|
|
241
|
-
canTrack: t
|
|
242
|
-
});
|
|
243
|
-
function Pe(e) {
|
|
244
|
-
var t;
|
|
245
|
-
typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && f.log(e);
|
|
246
|
-
}
|
|
247
|
-
const Ce = async ({
|
|
248
|
-
canTrack: e
|
|
249
|
-
}) => {
|
|
250
|
-
if (!e)
|
|
251
|
-
return {
|
|
252
|
-
visitorId: void 0,
|
|
253
|
-
sessionId: void 0
|
|
254
|
-
};
|
|
255
|
-
const t = await Se({
|
|
256
|
-
canTrack: e
|
|
257
|
-
}), n = ke({
|
|
258
|
-
canTrack: e
|
|
259
|
-
});
|
|
260
|
-
return {
|
|
261
|
-
sessionId: t,
|
|
262
|
-
visitorId: n
|
|
263
|
-
};
|
|
264
|
-
}, xe = async ({
|
|
265
|
-
type: e,
|
|
266
|
-
canTrack: t,
|
|
267
|
-
apiKey: n,
|
|
268
|
-
metadata: r,
|
|
269
|
-
...o
|
|
270
|
-
}) => ({
|
|
271
|
-
type: e,
|
|
272
|
-
data: {
|
|
273
|
-
...o,
|
|
274
|
-
metadata: {
|
|
275
|
-
url: location.href,
|
|
276
|
-
...r
|
|
277
|
-
},
|
|
278
|
-
...await Ce({
|
|
279
|
-
canTrack: t
|
|
280
|
-
}),
|
|
281
|
-
userAttributes: ce(),
|
|
282
|
-
ownerId: n
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
async function Ae({
|
|
286
|
-
apiHost: e,
|
|
287
|
-
...t
|
|
288
|
-
}) {
|
|
289
|
-
if (!t.apiKey) {
|
|
290
|
-
f.error("Missing API key for track call. Please provide your API key.");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
if (!t.canTrack || se() || !(c() || b === "reactNative"))
|
|
294
|
-
return;
|
|
295
|
-
const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
|
|
296
|
-
return Pe(r), fetch(r, {
|
|
297
|
-
method: "POST",
|
|
298
|
-
body: JSON.stringify({
|
|
299
|
-
events: [await xe(t)]
|
|
300
|
-
}),
|
|
301
|
-
headers: {
|
|
302
|
-
"content-type": "application/json",
|
|
303
|
-
...K()
|
|
304
|
-
},
|
|
305
|
-
mode: "cors"
|
|
306
|
-
}).catch((o) => {
|
|
307
|
-
console.error("Failed to track: ", o);
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
const Ye = (e) => Ae({
|
|
311
|
-
...e,
|
|
312
|
-
canTrack: !0
|
|
313
|
-
}), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
314
|
-
function z(e, t) {
|
|
315
|
-
if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
|
|
316
|
-
return !1;
|
|
317
|
-
const n = new URL(t.origin), r = n.hostname;
|
|
318
|
-
return (e || Te).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
319
|
-
}
|
|
320
|
-
const Ze = () => {
|
|
321
|
-
de("insertMenu", {
|
|
322
|
-
name: "_default",
|
|
323
|
-
default: !0,
|
|
324
|
-
items: [{
|
|
325
|
-
name: "Box"
|
|
326
|
-
}, {
|
|
327
|
-
name: "Text"
|
|
328
|
-
}, {
|
|
329
|
-
name: "Image"
|
|
330
|
-
}, {
|
|
331
|
-
name: "Columns"
|
|
332
|
-
}, {
|
|
333
|
-
name: "Core:Section"
|
|
334
|
-
}, {
|
|
335
|
-
name: "Core:Button"
|
|
336
|
-
}, {
|
|
337
|
-
name: "Embed"
|
|
338
|
-
}, {
|
|
339
|
-
name: "Custom Code"
|
|
340
|
-
}]
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
let U = !1;
|
|
344
|
-
const Be = (e = {}) => {
|
|
345
|
-
var t, n;
|
|
346
|
-
U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
347
|
-
type: "builder.sdkInfo",
|
|
348
|
-
data: {
|
|
349
|
-
target: b,
|
|
350
|
-
version: D,
|
|
351
|
-
supportsPatchUpdates: !1,
|
|
352
|
-
// Supports builder-model="..." attribute which is needed to
|
|
353
|
-
// scope our '+ add block' button styling
|
|
354
|
-
supportsAddBlockScoping: !0,
|
|
355
|
-
supportsCustomBreakpoints: !0
|
|
356
|
-
}
|
|
357
|
-
}, "*"), (n = window.parent) == null || n.postMessage({
|
|
358
|
-
type: "builder.updateContent",
|
|
359
|
-
data: {
|
|
360
|
-
options: e
|
|
361
|
-
}
|
|
362
|
-
}, "*"), window.addEventListener("message", (r) => {
|
|
363
|
-
var s, i;
|
|
364
|
-
if (!z(e.trustedHosts, r))
|
|
365
|
-
return;
|
|
366
|
-
const {
|
|
367
|
-
data: o
|
|
368
|
-
} = r;
|
|
369
|
-
if (o != null && o.type)
|
|
370
|
-
switch (o.type) {
|
|
371
|
-
case "builder.evaluate": {
|
|
372
|
-
const u = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(u);
|
|
373
|
-
let d, h = null;
|
|
374
|
-
try {
|
|
375
|
-
d = k.apply(null, y);
|
|
376
|
-
} catch (g) {
|
|
377
|
-
h = g;
|
|
378
|
-
}
|
|
379
|
-
h ? (s = window.parent) == null || s.postMessage({
|
|
380
|
-
type: "builder.evaluateError",
|
|
381
|
-
data: {
|
|
382
|
-
id: p,
|
|
383
|
-
error: h.message
|
|
384
|
-
}
|
|
385
|
-
}, "*") : d && typeof d.then == "function" ? d.then((g) => {
|
|
386
|
-
var S;
|
|
387
|
-
(S = window.parent) == null || S.postMessage({
|
|
388
|
-
type: "builder.evaluateResult",
|
|
389
|
-
data: {
|
|
390
|
-
id: p,
|
|
391
|
-
result: g
|
|
392
|
-
}
|
|
393
|
-
}, "*");
|
|
394
|
-
}).catch(console.error) : (i = window.parent) == null || i.postMessage({
|
|
395
|
-
type: "builder.evaluateResult",
|
|
396
|
-
data: {
|
|
397
|
-
result: d,
|
|
398
|
-
id: p
|
|
399
|
-
}
|
|
400
|
-
}, "*");
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
})));
|
|
405
|
-
}, Re = ({
|
|
406
|
-
model: e,
|
|
407
|
-
trustedHosts: t,
|
|
408
|
-
callbacks: n
|
|
409
|
-
}) => (r) => {
|
|
410
|
-
if (!z(t, r))
|
|
411
|
-
return;
|
|
412
|
-
const {
|
|
413
|
-
data: o
|
|
414
|
-
} = r;
|
|
415
|
-
if (o)
|
|
416
|
-
switch (o.type) {
|
|
417
|
-
case "builder.configureSdk": {
|
|
418
|
-
n.configureSdk(o.data);
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
case "builder.triggerAnimation": {
|
|
422
|
-
n.animation(o.data);
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
case "builder.contentUpdate": {
|
|
426
|
-
const s = o.data, i = s.key || s.alias || s.entry || s.modelName, u = s.data;
|
|
427
|
-
i === e && n.contentUpdate(u);
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}, et = (e, t, n) => {
|
|
432
|
-
if (!c)
|
|
433
|
-
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
434
|
-
};
|
|
435
|
-
Be();
|
|
436
|
-
const r = Re({
|
|
437
|
-
callbacks: {
|
|
438
|
-
contentUpdate: t,
|
|
439
|
-
animation: () => {
|
|
440
|
-
},
|
|
441
|
-
configureSdk: () => {
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
model: e,
|
|
445
|
-
trustedHosts: n == null ? void 0 : n.trustedHosts
|
|
446
|
-
});
|
|
447
|
-
return window.addEventListener("message", r), () => {
|
|
448
|
-
window.removeEventListener("message", r);
|
|
449
|
-
};
|
|
450
|
-
}, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
|
|
451
|
-
contentId: e
|
|
452
|
-
}) => W({
|
|
453
|
-
name: P(e),
|
|
454
|
-
canTrack: !0
|
|
455
|
-
}), Ve = ({
|
|
456
|
-
contentId: e
|
|
457
|
-
}) => j({
|
|
458
|
-
name: P(e),
|
|
459
|
-
canTrack: !0
|
|
460
|
-
}), Fe = ({
|
|
461
|
-
contentId: e,
|
|
462
|
-
value: t
|
|
463
|
-
}) => $({
|
|
464
|
-
name: P(e),
|
|
465
|
-
value: t,
|
|
466
|
-
canTrack: !0
|
|
467
|
-
}), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
|
|
468
|
-
id: e,
|
|
469
|
-
variations: t
|
|
470
|
-
}) => {
|
|
471
|
-
var o;
|
|
472
|
-
let n = 0;
|
|
473
|
-
const r = Math.random();
|
|
474
|
-
for (const s in t) {
|
|
475
|
-
const i = (o = t[s]) == null ? void 0 : o.testRatio;
|
|
476
|
-
if (n += i, r < n)
|
|
477
|
-
return s;
|
|
478
|
-
}
|
|
479
|
-
return e;
|
|
480
|
-
}, q = (e) => {
|
|
481
|
-
const t = Me(e);
|
|
482
|
-
return Fe({
|
|
483
|
-
contentId: e.id,
|
|
484
|
-
value: t
|
|
485
|
-
}).catch((n) => {
|
|
486
|
-
f.error("could not store A/B test variation: ", n);
|
|
487
|
-
}), t;
|
|
488
|
-
}, Q = ({
|
|
489
|
-
item: e,
|
|
490
|
-
testGroupId: t
|
|
491
|
-
}) => {
|
|
492
|
-
const n = e.variations[t];
|
|
493
|
-
return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
494
|
-
!n ? {
|
|
495
|
-
testVariationId: e.id,
|
|
496
|
-
testVariationName: "Default"
|
|
497
|
-
} : {
|
|
498
|
-
data: n.data,
|
|
499
|
-
testVariationId: n.id,
|
|
500
|
-
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
501
|
-
};
|
|
502
|
-
}, tt = ({
|
|
503
|
-
item: e,
|
|
504
|
-
canTrack: t
|
|
505
|
-
}) => {
|
|
506
|
-
if (!t)
|
|
507
|
-
return e;
|
|
508
|
-
if (!e)
|
|
509
|
-
return;
|
|
510
|
-
if (!J(e))
|
|
511
|
-
return e;
|
|
512
|
-
const n = Ve({
|
|
513
|
-
contentId: e.id
|
|
514
|
-
}) || q({
|
|
515
|
-
variations: e.variations,
|
|
516
|
-
id: e.id
|
|
517
|
-
}), r = Q({
|
|
518
|
-
item: e,
|
|
519
|
-
testGroupId: n
|
|
520
|
-
});
|
|
521
|
-
return {
|
|
522
|
-
...e,
|
|
523
|
-
...r
|
|
524
|
-
};
|
|
525
|
-
}, Ne = async ({
|
|
526
|
-
item: e,
|
|
527
|
-
canTrack: t
|
|
528
|
-
}) => {
|
|
529
|
-
if (!t || !J(e))
|
|
530
|
-
return e;
|
|
531
|
-
const r = await Le({
|
|
532
|
-
contentId: e.id
|
|
533
|
-
}) || q({
|
|
534
|
-
variations: e.variations,
|
|
535
|
-
id: e.id
|
|
536
|
-
}), o = Q({
|
|
537
|
-
item: e,
|
|
538
|
-
testGroupId: r
|
|
539
|
-
});
|
|
540
|
-
return {
|
|
541
|
-
...e,
|
|
542
|
-
...o
|
|
543
|
-
};
|
|
544
|
-
}, De = (e) => m(e) ? e : !0;
|
|
545
|
-
function Ke() {
|
|
546
|
-
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
547
|
-
}
|
|
548
|
-
function je() {
|
|
549
|
-
const e = Ke().fetch;
|
|
550
|
-
if (typeof e == "undefined")
|
|
551
|
-
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
552
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
553
|
-
return e;
|
|
554
|
-
}
|
|
555
|
-
const We = je();
|
|
556
|
-
function O(e, t = null, n = ".") {
|
|
557
|
-
return Object.keys(e).reduce((r, o) => {
|
|
558
|
-
const s = e[o], i = [t, o].filter(Boolean).join(n);
|
|
559
|
-
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
560
|
-
...r,
|
|
561
|
-
...O(s, i, n)
|
|
562
|
-
} : {
|
|
563
|
-
...r,
|
|
564
|
-
[i]: s
|
|
565
|
-
};
|
|
566
|
-
}, {});
|
|
567
|
-
}
|
|
568
|
-
function Y(e, t, n = {}) {
|
|
569
|
-
for (const r in e) {
|
|
570
|
-
const o = e[r], s = t ? t + "." + r : r;
|
|
571
|
-
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? Y(o, s, n) : n[s] = o;
|
|
572
|
-
}
|
|
573
|
-
return n;
|
|
574
|
-
}
|
|
575
|
-
const $e = "v3", L = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
|
|
576
|
-
const {
|
|
577
|
-
limit: t = 30,
|
|
578
|
-
userAttributes: n,
|
|
579
|
-
query: r,
|
|
580
|
-
model: o,
|
|
581
|
-
apiKey: s,
|
|
582
|
-
enrich: i,
|
|
583
|
-
locale: u,
|
|
584
|
-
apiVersion: y = $e,
|
|
585
|
-
fields: p,
|
|
586
|
-
omit: k,
|
|
587
|
-
offset: d,
|
|
588
|
-
cacheSeconds: h,
|
|
589
|
-
staleCacheSeconds: g,
|
|
590
|
-
sort: S,
|
|
591
|
-
includeUnpublished: x,
|
|
592
|
-
apiHost: Z
|
|
593
|
-
} = e;
|
|
594
|
-
if (!s)
|
|
595
|
-
throw new Error("Missing API key");
|
|
596
|
-
if (!["v3"].includes(y))
|
|
597
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
598
|
-
const ee = t !== 1, te = Z || "https://cdn.builder.io", a = new URL(`${te}/api/${y}/content/${o}`);
|
|
599
|
-
a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(ee)), a.searchParams.set("includeRefs", String(!0));
|
|
600
|
-
const E = u || (n == null ? void 0 : n.locale);
|
|
601
|
-
let v = n;
|
|
602
|
-
if (E && (a.searchParams.set("locale", E), v = {
|
|
603
|
-
locale: E,
|
|
604
|
-
...v
|
|
605
|
-
}), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof x == "boolean" && a.searchParams.set("includeUnpublished", String(x)), h && L(h) && a.searchParams.set("cacheSeconds", String(h)), g && L(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
|
|
606
|
-
const l = O({
|
|
607
|
-
sort: S
|
|
608
|
-
});
|
|
609
|
-
for (const w in l)
|
|
610
|
-
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
611
|
-
}
|
|
612
|
-
const ne = {
|
|
613
|
-
...fe(),
|
|
614
|
-
...V(e.options || {})
|
|
615
|
-
}, A = O(ne);
|
|
616
|
-
for (const l in A)
|
|
617
|
-
a.searchParams.set(l, String(A[l]));
|
|
618
|
-
if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
|
|
619
|
-
const l = Y({
|
|
620
|
-
query: r
|
|
621
|
-
});
|
|
622
|
-
for (const w in l)
|
|
623
|
-
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
624
|
-
}
|
|
625
|
-
return a;
|
|
626
|
-
}, Ge = (e) => "results" in e;
|
|
627
|
-
async function _e(e) {
|
|
628
|
-
const t = await ze({
|
|
629
|
-
...e,
|
|
630
|
-
limit: 1
|
|
631
|
-
});
|
|
632
|
-
return t && t[0] || null;
|
|
633
|
-
}
|
|
634
|
-
const He = async (e) => {
|
|
635
|
-
var i, u;
|
|
636
|
-
const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
|
|
637
|
-
...e.fetchOptions,
|
|
638
|
-
headers: {
|
|
639
|
-
...(u = e.fetchOptions) == null ? void 0 : u.headers,
|
|
640
|
-
...K()
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
return await (await n(t.href, r)).json();
|
|
644
|
-
}, Xe = async (e, t, n = C(e)) => {
|
|
645
|
-
const r = De(e.canTrack);
|
|
646
|
-
if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
|
|
647
|
-
return t.results;
|
|
648
|
-
try {
|
|
649
|
-
const o = [];
|
|
650
|
-
for (const s of t.results)
|
|
651
|
-
o.push(await Ne({
|
|
652
|
-
item: s,
|
|
653
|
-
canTrack: r
|
|
654
|
-
}));
|
|
655
|
-
t.results = o;
|
|
656
|
-
} catch (o) {
|
|
657
|
-
f.error("Could not process A/B tests. ", o);
|
|
658
|
-
}
|
|
659
|
-
return t.results;
|
|
660
|
-
};
|
|
661
|
-
async function ze(e) {
|
|
662
|
-
const t = C(e), n = await He(e);
|
|
663
|
-
if (!Ge(n))
|
|
664
|
-
throw f.error("Error fetching data. ", {
|
|
665
|
-
url: t,
|
|
666
|
-
content: n,
|
|
667
|
-
options: e
|
|
668
|
-
}), n;
|
|
669
|
-
return Xe(e, n);
|
|
670
|
-
}
|
|
671
|
-
const nt = async (e) => {
|
|
672
|
-
var r, o, s;
|
|
673
|
-
const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
|
|
674
|
-
...e,
|
|
675
|
-
apiKey: e.apiKey,
|
|
676
|
-
model: e.model || "page",
|
|
677
|
-
userAttributes: {
|
|
678
|
-
...e.userAttributes,
|
|
679
|
-
...t ? {
|
|
680
|
-
urlPath: t
|
|
681
|
-
} : {}
|
|
682
|
-
},
|
|
683
|
-
options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
|
|
684
|
-
};
|
|
685
|
-
return {
|
|
686
|
-
apiKey: n.apiKey,
|
|
687
|
-
model: n.model,
|
|
688
|
-
content: await _e(n)
|
|
689
|
-
};
|
|
690
|
-
};
|
|
691
|
-
export {
|
|
692
|
-
b as TARGET,
|
|
693
|
-
Xe as _processContentResult,
|
|
694
|
-
Ae as _track,
|
|
695
|
-
m as checkIsDefined,
|
|
696
|
-
Re as createEditorListener,
|
|
697
|
-
qe as createRegisterComponentMessage,
|
|
698
|
-
nt as fetchBuilderProps,
|
|
699
|
-
ze as fetchEntries,
|
|
700
|
-
_e as fetchOneEntry,
|
|
701
|
-
N as getBuilderSearchParams,
|
|
702
|
-
De as getDefaultCanTrack,
|
|
703
|
-
ce as getUserAttributes,
|
|
704
|
-
tt as handleABTestingSync,
|
|
705
|
-
c as isBrowser,
|
|
706
|
-
se as isEditing,
|
|
707
|
-
Je as isPreviewing,
|
|
708
|
-
Pe as logFetch,
|
|
709
|
-
f as logger,
|
|
710
|
-
de as register,
|
|
711
|
-
Ze as registerInsertMenu,
|
|
712
|
-
M as serializeIncludingFunctions,
|
|
713
|
-
Qe as setEditorSettings,
|
|
714
|
-
Be as setupBrowserForEditing,
|
|
715
|
-
et as subscribeToEditor,
|
|
716
|
-
Ye as track
|
|
717
|
-
};
|