@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,36 +1,36 @@
|
|
|
1
|
-
const b = "react",
|
|
1
|
+
const b = "react", te = (e) => {
|
|
2
2
|
const t = {};
|
|
3
3
|
return e.forEach((n, r) => {
|
|
4
4
|
t[r] = n;
|
|
5
5
|
}), t;
|
|
6
|
-
}, L = (e) => e instanceof URLSearchParams ?
|
|
6
|
+
}, L = (e) => e instanceof URLSearchParams ? te(e) : e, U = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
|
|
7
7
|
function c() {
|
|
8
8
|
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function ne() {
|
|
11
11
|
return c() && window.self !== window.top;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
15
|
-
|
|
13
|
+
function re(e) {
|
|
14
|
+
return ne() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
15
|
+
U(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function He(e) {
|
|
18
18
|
const t = e || (c() ? window.location.search : void 0);
|
|
19
|
-
return t ?
|
|
19
|
+
return t ? U(t).indexOf("builder.preview=") !== -1 : !1;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const Xe = (e) => ({
|
|
22
22
|
type: "builder.registerComponent",
|
|
23
|
-
data:
|
|
24
|
-
}),
|
|
23
|
+
data: V(e)
|
|
24
|
+
}), oe = (e) => {
|
|
25
25
|
const t = e.toString().trim();
|
|
26
26
|
return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ?
|
|
28
|
+
function V(e) {
|
|
29
|
+
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? oe(n) : n));
|
|
30
30
|
}
|
|
31
31
|
const x = {};
|
|
32
|
-
function
|
|
33
|
-
e === "plugin" && (t =
|
|
32
|
+
function se(e, t) {
|
|
33
|
+
e === "plugin" && (t = V(t));
|
|
34
34
|
let n = x[e];
|
|
35
35
|
if (n || (n = x[e] = []), n.push(t), c()) {
|
|
36
36
|
const r = {
|
|
@@ -48,7 +48,7 @@ function re(e, t) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const A = {};
|
|
51
|
-
function
|
|
51
|
+
function Je(e) {
|
|
52
52
|
if (c()) {
|
|
53
53
|
Object.assign(A, e);
|
|
54
54
|
const t = {
|
|
@@ -58,17 +58,17 @@ function Xe(e) {
|
|
|
58
58
|
parent.postMessage(t, "*");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
const T = "builder.",
|
|
61
|
+
const T = "builder.", ie = "options.", M = (e) => {
|
|
62
62
|
if (!e)
|
|
63
63
|
return {};
|
|
64
64
|
const t = L(e), n = {};
|
|
65
65
|
return Object.keys(t).forEach((r) => {
|
|
66
66
|
if (r.startsWith(T)) {
|
|
67
|
-
const o = r.replace(T, "").replace(
|
|
67
|
+
const o = r.replace(T, "").replace(ie, "");
|
|
68
68
|
n[o] = t[r];
|
|
69
69
|
}
|
|
70
70
|
}), n;
|
|
71
|
-
},
|
|
71
|
+
}, ae = () => {
|
|
72
72
|
if (!c())
|
|
73
73
|
return {};
|
|
74
74
|
const e = new URLSearchParams(window.location.search);
|
|
@@ -78,11 +78,11 @@ const T = "builder.", oe = "options.", M = (e) => {
|
|
|
78
78
|
error: (...e) => console.error(v, ...e),
|
|
79
79
|
warn: (...e) => console.warn(v, ...e),
|
|
80
80
|
debug: (...e) => console.debug(v, ...e)
|
|
81
|
-
}, N = "2.0.
|
|
81
|
+
}, N = "2.0.27", F = () => ({
|
|
82
82
|
"X-Builder-SDK": b,
|
|
83
83
|
"X-Builder-SDK-GEN": "2",
|
|
84
84
|
"X-Builder-SDK-Version": N
|
|
85
|
-
}), m = (e) => e != null,
|
|
85
|
+
}), m = (e) => e != null, ce = (e) => {
|
|
86
86
|
if (e === "localhost" || e === "127.0.0.1")
|
|
87
87
|
return e;
|
|
88
88
|
const t = e.split(".");
|
|
@@ -98,13 +98,13 @@ const T = "builder.", oe = "options.", M = (e) => {
|
|
|
98
98
|
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
}, K = async (e) => D(e),
|
|
101
|
+
}, K = async (e) => D(e), ue = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), de = [["secure", ""], ["SameSite", "None"]], le = ({
|
|
102
102
|
name: e,
|
|
103
103
|
value: t,
|
|
104
104
|
expires: n
|
|
105
105
|
}) => {
|
|
106
|
-
const o = (c() ? location.protocol === "https:" : !0) ?
|
|
107
|
-
return
|
|
106
|
+
const o = (c() ? location.protocol === "https:" : !0) ? de : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", ce(window.location.hostname)], ...o];
|
|
107
|
+
return ue(i);
|
|
108
108
|
}, j = async ({
|
|
109
109
|
name: e,
|
|
110
110
|
value: t,
|
|
@@ -114,7 +114,7 @@ const T = "builder.", oe = "options.", M = (e) => {
|
|
|
114
114
|
try {
|
|
115
115
|
if (!r)
|
|
116
116
|
return;
|
|
117
|
-
const o =
|
|
117
|
+
const o = le({
|
|
118
118
|
name: e,
|
|
119
119
|
value: t,
|
|
120
120
|
expires: n
|
|
@@ -124,16 +124,16 @@ const T = "builder.", oe = "options.", M = (e) => {
|
|
|
124
124
|
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
function
|
|
127
|
+
function fe() {
|
|
128
128
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
129
129
|
const t = Math.random() * 16 | 0;
|
|
130
130
|
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
function W() {
|
|
134
|
-
return
|
|
134
|
+
return fe().replace(/-/g, "");
|
|
135
135
|
}
|
|
136
|
-
const $ = "builderSessionId",
|
|
136
|
+
const $ = "builderSessionId", he = async ({
|
|
137
137
|
canTrack: e
|
|
138
138
|
}) => {
|
|
139
139
|
if (!e)
|
|
@@ -145,20 +145,20 @@ const $ = "builderSessionId", le = async ({
|
|
|
145
145
|
if (m(t))
|
|
146
146
|
return t;
|
|
147
147
|
{
|
|
148
|
-
const n =
|
|
149
|
-
return
|
|
148
|
+
const n = ge();
|
|
149
|
+
return pe({
|
|
150
150
|
id: n,
|
|
151
151
|
canTrack: e
|
|
152
152
|
}), n;
|
|
153
153
|
}
|
|
154
|
-
},
|
|
154
|
+
}, ge = () => W(), pe = ({
|
|
155
155
|
id: e,
|
|
156
156
|
canTrack: t
|
|
157
157
|
}) => j({
|
|
158
158
|
name: $,
|
|
159
159
|
value: e,
|
|
160
160
|
canTrack: t
|
|
161
|
-
}), _ = () => c() && typeof localStorage != "undefined" ? localStorage : void 0,
|
|
161
|
+
}), _ = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, me = ({
|
|
162
162
|
key: e,
|
|
163
163
|
canTrack: t
|
|
164
164
|
}) => {
|
|
@@ -169,7 +169,7 @@ const $ = "builderSessionId", le = async ({
|
|
|
169
169
|
console.debug("[LocalStorage] GET error: ", r);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
},
|
|
172
|
+
}, ye = ({
|
|
173
173
|
key: e,
|
|
174
174
|
canTrack: t,
|
|
175
175
|
value: n
|
|
@@ -180,39 +180,39 @@ const $ = "builderSessionId", le = async ({
|
|
|
180
180
|
} catch (o) {
|
|
181
181
|
console.debug("[LocalStorage] SET error: ", o);
|
|
182
182
|
}
|
|
183
|
-
}, G = "builderVisitorId",
|
|
183
|
+
}, G = "builderVisitorId", Se = ({
|
|
184
184
|
canTrack: e
|
|
185
185
|
}) => {
|
|
186
186
|
if (!e)
|
|
187
187
|
return;
|
|
188
|
-
const t =
|
|
188
|
+
const t = me({
|
|
189
189
|
key: G,
|
|
190
190
|
canTrack: e
|
|
191
191
|
});
|
|
192
192
|
if (m(t))
|
|
193
193
|
return t;
|
|
194
194
|
{
|
|
195
|
-
const n =
|
|
196
|
-
return
|
|
195
|
+
const n = we();
|
|
196
|
+
return be({
|
|
197
197
|
id: n,
|
|
198
198
|
canTrack: e
|
|
199
199
|
}), n;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, we = () => W(), be = ({
|
|
202
202
|
id: e,
|
|
203
203
|
canTrack: t
|
|
204
|
-
}) =>
|
|
204
|
+
}) => ye({
|
|
205
205
|
key: G,
|
|
206
206
|
value: e,
|
|
207
207
|
canTrack: t
|
|
208
|
-
}),
|
|
208
|
+
}), ve = () => {
|
|
209
209
|
if (c()) {
|
|
210
210
|
const e = new URL(location.href);
|
|
211
211
|
return e.pathname === "" && (e.pathname = "/"), e;
|
|
212
212
|
} else
|
|
213
213
|
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
214
|
-
},
|
|
215
|
-
const e =
|
|
214
|
+
}, Ie = () => typeof navigator == "object" && navigator.userAgent || "", ke = () => {
|
|
215
|
+
const e = Ie(), t = {
|
|
216
216
|
Android() {
|
|
217
217
|
return e.match(/Android/i);
|
|
218
218
|
},
|
|
@@ -231,13 +231,13 @@ const $ = "builderSessionId", le = async ({
|
|
|
231
231
|
any() {
|
|
232
232
|
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
|
|
233
233
|
}
|
|
234
|
-
}, n = e.match(/Tablet|iPad/i), r =
|
|
234
|
+
}, n = e.match(/Tablet|iPad/i), r = ve();
|
|
235
235
|
return {
|
|
236
236
|
urlPath: r == null ? void 0 : r.pathname,
|
|
237
237
|
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
238
238
|
device: n ? "tablet" : t.any() ? "mobile" : "desktop"
|
|
239
239
|
};
|
|
240
|
-
},
|
|
240
|
+
}, Ee = async ({
|
|
241
241
|
canTrack: e
|
|
242
242
|
}) => {
|
|
243
243
|
if (!e)
|
|
@@ -245,16 +245,16 @@ const $ = "builderSessionId", le = async ({
|
|
|
245
245
|
visitorId: void 0,
|
|
246
246
|
sessionId: void 0
|
|
247
247
|
};
|
|
248
|
-
const t = await
|
|
248
|
+
const t = await he({
|
|
249
249
|
canTrack: e
|
|
250
|
-
}), n =
|
|
250
|
+
}), n = Se({
|
|
251
251
|
canTrack: e
|
|
252
252
|
});
|
|
253
253
|
return {
|
|
254
254
|
sessionId: t,
|
|
255
255
|
visitorId: n
|
|
256
256
|
};
|
|
257
|
-
},
|
|
257
|
+
}, Oe = async ({
|
|
258
258
|
type: e,
|
|
259
259
|
canTrack: t,
|
|
260
260
|
apiKey: n,
|
|
@@ -268,45 +268,47 @@ const $ = "builderSessionId", le = async ({
|
|
|
268
268
|
url: location.href,
|
|
269
269
|
...r
|
|
270
270
|
},
|
|
271
|
-
...await
|
|
271
|
+
...await Ee({
|
|
272
272
|
canTrack: t
|
|
273
273
|
}),
|
|
274
|
-
userAttributes:
|
|
274
|
+
userAttributes: ke(),
|
|
275
275
|
ownerId: n
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
|
-
async function
|
|
279
|
-
|
|
278
|
+
async function Pe({
|
|
279
|
+
apiHost: e,
|
|
280
|
+
...t
|
|
281
|
+
}) {
|
|
282
|
+
if (!t.apiKey) {
|
|
280
283
|
f.error("Missing API key for track call. Please provide your API key.");
|
|
281
284
|
return;
|
|
282
285
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
});
|
|
286
|
+
return !t.canTrack || re() || !(c() || b === "reactNative") ? void 0 : fetch(`${e || "https://cdn.builder.io"}/api/v1/track`, {
|
|
287
|
+
method: "POST",
|
|
288
|
+
body: JSON.stringify({
|
|
289
|
+
events: [await Oe(t)]
|
|
290
|
+
}),
|
|
291
|
+
headers: {
|
|
292
|
+
"content-type": "application/json",
|
|
293
|
+
...F()
|
|
294
|
+
},
|
|
295
|
+
mode: "cors"
|
|
296
|
+
}).catch((r) => {
|
|
297
|
+
console.error("Failed to track: ", r);
|
|
298
|
+
});
|
|
297
299
|
}
|
|
298
|
-
const
|
|
300
|
+
const ze = (e) => Pe({
|
|
299
301
|
...e,
|
|
300
302
|
canTrack: !0
|
|
301
|
-
}),
|
|
302
|
-
function
|
|
303
|
+
}), Ce = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
304
|
+
function H(e, t) {
|
|
303
305
|
if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
|
|
304
306
|
return !1;
|
|
305
307
|
const n = new URL(t.origin), r = n.hostname;
|
|
306
|
-
return (e ||
|
|
308
|
+
return (e || Ce).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
307
309
|
}
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
+
const qe = () => {
|
|
311
|
+
se("insertMenu", {
|
|
310
312
|
name: "_default",
|
|
311
313
|
default: !0,
|
|
312
314
|
items: [{
|
|
@@ -329,7 +331,7 @@ const Je = () => {
|
|
|
329
331
|
});
|
|
330
332
|
};
|
|
331
333
|
let R = !1;
|
|
332
|
-
const
|
|
334
|
+
const xe = (e = {}) => {
|
|
333
335
|
var t, n;
|
|
334
336
|
R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
335
337
|
type: "builder.sdkInfo",
|
|
@@ -349,7 +351,7 @@ const Pe = (e = {}) => {
|
|
|
349
351
|
}
|
|
350
352
|
}, "*"), window.addEventListener("message", (r) => {
|
|
351
353
|
var s, i;
|
|
352
|
-
if (!
|
|
354
|
+
if (!H(e.trustedHosts, r))
|
|
353
355
|
return;
|
|
354
356
|
const {
|
|
355
357
|
data: o
|
|
@@ -390,12 +392,12 @@ const Pe = (e = {}) => {
|
|
|
390
392
|
}
|
|
391
393
|
}
|
|
392
394
|
})));
|
|
393
|
-
},
|
|
395
|
+
}, Ae = ({
|
|
394
396
|
model: e,
|
|
395
397
|
trustedHosts: t,
|
|
396
398
|
callbacks: n
|
|
397
399
|
}) => (r) => {
|
|
398
|
-
if (!
|
|
400
|
+
if (!H(t, r))
|
|
399
401
|
return;
|
|
400
402
|
const {
|
|
401
403
|
data: o
|
|
@@ -416,12 +418,12 @@ const Pe = (e = {}) => {
|
|
|
416
418
|
break;
|
|
417
419
|
}
|
|
418
420
|
}
|
|
419
|
-
},
|
|
421
|
+
}, Qe = (e, t, n) => {
|
|
420
422
|
if (!c)
|
|
421
423
|
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
422
424
|
};
|
|
423
|
-
|
|
424
|
-
const r =
|
|
425
|
+
xe();
|
|
426
|
+
const r = Ae({
|
|
425
427
|
callbacks: {
|
|
426
428
|
contentUpdate: t,
|
|
427
429
|
animation: () => {
|
|
@@ -435,24 +437,24 @@ const Pe = (e = {}) => {
|
|
|
435
437
|
return window.addEventListener("message", r), () => {
|
|
436
438
|
window.removeEventListener("message", r);
|
|
437
439
|
};
|
|
438
|
-
},
|
|
440
|
+
}, Te = "builder.tests", E = (e) => `${Te}.${e}`, Re = ({
|
|
439
441
|
contentId: e
|
|
440
442
|
}) => K({
|
|
441
443
|
name: E(e),
|
|
442
444
|
canTrack: !0
|
|
443
|
-
}),
|
|
445
|
+
}), Be = ({
|
|
444
446
|
contentId: e
|
|
445
447
|
}) => D({
|
|
446
448
|
name: E(e),
|
|
447
449
|
canTrack: !0
|
|
448
|
-
}),
|
|
450
|
+
}), Le = ({
|
|
449
451
|
contentId: e,
|
|
450
452
|
value: t
|
|
451
453
|
}) => j({
|
|
452
454
|
name: E(e),
|
|
453
455
|
value: t,
|
|
454
456
|
canTrack: !0
|
|
455
|
-
}),
|
|
457
|
+
}), X = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Ue = ({
|
|
456
458
|
id: e,
|
|
457
459
|
variations: t
|
|
458
460
|
}) => {
|
|
@@ -466,8 +468,8 @@ const Pe = (e = {}) => {
|
|
|
466
468
|
}
|
|
467
469
|
return e;
|
|
468
470
|
}, J = (e) => {
|
|
469
|
-
const t =
|
|
470
|
-
return
|
|
471
|
+
const t = Ue(e);
|
|
472
|
+
return Le({
|
|
471
473
|
contentId: e.id,
|
|
472
474
|
value: t
|
|
473
475
|
}).catch((n) => {
|
|
@@ -487,7 +489,7 @@ const Pe = (e = {}) => {
|
|
|
487
489
|
testVariationId: n.id,
|
|
488
490
|
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
489
491
|
};
|
|
490
|
-
},
|
|
492
|
+
}, Ye = ({
|
|
491
493
|
item: e,
|
|
492
494
|
canTrack: t
|
|
493
495
|
}) => {
|
|
@@ -495,9 +497,9 @@ const Pe = (e = {}) => {
|
|
|
495
497
|
return e;
|
|
496
498
|
if (!e)
|
|
497
499
|
return;
|
|
498
|
-
if (!
|
|
500
|
+
if (!X(e))
|
|
499
501
|
return e;
|
|
500
|
-
const n =
|
|
502
|
+
const n = Be({
|
|
501
503
|
contentId: e.id
|
|
502
504
|
}) || J({
|
|
503
505
|
variations: e.variations,
|
|
@@ -510,13 +512,13 @@ const Pe = (e = {}) => {
|
|
|
510
512
|
...e,
|
|
511
513
|
...r
|
|
512
514
|
};
|
|
513
|
-
},
|
|
515
|
+
}, Ve = async ({
|
|
514
516
|
item: e,
|
|
515
517
|
canTrack: t
|
|
516
518
|
}) => {
|
|
517
|
-
if (!t || !
|
|
519
|
+
if (!t || !X(e))
|
|
518
520
|
return e;
|
|
519
|
-
const r = await
|
|
521
|
+
const r = await Re({
|
|
520
522
|
contentId: e.id
|
|
521
523
|
}) || J({
|
|
522
524
|
variations: e.variations,
|
|
@@ -529,18 +531,18 @@ const Pe = (e = {}) => {
|
|
|
529
531
|
...e,
|
|
530
532
|
...o
|
|
531
533
|
};
|
|
532
|
-
},
|
|
533
|
-
function
|
|
534
|
+
}, Me = (e) => m(e) ? e : !0;
|
|
535
|
+
function Ne() {
|
|
534
536
|
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
535
537
|
}
|
|
536
|
-
function
|
|
537
|
-
const e =
|
|
538
|
+
function Fe() {
|
|
539
|
+
const e = Ne().fetch;
|
|
538
540
|
if (typeof e == "undefined")
|
|
539
541
|
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
540
542
|
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
541
543
|
return e;
|
|
542
544
|
}
|
|
543
|
-
const
|
|
545
|
+
const De = Fe();
|
|
544
546
|
function k(e, t = null, n = ".") {
|
|
545
547
|
return Object.keys(e).reduce((r, o) => {
|
|
546
548
|
const s = e[o], i = [t, o].filter(Boolean).join(n);
|
|
@@ -560,7 +562,7 @@ function q(e, t, n = {}) {
|
|
|
560
562
|
}
|
|
561
563
|
return n;
|
|
562
564
|
}
|
|
563
|
-
const
|
|
565
|
+
const Ke = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
|
|
564
566
|
const {
|
|
565
567
|
limit: t = 30,
|
|
566
568
|
userAttributes: n,
|
|
@@ -569,31 +571,32 @@ const Fe = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
|
|
|
569
571
|
apiKey: s,
|
|
570
572
|
enrich: i,
|
|
571
573
|
locale: u,
|
|
572
|
-
apiVersion: y =
|
|
574
|
+
apiVersion: y = Ke,
|
|
573
575
|
fields: p,
|
|
574
576
|
omit: I,
|
|
575
577
|
offset: d,
|
|
576
578
|
cacheSeconds: h,
|
|
577
579
|
staleCacheSeconds: g,
|
|
578
580
|
sort: S,
|
|
579
|
-
includeUnpublished: P
|
|
581
|
+
includeUnpublished: P,
|
|
582
|
+
apiHost: Q
|
|
580
583
|
} = e;
|
|
581
584
|
if (!s)
|
|
582
585
|
throw new Error("Missing API key");
|
|
583
586
|
if (!["v3"].includes(y))
|
|
584
587
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
585
|
-
const
|
|
586
|
-
if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(
|
|
588
|
+
const Y = t !== 1, Z = Q || "https://cdn.builder.io", a = new URL(`${Z}/api/${y}/content/${o}`);
|
|
589
|
+
if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(Y)), a.searchParams.set("includeRefs", String(!0)), u && a.searchParams.set("locale", u), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", I || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof P == "boolean" && a.searchParams.set("includeUnpublished", String(P)), h && B(h) && a.searchParams.set("cacheSeconds", String(h)), g && B(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
|
|
587
590
|
const l = k({
|
|
588
591
|
sort: S
|
|
589
592
|
});
|
|
590
593
|
for (const w in l)
|
|
591
594
|
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
592
595
|
}
|
|
593
|
-
const
|
|
594
|
-
...
|
|
596
|
+
const ee = {
|
|
597
|
+
...ae(),
|
|
595
598
|
...L(e.options || {})
|
|
596
|
-
}, C = k(
|
|
599
|
+
}, C = k(ee);
|
|
597
600
|
for (const l in C)
|
|
598
601
|
a.searchParams.set(l, String(C[l]));
|
|
599
602
|
if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
@@ -604,17 +607,17 @@ const Fe = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
|
|
|
604
607
|
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
605
608
|
}
|
|
606
609
|
return a;
|
|
607
|
-
},
|
|
608
|
-
async function
|
|
609
|
-
const t = await
|
|
610
|
+
}, je = (e) => "results" in e;
|
|
611
|
+
async function We(e) {
|
|
612
|
+
const t = await Ge({
|
|
610
613
|
...e,
|
|
611
614
|
limit: 1
|
|
612
615
|
});
|
|
613
616
|
return t && t[0] || null;
|
|
614
617
|
}
|
|
615
|
-
const
|
|
618
|
+
const $e = async (e) => {
|
|
616
619
|
var i, u;
|
|
617
|
-
const t = O(e), n = (i = e.fetch) != null ? i :
|
|
620
|
+
const t = O(e), n = (i = e.fetch) != null ? i : De, r = {
|
|
618
621
|
...e.fetchOptions,
|
|
619
622
|
headers: {
|
|
620
623
|
...(u = e.fetchOptions) == null ? void 0 : u.headers,
|
|
@@ -622,14 +625,14 @@ const je = async (e) => {
|
|
|
622
625
|
}
|
|
623
626
|
};
|
|
624
627
|
return await (await n(t.href, r)).json();
|
|
625
|
-
},
|
|
626
|
-
const r =
|
|
628
|
+
}, _e = async (e, t, n = O(e)) => {
|
|
629
|
+
const r = Me(e.canTrack);
|
|
627
630
|
if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
|
|
628
631
|
return t.results;
|
|
629
632
|
try {
|
|
630
633
|
const o = [];
|
|
631
634
|
for (const s of t.results)
|
|
632
|
-
o.push(await
|
|
635
|
+
o.push(await Ve({
|
|
633
636
|
item: s,
|
|
634
637
|
canTrack: r
|
|
635
638
|
}));
|
|
@@ -639,10 +642,10 @@ const je = async (e) => {
|
|
|
639
642
|
}
|
|
640
643
|
return t.results;
|
|
641
644
|
};
|
|
642
|
-
async function
|
|
645
|
+
async function Ge(e) {
|
|
643
646
|
try {
|
|
644
|
-
const t = O(e), n = await
|
|
645
|
-
return
|
|
647
|
+
const t = O(e), n = await $e(e);
|
|
648
|
+
return je(n) ? _e(e, n) : (f.error("Error fetching data. ", {
|
|
646
649
|
url: t,
|
|
647
650
|
content: n,
|
|
648
651
|
options: e
|
|
@@ -651,7 +654,7 @@ async function $e(e) {
|
|
|
651
654
|
return f.error("Error fetching data. ", t), null;
|
|
652
655
|
}
|
|
653
656
|
}
|
|
654
|
-
const
|
|
657
|
+
const Ze = async (e) => {
|
|
655
658
|
var r, o, s;
|
|
656
659
|
const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
|
|
657
660
|
...e,
|
|
@@ -668,32 +671,32 @@ const Qe = async (e) => {
|
|
|
668
671
|
return {
|
|
669
672
|
apiKey: n.apiKey,
|
|
670
673
|
model: n.model,
|
|
671
|
-
content: await
|
|
674
|
+
content: await We(n)
|
|
672
675
|
};
|
|
673
676
|
};
|
|
674
677
|
export {
|
|
675
678
|
b as TARGET,
|
|
676
|
-
|
|
677
|
-
|
|
679
|
+
_e as _processContentResult,
|
|
680
|
+
Pe as _track,
|
|
678
681
|
m as checkIsDefined,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
682
|
+
Ae as createEditorListener,
|
|
683
|
+
Xe as createRegisterComponentMessage,
|
|
684
|
+
Ze as fetchBuilderProps,
|
|
685
|
+
Ge as fetchEntries,
|
|
686
|
+
We as fetchOneEntry,
|
|
684
687
|
M as getBuilderSearchParams,
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
+
Me as getDefaultCanTrack,
|
|
689
|
+
ke as getUserAttributes,
|
|
690
|
+
Ye as handleABTestingSync,
|
|
688
691
|
c as isBrowser,
|
|
689
|
-
|
|
690
|
-
|
|
692
|
+
re as isEditing,
|
|
693
|
+
He as isPreviewing,
|
|
691
694
|
f as logger,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
695
|
+
se as register,
|
|
696
|
+
qe as registerInsertMenu,
|
|
697
|
+
V as serializeIncludingFunctions,
|
|
698
|
+
Je as setEditorSettings,
|
|
699
|
+
xe as setupBrowserForEditing,
|
|
700
|
+
Qe as subscribeToEditor,
|
|
701
|
+
ze as track
|
|
699
702
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const y="react",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 c(){return typeof window!="undefined"&&typeof document!="undefined"}function fe(){return c()&&window.self!==window.top}function F(e){return fe()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}function ge(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const he=e=>({type:"builder.registerComponent",data:k(e)}),pe=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"?pe(n):n))}const x={};function N(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 me(e){if(c()){Object.assign(B,e);const t={type:"builder.settingsChange",data:B};parent.postMessage(t,"*")}}const R="builder.",ye="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(ye,"");n[o]=t[r]}}),n},Se=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},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)},D="2.0.27",K=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":D}),p=e=>e!=null,we=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},j=({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}},W=async e=>j(e),be=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ie=[["secure",""],["SameSite","None"]],ve=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Ie:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",we(window.location.hostname)],...o];return be(i)},$=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ve({name:e,value:t,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function Ee(){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 _(){return Ee().replace(/-/g,"")}const G="builderSessionId",ke=async({canTrack:e})=>{if(!e)return;const t=await W({name:G,canTrack:e});if(p(t))return t;{const n=Pe();return Oe({id:n,canTrack:e}),n}},Pe=()=>_(),Oe=({id:e,canTrack:t})=>$({name:G,value:e,canTrack:t}),H=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Ce=({key:e,canTrack:t})=>{var n;try{return t?(n=H())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ae=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=H())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},X="builderVisitorId",Te=({canTrack:e})=>{if(!e)return;const t=Ce({key:X,canTrack:e});if(p(t))return t;{const n=xe();return Be({id:n,canTrack:e}),n}},xe=()=>_(),Be=({id:e,canTrack:t})=>Ae({key:X,value:e,canTrack:t}),Re=()=>{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||"",z=()=>{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()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=Re();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"}},Ue=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await ke({canTrack:e}),n=Te({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:z(),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",...K()},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=()=>{N("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:D,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})=>W({name:O(e),canTrack:!0}),We=({contentId:e})=>j({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={...Se(),...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,...K()}};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=he;exports.fetchBuilderProps=Ze;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ne;exports.getUserAttributes=z;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=ge;exports.logger=l;exports.register=N;exports.registerInsertMenu=Ne;exports.serializeIncludingFunctions=k;exports.setEditorSettings=me;exports.setupBrowserForEditing=Q;exports.subscribeToEditor=De;exports.track=Me;
|