@builder.io/sdk-react-nextjs 0.16.2 → 0.16.4
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 +26 -26
- package/lib/browser/blocks-exports.mjs +198 -177
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +1 -1
- package/lib/browser/server-entry-15a258a6.cjs +2 -0
- package/lib/browser/{server-entry-242f596f.js → server-entry-3336d7c2.js} +152 -158
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/blocks-exports.cjs +35 -35
- package/lib/edge/blocks-exports.mjs +228 -206
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +1 -1
- package/lib/edge/server-entry-15a258a6.cjs +2 -0
- package/lib/{node/server-entry-fbf4e3a9.js → edge/server-entry-3336d7c2.js} +152 -158
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/node/blocks-exports.cjs +15 -15
- package/lib/node/blocks-exports.mjs +128 -107
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +2 -2
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +2 -2
- package/lib/node/{node-runtime-e1243cd6.cjs → node-runtime-7537779c.cjs} +2 -2
- package/lib/node/{node-runtime-42e494ca.js → node-runtime-adcc8fa1.js} +3 -2
- package/lib/node/server-entry-15a258a6.cjs +2 -0
- package/lib/{edge/server-entry-242f596f.js → node/server-entry-3336d7c2.js} +152 -158
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +1 -1
- package/types/cjs/blocks/image/image.types.d.ts +2 -0
- package/types/cjs/blocks/symbol/symbol.types.d.ts +1 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/register-component.d.ts +2 -2
- package/types/esm/blocks/image/image.types.d.ts +2 -0
- package/types/esm/blocks/symbol/symbol.types.d.ts +1 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/register-component.d.ts +2 -2
- package/lib/browser/server-entry-494604dc.cjs +0 -2
- package/lib/edge/server-entry-494604dc.cjs +0 -2
- package/lib/node/server-entry-db7b41aa.cjs +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LRUCache as
|
|
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
|
|
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 ?
|
|
17
|
-
function
|
|
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
|
|
21
|
-
return
|
|
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
|
|
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
|
-
},
|
|
31
|
-
const e =
|
|
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 =
|
|
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,
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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) ?
|
|
78
|
-
return
|
|
79
|
-
},
|
|
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 =
|
|
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
|
-
},
|
|
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
|
-
}),
|
|
102
|
+
}), ue = ({
|
|
103
103
|
contentId: e
|
|
104
|
-
}) =>
|
|
104
|
+
}) => V({
|
|
105
105
|
name: k(e),
|
|
106
106
|
canTrack: !0
|
|
107
|
-
}),
|
|
107
|
+
}), de = ({
|
|
108
108
|
contentId: e,
|
|
109
109
|
value: t
|
|
110
|
-
}) =>
|
|
110
|
+
}) => _({
|
|
111
111
|
name: k(e),
|
|
112
112
|
value: t,
|
|
113
113
|
canTrack: !0
|
|
114
|
-
}),
|
|
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
|
-
},
|
|
128
|
-
const t =
|
|
129
|
-
return
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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 (!
|
|
157
|
+
if (!N(e))
|
|
158
158
|
return e;
|
|
159
|
-
const n =
|
|
159
|
+
const n = ue({
|
|
160
160
|
contentId: e.id
|
|
161
|
-
}) ||
|
|
161
|
+
}) || F({
|
|
162
162
|
variations: e.variations,
|
|
163
163
|
id: e.id
|
|
164
|
-
}), r =
|
|
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
|
-
},
|
|
172
|
+
}, fe = async ({
|
|
173
173
|
item: e,
|
|
174
174
|
canTrack: t
|
|
175
175
|
}) => {
|
|
176
|
-
if (!t || !
|
|
176
|
+
if (!t || !N(e))
|
|
177
177
|
return e;
|
|
178
|
-
const r = await
|
|
178
|
+
const r = await ce({
|
|
179
179
|
contentId: e.id
|
|
180
|
-
}) ||
|
|
180
|
+
}) || F({
|
|
181
181
|
variations: e.variations,
|
|
182
182
|
id: e.id
|
|
183
|
-
}), o =
|
|
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
|
-
},
|
|
191
|
+
}, he = (e) => m(e) ? e : !0, Xe = (e) => ({
|
|
192
192
|
type: "builder.registerComponent",
|
|
193
|
-
data:
|
|
194
|
-
}),
|
|
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
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
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
|
|
211
|
-
globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new
|
|
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
|
|
218
|
-
|
|
219
|
-
const t =
|
|
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
|
|
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
|
|
226
|
-
const e =
|
|
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
|
|
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
|
|
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("$")) ?
|
|
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
|
|
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(
|
|
253
|
+
const o = r.replace(R, "").replace(Ee, "");
|
|
259
254
|
n[o] = t[r];
|
|
260
255
|
}
|
|
261
256
|
}), n;
|
|
262
|
-
},
|
|
257
|
+
}, ke = () => {
|
|
263
258
|
if (!c())
|
|
264
259
|
return {};
|
|
265
260
|
const e = new URLSearchParams(window.location.search);
|
|
266
|
-
return
|
|
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 =
|
|
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
|
|
290
|
-
if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(
|
|
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
|
|
298
|
-
...
|
|
292
|
+
const X = {
|
|
293
|
+
...ke(),
|
|
299
294
|
...B(e.options || {})
|
|
300
|
-
}, O = E(
|
|
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 =
|
|
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
|
-
},
|
|
312
|
-
async function
|
|
313
|
-
const t = await
|
|
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
|
|
314
|
+
const Oe = async (e) => {
|
|
320
315
|
var s;
|
|
321
316
|
const t = C(e);
|
|
322
|
-
return await (await ((s = e.fetch) != null ? s :
|
|
323
|
-
},
|
|
324
|
-
const r =
|
|
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 =
|
|
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
|
|
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
|
|
343
|
+
async function xe(e) {
|
|
349
344
|
try {
|
|
350
|
-
const t = C(e), n = await
|
|
351
|
-
return
|
|
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
|
|
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
|
|
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
|
|
365
|
+
function W() {
|
|
366
|
+
return Ae().replace(/-/g, "");
|
|
372
367
|
}
|
|
373
|
-
const
|
|
368
|
+
const $ = "builderSessionId", Te = async ({
|
|
374
369
|
canTrack: e
|
|
375
370
|
}) => {
|
|
376
371
|
if (!e)
|
|
377
372
|
return;
|
|
378
|
-
const t = await
|
|
379
|
-
name:
|
|
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 =
|
|
386
|
-
return
|
|
380
|
+
const n = Le();
|
|
381
|
+
return Be({
|
|
387
382
|
id: n,
|
|
388
383
|
canTrack: e
|
|
389
384
|
}), n;
|
|
390
385
|
}
|
|
391
|
-
},
|
|
386
|
+
}, Le = () => W(), Be = ({
|
|
392
387
|
id: e,
|
|
393
388
|
canTrack: t
|
|
394
|
-
}) =>
|
|
395
|
-
name:
|
|
389
|
+
}) => _({
|
|
390
|
+
name: $,
|
|
396
391
|
value: e,
|
|
397
392
|
canTrack: t
|
|
398
|
-
}),
|
|
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 =
|
|
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
|
-
},
|
|
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 =
|
|
411
|
+
t && ((r = G()) == null || r.setItem(e, n));
|
|
417
412
|
} catch (o) {
|
|
418
413
|
console.debug("[LocalStorage] SET error: ", o);
|
|
419
414
|
}
|
|
420
|
-
},
|
|
415
|
+
}, H = "builderVisitorId", Me = ({
|
|
421
416
|
canTrack: e
|
|
422
417
|
}) => {
|
|
423
418
|
if (!e)
|
|
424
419
|
return;
|
|
425
|
-
const t =
|
|
426
|
-
key:
|
|
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 =
|
|
433
|
-
return
|
|
427
|
+
const n = _e();
|
|
428
|
+
return Ne({
|
|
434
429
|
id: n,
|
|
435
430
|
canTrack: e
|
|
436
431
|
}), n;
|
|
437
432
|
}
|
|
438
|
-
},
|
|
433
|
+
}, _e = () => W(), Ne = ({
|
|
439
434
|
id: e,
|
|
440
435
|
canTrack: t
|
|
441
|
-
}) =>
|
|
442
|
-
key:
|
|
436
|
+
}) => Ve({
|
|
437
|
+
key: H,
|
|
443
438
|
value: e,
|
|
444
439
|
canTrack: t
|
|
445
|
-
}),
|
|
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
|
|
448
|
+
const t = await Te({
|
|
454
449
|
canTrack: e
|
|
455
|
-
}), n =
|
|
450
|
+
}), n = Me({
|
|
456
451
|
canTrack: e
|
|
457
452
|
});
|
|
458
453
|
return {
|
|
459
454
|
sessionId: t,
|
|
460
455
|
visitorId: n
|
|
461
456
|
};
|
|
462
|
-
},
|
|
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
|
|
471
|
+
...await Fe({
|
|
477
472
|
canTrack: t
|
|
478
473
|
}),
|
|
479
|
-
userAttributes:
|
|
474
|
+
userAttributes: ne(),
|
|
480
475
|
ownerId: n
|
|
481
476
|
}
|
|
482
477
|
});
|
|
483
|
-
async function
|
|
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 && !
|
|
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
|
|
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
|
|
497
|
+
const Qe = (e) => je({
|
|
503
498
|
...e,
|
|
504
499
|
canTrack: !0
|
|
505
|
-
}),
|
|
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 ||
|
|
505
|
+
return (e || Ke).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
511
506
|
}
|
|
512
|
-
const
|
|
513
|
-
function
|
|
507
|
+
const We = "0.16.4", 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
|
|
531
|
-
|
|
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
|
|
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:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
|
|
646
|
-
const r =
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
683
|
+
content: await Pe(n)
|
|
689
684
|
};
|
|
690
685
|
};
|
|
691
686
|
export {
|
|
692
687
|
b as MSG_PREFIX,
|
|
693
688
|
v as TARGET,
|
|
694
|
-
|
|
695
|
-
|
|
689
|
+
Re as _processContentResult,
|
|
690
|
+
je as _track,
|
|
696
691
|
m as checkIsDefined,
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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
|
-
|
|
711
|
-
|
|
704
|
+
Z as isEditing,
|
|
705
|
+
qe as isPreviewing,
|
|
712
706
|
l as logger,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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
|
};
|