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