@builder.io/sdk-react-nextjs 0.16.2 → 0.16.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.
Files changed (40) hide show
  1. package/lib/browser/blocks-exports.cjs +24 -24
  2. package/lib/browser/blocks-exports.mjs +93 -92
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/init.cjs +1 -1
  6. package/lib/browser/init.mjs +1 -1
  7. package/lib/browser/server-entry-8a47b9f9.cjs +2 -0
  8. package/lib/browser/{server-entry-242f596f.js → server-entry-b8ecec52.js} +152 -158
  9. package/lib/browser/server-entry.cjs +1 -1
  10. package/lib/browser/server-entry.mjs +1 -1
  11. package/lib/edge/blocks-exports.cjs +33 -33
  12. package/lib/edge/blocks-exports.mjs +60 -58
  13. package/lib/edge/index.cjs +1 -1
  14. package/lib/edge/index.mjs +1 -1
  15. package/lib/edge/init.cjs +1 -1
  16. package/lib/edge/init.mjs +1 -1
  17. package/lib/edge/server-entry-8a47b9f9.cjs +2 -0
  18. package/lib/{node/server-entry-fbf4e3a9.js → edge/server-entry-b8ecec52.js} +152 -158
  19. package/lib/edge/server-entry.cjs +1 -1
  20. package/lib/edge/server-entry.mjs +1 -1
  21. package/lib/node/blocks-exports.cjs +8 -8
  22. package/lib/node/blocks-exports.mjs +60 -59
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +2 -2
  25. package/lib/node/init.cjs +1 -1
  26. package/lib/node/init.mjs +2 -2
  27. package/lib/node/{node-runtime-e1243cd6.cjs → node-runtime-e2a21ba1.cjs} +2 -2
  28. package/lib/node/{node-runtime-42e494ca.js → node-runtime-ffe74dec.js} +3 -2
  29. package/lib/node/server-entry-8a47b9f9.cjs +2 -0
  30. package/lib/{edge/server-entry-242f596f.js → node/server-entry-b8ecec52.js} +152 -158
  31. package/lib/node/server-entry.cjs +1 -1
  32. package/lib/node/server-entry.mjs +1 -1
  33. package/package.json +1 -1
  34. package/types/cjs/constants/sdk-version.d.ts +1 -1
  35. package/types/cjs/functions/register-component.d.ts +2 -2
  36. package/types/esm/constants/sdk-version.d.ts +1 -1
  37. package/types/esm/functions/register-component.d.ts +2 -2
  38. package/lib/browser/server-entry-494604dc.cjs +0 -2
  39. package/lib/edge/server-entry-494604dc.cjs +0 -2
  40. package/lib/node/server-entry-db7b41aa.cjs +0 -2
@@ -1,4 +1,4 @@
1
- import { LRUCache as Q } from "lru-cache";
1
+ import { LRUCache as q } from "lru-cache";
2
2
  const v = "rsc", b = "[Builder.io]: ", l = {
3
3
  log: (...e) => console.log(b, ...e),
4
4
  error: (...e) => console.error(b, ...e),
@@ -8,27 +8,27 @@ const v = "rsc", b = "[Builder.io]: ", l = {
8
8
  function c() {
9
9
  return typeof window != "undefined" && typeof document != "undefined";
10
10
  }
11
- const Y = (e) => {
11
+ const Q = (e) => {
12
12
  const t = {};
13
13
  return e.forEach((n, r) => {
14
14
  t[r] = n;
15
15
  }), t;
16
- }, B = (e) => e instanceof URLSearchParams ? Y(e) : e, U = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
17
- function Z() {
16
+ }, B = (e) => e instanceof URLSearchParams ? Q(e) : e, U = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
17
+ function Y() {
18
18
  return c() && window.self !== window.top;
19
19
  }
20
- function ee(e) {
21
- return Z() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
20
+ function Z(e) {
21
+ return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
22
22
  U(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
23
23
  }
24
- const te = () => {
24
+ const ee = () => {
25
25
  if (c()) {
26
26
  const e = new URL(location.href);
27
27
  return e.pathname === "" && (e.pathname = "/"), e;
28
28
  } else
29
29
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
30
- }, ne = () => typeof navigator == "object" && navigator.userAgent || "", re = () => {
31
- const e = ne(), t = {
30
+ }, te = () => typeof navigator == "object" && navigator.userAgent || "", ne = () => {
31
+ const e = te(), t = {
32
32
  Android() {
33
33
  return e.match(/Android/i);
34
34
  },
@@ -47,18 +47,18 @@ const te = () => {
47
47
  any() {
48
48
  return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
49
49
  }
50
- }, n = e.match(/Tablet|iPad/i), r = te();
50
+ }, n = e.match(/Tablet|iPad/i), r = ee();
51
51
  return {
52
52
  urlPath: r == null ? void 0 : r.pathname,
53
53
  host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
54
54
  device: n ? "tablet" : t.any() ? "mobile" : "desktop"
55
55
  };
56
- }, m = (e) => e != null, V = (e) => JSON.parse(JSON.stringify(e)), oe = (e) => {
56
+ }, m = (e) => e != null, re = (e) => {
57
57
  if (e === "localhost" || e === "127.0.0.1")
58
58
  return e;
59
59
  const t = e.split(".");
60
60
  return t.length > 2 ? t.slice(1).join(".") : e;
61
- }, M = ({
61
+ }, V = ({
62
62
  name: e,
63
63
  canTrack: t
64
64
  }) => {
@@ -69,14 +69,14 @@ const te = () => {
69
69
  l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
70
70
  return;
71
71
  }
72
- }, _ = async (e) => M(e), se = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ie = [["secure", ""], ["SameSite", "None"]], ae = ({
72
+ }, M = async (e) => V(e), oe = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), se = [["secure", ""], ["SameSite", "None"]], ie = ({
73
73
  name: e,
74
74
  value: t,
75
75
  expires: n
76
76
  }) => {
77
- const o = (c() ? location.protocol === "https:" : !0) ? ie : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", oe(window.location.hostname)], ...o];
78
- return se(i);
79
- }, N = async ({
77
+ const o = (c() ? location.protocol === "https:" : !0) ? se : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", re(window.location.hostname)], ...o];
78
+ return oe(i);
79
+ }, _ = async ({
80
80
  name: e,
81
81
  value: t,
82
82
  expires: n,
@@ -85,7 +85,7 @@ const te = () => {
85
85
  try {
86
86
  if (!r)
87
87
  return;
88
- const o = ae({
88
+ const o = ie({
89
89
  name: e,
90
90
  value: t,
91
91
  expires: n
@@ -94,24 +94,24 @@ const te = () => {
94
94
  } catch (o) {
95
95
  l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
96
96
  }
97
- }, ce = "builder.tests", k = (e) => `${ce}.${e}`, ue = ({
97
+ }, ae = "builder.tests", k = (e) => `${ae}.${e}`, ce = ({
98
98
  contentId: e
99
- }) => _({
99
+ }) => M({
100
100
  name: k(e),
101
101
  canTrack: !0
102
- }), de = ({
102
+ }), ue = ({
103
103
  contentId: e
104
- }) => M({
104
+ }) => V({
105
105
  name: k(e),
106
106
  canTrack: !0
107
- }), le = ({
107
+ }), de = ({
108
108
  contentId: e,
109
109
  value: t
110
- }) => N({
110
+ }) => _({
111
111
  name: k(e),
112
112
  value: t,
113
113
  canTrack: !0
114
- }), F = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, fe = ({
114
+ }), N = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, le = ({
115
115
  id: e,
116
116
  variations: t
117
117
  }) => {
@@ -124,15 +124,15 @@ const te = () => {
124
124
  return s;
125
125
  }
126
126
  return e;
127
- }, D = (e) => {
128
- const t = fe(e);
129
- return le({
127
+ }, F = (e) => {
128
+ const t = le(e);
129
+ return de({
130
130
  contentId: e.id,
131
131
  value: t
132
132
  }).catch((n) => {
133
133
  l.error("could not store A/B test variation: ", n);
134
134
  }), t;
135
- }, j = ({
135
+ }, D = ({
136
136
  item: e,
137
137
  testGroupId: t
138
138
  }) => {
@@ -146,7 +146,7 @@ const te = () => {
146
146
  testVariationId: n.id,
147
147
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
148
148
  };
149
- }, qe = ({
149
+ }, ze = ({
150
150
  item: e,
151
151
  canTrack: t
152
152
  }) => {
@@ -154,14 +154,14 @@ const te = () => {
154
154
  return e;
155
155
  if (!e)
156
156
  return;
157
- if (!F(e))
157
+ if (!N(e))
158
158
  return e;
159
- const n = de({
159
+ const n = ue({
160
160
  contentId: e.id
161
- }) || D({
161
+ }) || F({
162
162
  variations: e.variations,
163
163
  id: e.id
164
- }), r = j({
164
+ }), r = D({
165
165
  item: e,
166
166
  testGroupId: n
167
167
  });
@@ -169,18 +169,18 @@ const te = () => {
169
169
  ...e,
170
170
  ...r
171
171
  };
172
- }, he = async ({
172
+ }, fe = async ({
173
173
  item: e,
174
174
  canTrack: t
175
175
  }) => {
176
- if (!t || !F(e))
176
+ if (!t || !N(e))
177
177
  return e;
178
- const r = await ue({
178
+ const r = await ce({
179
179
  contentId: e.id
180
- }) || D({
180
+ }) || F({
181
181
  variations: e.variations,
182
182
  id: e.id
183
- }), o = j({
183
+ }), o = D({
184
184
  item: e,
185
185
  testGroupId: r
186
186
  });
@@ -188,48 +188,43 @@ const te = () => {
188
188
  ...e,
189
189
  ...o
190
190
  };
191
- }, ge = (e) => m(e) ? e : !0, Qe = (e) => ({
191
+ }, he = (e) => m(e) ? e : !0, Xe = (e) => ({
192
192
  type: "builder.registerComponent",
193
- data: ye(e)
194
- }), pe = (e) => {
193
+ data: pe(e)
194
+ }), ge = (e) => {
195
195
  const t = e.toString().trim();
196
196
  return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
197
- }, me = (e) => typeof e == "function" ? pe(e) : V(e), ye = ({
198
- inputs: e,
199
- ...t
200
- }) => ({
201
- ...V(t),
202
- inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
203
- ...r,
204
- [o]: me(s)
205
- }), {}))
206
- }), we = (e) => {
197
+ };
198
+ function pe(e) {
199
+ return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ge(n) : n));
200
+ }
201
+ const me = (e) => {
207
202
  const t = e.get("preview"), n = e.get("overrides." + t);
208
203
  return n || l.warn("No previewed ID found in search params."), n;
209
204
  };
210
- function Se() {
211
- globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new Q({
205
+ function ye() {
206
+ globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new q({
212
207
  max: 500,
213
208
  // how long to live in ms
214
209
  ttl: 1e3 * 60 * 5
215
210
  }));
216
211
  }
217
- function be(e) {
218
- Se();
219
- const t = we(e);
212
+ function we(e) {
213
+ ye();
214
+ const t = me(e);
220
215
  return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
221
216
  }
222
- function ve() {
217
+ function Se() {
223
218
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
224
219
  }
225
- function Ie() {
226
- const e = ve().fetch;
220
+ function be() {
221
+ const e = Se().fetch;
227
222
  if (typeof e == "undefined")
228
223
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
229
224
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
230
225
  return e;
231
226
  }
232
- const Ee = Ie();
227
+ const ve = be();
233
228
  function E(e, t = null, n = ".") {
234
229
  return Object.keys(e).reduce((r, o) => {
235
230
  const s = e[o], i = [t, o].filter(Boolean).join(n);
@@ -242,28 +237,28 @@ function E(e, t = null, n = ".") {
242
237
  };
243
238
  }, {});
244
239
  }
245
- function K(e, t, n = {}) {
240
+ function j(e, t, n = {}) {
246
241
  for (const r in e) {
247
242
  const o = e[r], s = t ? t + "." + r : r;
248
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? K(o, s, n) : n[s] = o;
243
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? j(o, s, n) : n[s] = o;
249
244
  }
250
245
  return n;
251
246
  }
252
- const ke = "v3", R = "builder.", Ce = "options.", W = (e) => {
247
+ const Ie = "v3", R = "builder.", Ee = "options.", K = (e) => {
253
248
  if (!e)
254
249
  return {};
255
250
  const t = B(e), n = {};
256
251
  return Object.keys(t).forEach((r) => {
257
252
  if (r.startsWith(R)) {
258
- const o = r.replace(R, "").replace(Ce, "");
253
+ const o = r.replace(R, "").replace(Ee, "");
259
254
  n[o] = t[r];
260
255
  }
261
256
  }), n;
262
- }, Pe = () => {
257
+ }, ke = () => {
263
258
  if (!c())
264
259
  return {};
265
260
  const e = new URLSearchParams(window.location.search);
266
- return W(e);
261
+ return K(e);
267
262
  }, x = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
268
263
  const {
269
264
  limit: t = 30,
@@ -273,7 +268,7 @@ const ke = "v3", R = "builder.", Ce = "options.", W = (e) => {
273
268
  apiKey: s,
274
269
  enrich: i,
275
270
  locale: u,
276
- apiVersion: y = ke,
271
+ apiVersion: y = Ie,
277
272
  fields: p,
278
273
  omit: I,
279
274
  offset: d,
@@ -286,46 +281,46 @@ const ke = "v3", R = "builder.", Ce = "options.", W = (e) => {
286
281
  throw new Error("Missing API key");
287
282
  if (!["v3"].includes(y))
288
283
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
289
- const X = t !== 1, a = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
290
- if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(X)), 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 && x(h) && a.searchParams.set("cacheSeconds", String(h)), g && x(g) && a.searchParams.set("staleCacheSeconds", String(g)), w) {
284
+ const z = t !== 1, a = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
285
+ if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(z)), 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 && x(h) && a.searchParams.set("cacheSeconds", String(h)), g && x(g) && a.searchParams.set("staleCacheSeconds", String(g)), w) {
291
286
  const f = E({
292
287
  sort: w
293
288
  });
294
289
  for (const S in f)
295
290
  a.searchParams.set(S, JSON.stringify(f[S]));
296
291
  }
297
- const q = {
298
- ...Pe(),
292
+ const X = {
293
+ ...ke(),
299
294
  ...B(e.options || {})
300
- }, O = E(q);
295
+ }, O = E(X);
301
296
  for (const f in O)
302
297
  a.searchParams.set(f, String(O[f]));
303
298
  if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
304
- const f = K({
299
+ const f = j({
305
300
  query: r
306
301
  });
307
302
  for (const S in f)
308
303
  a.searchParams.set(S, JSON.stringify(f[S]));
309
304
  }
310
305
  return a;
311
- }, Oe = (e) => "results" in e;
312
- async function Re(e) {
313
- const t = await Te({
306
+ }, Ce = (e) => "results" in e;
307
+ async function Pe(e) {
308
+ const t = await xe({
314
309
  ...e,
315
310
  limit: 1
316
311
  });
317
312
  return t && t[0] || null;
318
313
  }
319
- const xe = async (e) => {
314
+ const Oe = async (e) => {
320
315
  var s;
321
316
  const t = C(e);
322
- return await (await ((s = e.fetch) != null ? s : Ee)(t.href, e.fetchOptions)).json();
323
- }, Ae = async (e, t, n = C(e)) => {
324
- const r = ge(e.canTrack);
317
+ return await (await ((s = e.fetch) != null ? s : ve)(t.href, e.fetchOptions)).json();
318
+ }, Re = async (e, t, n = C(e)) => {
319
+ const r = he(e.canTrack);
325
320
  if (n.search.includes("preview=")) {
326
321
  const s = [];
327
322
  for (const i of t.results) {
328
- const u = be(n.searchParams);
323
+ const u = we(n.searchParams);
329
324
  s.push(u || i);
330
325
  }
331
326
  t.results = s;
@@ -335,7 +330,7 @@ const xe = async (e) => {
335
330
  try {
336
331
  const s = [];
337
332
  for (const i of t.results)
338
- s.push(await he({
333
+ s.push(await fe({
339
334
  item: i,
340
335
  canTrack: r
341
336
  }));
@@ -345,10 +340,10 @@ const xe = async (e) => {
345
340
  }
346
341
  return t.results;
347
342
  };
348
- async function Te(e) {
343
+ async function xe(e) {
349
344
  try {
350
- const t = C(e), n = await xe(e);
351
- return Oe(n) ? Ae(e, n) : (l.error("Error fetching data. ", {
345
+ const t = C(e), n = await Oe(e);
346
+ return Ce(n) ? Re(e, n) : (l.error("Error fetching data. ", {
352
347
  url: t,
353
348
  content: n,
354
349
  options: e
@@ -357,92 +352,92 @@ async function Te(e) {
357
352
  return l.error("Error fetching data. ", t), null;
358
353
  }
359
354
  }
360
- function Ye(e) {
355
+ function qe(e) {
361
356
  const t = e || (c() ? window.location.search : void 0);
362
357
  return t ? U(t).indexOf("builder.preview=") !== -1 : !1;
363
358
  }
364
- function Le() {
359
+ function Ae() {
365
360
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
366
361
  const t = Math.random() * 16 | 0;
367
362
  return (e == "x" ? t : t & 3 | 8).toString(16);
368
363
  });
369
364
  }
370
- function $() {
371
- return Le().replace(/-/g, "");
365
+ function W() {
366
+ return Ae().replace(/-/g, "");
372
367
  }
373
- const G = "builderSessionId", Be = async ({
368
+ const $ = "builderSessionId", Te = async ({
374
369
  canTrack: e
375
370
  }) => {
376
371
  if (!e)
377
372
  return;
378
- const t = await _({
379
- name: G,
373
+ const t = await M({
374
+ name: $,
380
375
  canTrack: e
381
376
  });
382
377
  if (m(t))
383
378
  return t;
384
379
  {
385
- const n = Ue();
386
- return Ve({
380
+ const n = Le();
381
+ return Be({
387
382
  id: n,
388
383
  canTrack: e
389
384
  }), n;
390
385
  }
391
- }, Ue = () => $(), Ve = ({
386
+ }, Le = () => W(), Be = ({
392
387
  id: e,
393
388
  canTrack: t
394
- }) => N({
395
- name: G,
389
+ }) => _({
390
+ name: $,
396
391
  value: e,
397
392
  canTrack: t
398
- }), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Me = ({
393
+ }), G = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Ue = ({
399
394
  key: e,
400
395
  canTrack: t
401
396
  }) => {
402
397
  var n;
403
398
  try {
404
- return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
399
+ return t ? (n = G()) == null ? void 0 : n.getItem(e) : void 0;
405
400
  } catch (r) {
406
401
  console.debug("[LocalStorage] GET error: ", r);
407
402
  return;
408
403
  }
409
- }, _e = ({
404
+ }, Ve = ({
410
405
  key: e,
411
406
  canTrack: t,
412
407
  value: n
413
408
  }) => {
414
409
  var r;
415
410
  try {
416
- t && ((r = H()) == null || r.setItem(e, n));
411
+ t && ((r = G()) == null || r.setItem(e, n));
417
412
  } catch (o) {
418
413
  console.debug("[LocalStorage] SET error: ", o);
419
414
  }
420
- }, z = "builderVisitorId", Ne = ({
415
+ }, H = "builderVisitorId", Me = ({
421
416
  canTrack: e
422
417
  }) => {
423
418
  if (!e)
424
419
  return;
425
- const t = Me({
426
- key: z,
420
+ const t = Ue({
421
+ key: H,
427
422
  canTrack: e
428
423
  });
429
424
  if (m(t))
430
425
  return t;
431
426
  {
432
- const n = Fe();
433
- return De({
427
+ const n = _e();
428
+ return Ne({
434
429
  id: n,
435
430
  canTrack: e
436
431
  }), n;
437
432
  }
438
- }, Fe = () => $(), De = ({
433
+ }, _e = () => W(), Ne = ({
439
434
  id: e,
440
435
  canTrack: t
441
- }) => _e({
442
- key: z,
436
+ }) => Ve({
437
+ key: H,
443
438
  value: e,
444
439
  canTrack: t
445
- }), je = async ({
440
+ }), Fe = async ({
446
441
  canTrack: e
447
442
  }) => {
448
443
  if (!e)
@@ -450,16 +445,16 @@ const G = "builderSessionId", Be = async ({
450
445
  visitorId: void 0,
451
446
  sessionId: void 0
452
447
  };
453
- const t = await Be({
448
+ const t = await Te({
454
449
  canTrack: e
455
- }), n = Ne({
450
+ }), n = Me({
456
451
  canTrack: e
457
452
  });
458
453
  return {
459
454
  sessionId: t,
460
455
  visitorId: n
461
456
  };
462
- }, Ke = async ({
457
+ }, De = async ({
463
458
  type: e,
464
459
  canTrack: t,
465
460
  apiKey: n,
@@ -473,23 +468,23 @@ const G = "builderSessionId", Be = async ({
473
468
  url: location.href,
474
469
  ...r
475
470
  },
476
- ...await je({
471
+ ...await Fe({
477
472
  canTrack: t
478
473
  }),
479
- userAttributes: re(),
474
+ userAttributes: ne(),
480
475
  ownerId: n
481
476
  }
482
477
  });
483
- async function We(e) {
478
+ async function je(e) {
484
479
  if (!e.apiKey) {
485
480
  l.error("Missing API key for track call. Please provide your API key.");
486
481
  return;
487
482
  }
488
- if (e.canTrack && !ee() && (c() || v === "reactNative"))
483
+ if (e.canTrack && !Z() && (c() || v === "reactNative"))
489
484
  return fetch("https://cdn.builder.io/api/v1/track", {
490
485
  method: "POST",
491
486
  body: JSON.stringify({
492
- events: [await Ke(e)]
487
+ events: [await De(e)]
493
488
  }),
494
489
  headers: {
495
490
  "content-type": "application/json"
@@ -499,18 +494,18 @@ async function We(e) {
499
494
  console.error("Failed to track: ", t);
500
495
  });
501
496
  }
502
- const Ze = (e) => We({
497
+ const Qe = (e) => je({
503
498
  ...e,
504
499
  canTrack: !0
505
- }), $e = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
500
+ }), Ke = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
506
501
  function J(e, t) {
507
502
  if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
508
503
  return !1;
509
504
  const n = new URL(t.origin), r = n.hostname;
510
- return (e || $e).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
505
+ return (e || Ke).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
511
506
  }
512
- const Ge = "0.16.2", A = {};
513
- function He(e, t) {
507
+ const We = "0.16.3", A = {};
508
+ function $e(e, t) {
514
509
  let n = A[e];
515
510
  if (n || (n = A[e] = []), n.push(t), c()) {
516
511
  const r = {
@@ -527,8 +522,8 @@ function He(e, t) {
527
522
  }
528
523
  }
529
524
  }
530
- const et = () => {
531
- He("insertMenu", {
525
+ const Ye = () => {
526
+ $e("insertMenu", {
532
527
  name: "_default",
533
528
  default: !0,
534
529
  items: [{
@@ -551,13 +546,13 @@ const et = () => {
551
546
  });
552
547
  };
553
548
  let T = !1;
554
- const ze = (e = {}) => {
549
+ const Ge = (e = {}) => {
555
550
  var t, n;
556
551
  T || (T = !0, c() && ((t = window.parent) == null || t.postMessage({
557
552
  type: "builder.sdkInfo",
558
553
  data: {
559
554
  target: v,
560
- version: Ge,
555
+ version: We,
561
556
  supportsPatchUpdates: !1,
562
557
  // Supports builder-model="..." attribute which is needed to
563
558
  // scope our '+ add block' button styling
@@ -612,7 +607,7 @@ const ze = (e = {}) => {
612
607
  }
613
608
  }
614
609
  })));
615
- }, Je = ({
610
+ }, He = ({
616
611
  model: e,
617
612
  trustedHosts: t,
618
613
  callbacks: n
@@ -638,12 +633,12 @@ const ze = (e = {}) => {
638
633
  break;
639
634
  }
640
635
  }
641
- }, tt = (e, t, n) => {
636
+ }, Ze = (e, t, n) => {
642
637
  if (!c)
643
638
  return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
644
639
  };
645
- ze();
646
- const r = Je({
640
+ Ge();
641
+ const r = He({
647
642
  callbacks: {
648
643
  contentUpdate: t,
649
644
  animation: () => {
@@ -658,7 +653,7 @@ const ze = (e = {}) => {
658
653
  window.removeEventListener("message", r);
659
654
  };
660
655
  }, L = {};
661
- function nt(e) {
656
+ function et(e) {
662
657
  if (c()) {
663
658
  Object.assign(L, e);
664
659
  const t = {
@@ -668,7 +663,7 @@ function nt(e) {
668
663
  parent.postMessage(t, "*");
669
664
  }
670
665
  }
671
- const rt = async (e) => {
666
+ const tt = async (e) => {
672
667
  var r, o, s;
673
668
  const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
674
669
  ...e,
@@ -680,41 +675,40 @@ const rt = async (e) => {
680
675
  urlPath: t
681
676
  } : {}
682
677
  },
683
- options: W(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
678
+ options: K(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
684
679
  };
685
680
  return {
686
681
  apiKey: n.apiKey,
687
682
  model: n.model,
688
- content: await Re(n)
683
+ content: await Pe(n)
689
684
  };
690
685
  };
691
686
  export {
692
687
  b as MSG_PREFIX,
693
688
  v as TARGET,
694
- Ae as _processContentResult,
695
- We as _track,
689
+ Re as _processContentResult,
690
+ je as _track,
696
691
  m as checkIsDefined,
697
- Je as createEditorListener,
698
- Qe as createRegisterComponentMessage,
699
- V as fastClone,
700
- Ee as fetch,
701
- rt as fetchBuilderProps,
702
- Te as fetchEntries,
703
- Re as fetchOneEntry,
704
- W as getBuilderSearchParams,
705
- ge as getDefaultCanTrack,
706
- re as getUserAttributes,
707
- qe as handleABTestingSync,
708
- Se as init,
692
+ He as createEditorListener,
693
+ Xe as createRegisterComponentMessage,
694
+ ve as fetch,
695
+ tt as fetchBuilderProps,
696
+ xe as fetchEntries,
697
+ Pe as fetchOneEntry,
698
+ K as getBuilderSearchParams,
699
+ he as getDefaultCanTrack,
700
+ ne as getUserAttributes,
701
+ ze as handleABTestingSync,
702
+ ye as init,
709
703
  c as isBrowser,
710
- ee as isEditing,
711
- Ye as isPreviewing,
704
+ Z as isEditing,
705
+ qe as isPreviewing,
712
706
  l as logger,
713
- He as register,
714
- et as registerInsertMenu,
715
- ye as serializeComponentInfo,
716
- nt as setEditorSettings,
717
- ze as setupBrowserForEditing,
718
- tt as subscribeToEditor,
719
- Ze as track
707
+ $e as register,
708
+ Ye as registerInsertMenu,
709
+ pe as serializeComponentInfo,
710
+ et as setEditorSettings,
711
+ Ge as setupBrowserForEditing,
712
+ Ze as subscribeToEditor,
713
+ Qe as track
720
714
  };