@builder.io/sdk-react 2.0.1 → 2.0.2-1
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 +22 -22
- package/lib/browser/blocks-exports.mjs +745 -758
- 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-f9067095.js → server-entry-45c77a86.js} +337 -335
- package/lib/browser/server-entry-69a4d3c9.cjs +2 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-6ad2cec7.cjs → accordion-7896cae6.cjs} +1 -1
- package/lib/edge/{accordion-4a70912d.js → accordion-ddf18178.js} +1 -1
- package/lib/edge/blocks-03bf455b.cjs +32 -0
- package/lib/edge/{blocks-fedde8d2.js → blocks-10f68d94.js} +1333 -1346
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-f6426eff.cjs → button-91e0aec2.cjs} +1 -1
- package/lib/edge/{button-af35e8de.js → button-cba5f3f8.js} +2 -2
- package/lib/edge/{columns-f607250b.cjs → columns-080edf58.cjs} +1 -1
- package/lib/edge/{columns-1065c0ae.js → columns-6bfc17df.js} +3 -3
- package/lib/edge/{content-variants-773afb9f.cjs → content-variants-65794f41.cjs} +1 -1
- package/lib/edge/{content-variants-3d57a82f.js → content-variants-d855ce6c.js} +10 -10
- package/lib/edge/{form-5762c22a.cjs → form-23561b33.cjs} +1 -1
- package/lib/edge/{form-0a58d0e4.js → form-f4cd948c.js} +3 -3
- package/lib/edge/{get-class-prop-name-268b0f61.js → get-class-prop-name-1928cf9f.js} +1 -1
- package/lib/edge/{get-class-prop-name-3061c329.cjs → get-class-prop-name-237cd359.cjs} +1 -1
- package/lib/edge/{img-59bb70c7.cjs → img-86db320f.cjs} +1 -1
- package/lib/edge/{img-252c9967.js → img-f9ec8689.js} +1 -1
- 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/{input-7ae243e2.js → input-394e72b8.js} +1 -1
- package/lib/edge/{input-2163d4dc.cjs → input-953ef2fe.cjs} +1 -1
- package/lib/edge/{select-cfa0eb8e.js → select-3e25848f.js} +1 -1
- package/lib/edge/{select-39231177.cjs → select-9bb6b8c1.cjs} +1 -1
- package/lib/edge/{server-entry-4750de9c.cjs → server-entry-6bd1c4bc.cjs} +1 -1
- package/lib/edge/{server-entry-681e8e79.js → server-entry-771d1637.js} +1 -1
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-69da8c56.cjs → slot-22940ad6.cjs} +1 -1
- package/lib/edge/{slot-7c61542f.js → slot-881129c3.js} +3 -3
- package/lib/edge/{symbol-bd999a19.cjs → symbol-58595a6d.cjs} +1 -1
- package/lib/edge/{symbol-4a8a6cda.js → symbol-faa97614.js} +2 -2
- package/lib/edge/{tabs-3d0e242e.cjs → tabs-dc23d0fa.cjs} +1 -1
- package/lib/edge/{tabs-c3ff0c70.js → tabs-f0ca75e4.js} +3 -3
- package/lib/node/blocks-exports.cjs +21 -21
- package/lib/node/blocks-exports.mjs +758 -771
- 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-78262e65.js → node-runtime-46d21495.js} +1 -1
- package/lib/node/{node-runtime-3bfd8465.cjs → node-runtime-55fc8cd4.cjs} +1 -1
- package/lib/node/server-entry-11eee7d8.cjs +2 -0
- package/lib/node/{server-entry-5f9f100f.js → server-entry-d45c1bf6.js} +337 -335
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +3 -2
- package/types/components/block/block.helpers.d.ts +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/lib/browser/server-entry-29c5c31c.cjs +0 -2
- package/lib/edge/blocks-0bd38a83.cjs +0 -32
- package/lib/node/server-entry-63058f3f.cjs +0 -2
|
@@ -52,12 +52,76 @@ const ee = () => {
|
|
|
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
|
-
}, U = (e) => JSON.parse(JSON.stringify(e)), m = (e) => e != null
|
|
55
|
+
}, U = (e) => JSON.parse(JSON.stringify(e)), m = (e) => e != null;
|
|
56
|
+
function Ge(e) {
|
|
57
|
+
const t = e || (c() ? window.location.search : void 0);
|
|
58
|
+
return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
|
|
59
|
+
}
|
|
60
|
+
const ze = (e) => ({
|
|
61
|
+
type: "builder.registerComponent",
|
|
62
|
+
data: se(e)
|
|
63
|
+
}), re = (e) => {
|
|
64
|
+
const t = e.toString().trim();
|
|
65
|
+
return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
|
|
66
|
+
}, oe = (e) => typeof e == "function" ? re(e) : U(e), se = ({
|
|
67
|
+
inputs: e,
|
|
68
|
+
...t
|
|
69
|
+
}) => ({
|
|
70
|
+
...U(t),
|
|
71
|
+
inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
|
|
72
|
+
...r,
|
|
73
|
+
[o]: oe(s)
|
|
74
|
+
}), {}))
|
|
75
|
+
}), x = {};
|
|
76
|
+
function ie(e, t) {
|
|
77
|
+
let n = x[e];
|
|
78
|
+
if (n || (n = x[e] = []), n.push(t), c()) {
|
|
79
|
+
const r = {
|
|
80
|
+
type: "builder.register",
|
|
81
|
+
data: {
|
|
82
|
+
type: e,
|
|
83
|
+
info: t
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
88
|
+
} catch (o) {
|
|
89
|
+
console.debug("Could not postmessage", o);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const A = {};
|
|
94
|
+
function Je(e) {
|
|
95
|
+
if (c()) {
|
|
96
|
+
Object.assign(A, e);
|
|
97
|
+
const t = {
|
|
98
|
+
type: "builder.settingsChange",
|
|
99
|
+
data: A
|
|
100
|
+
};
|
|
101
|
+
parent.postMessage(t, "*");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const T = "builder.", ae = "options.", M = (e) => {
|
|
105
|
+
if (!e)
|
|
106
|
+
return {};
|
|
107
|
+
const t = L(e), n = {};
|
|
108
|
+
return Object.keys(t).forEach((r) => {
|
|
109
|
+
if (r.startsWith(T)) {
|
|
110
|
+
const o = r.replace(T, "").replace(ae, "");
|
|
111
|
+
n[o] = t[r];
|
|
112
|
+
}
|
|
113
|
+
}), n;
|
|
114
|
+
}, ce = () => {
|
|
115
|
+
if (!c())
|
|
116
|
+
return {};
|
|
117
|
+
const e = new URLSearchParams(window.location.search);
|
|
118
|
+
return M(e);
|
|
119
|
+
}, ue = (e) => {
|
|
56
120
|
if (e === "localhost" || e === "127.0.0.1")
|
|
57
121
|
return e;
|
|
58
122
|
const t = e.split(".");
|
|
59
123
|
return t.length > 2 ? t.slice(1).join(".") : e;
|
|
60
|
-
},
|
|
124
|
+
}, N = ({
|
|
61
125
|
name: e,
|
|
62
126
|
canTrack: t
|
|
63
127
|
}) => {
|
|
@@ -68,14 +132,14 @@ const ee = () => {
|
|
|
68
132
|
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
69
133
|
return;
|
|
70
134
|
}
|
|
71
|
-
},
|
|
135
|
+
}, F = async (e) => N(e), de = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), le = [["secure", ""], ["SameSite", "None"]], fe = ({
|
|
72
136
|
name: e,
|
|
73
137
|
value: t,
|
|
74
138
|
expires: n
|
|
75
139
|
}) => {
|
|
76
|
-
const o = (c() ? location.protocol === "https:" : !0) ?
|
|
77
|
-
return
|
|
78
|
-
},
|
|
140
|
+
const o = (c() ? location.protocol === "https:" : !0) ? le : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", ue(window.location.hostname)], ...o];
|
|
141
|
+
return de(a);
|
|
142
|
+
}, j = async ({
|
|
79
143
|
name: e,
|
|
80
144
|
value: t,
|
|
81
145
|
expires: n,
|
|
@@ -84,7 +148,7 @@ const ee = () => {
|
|
|
84
148
|
try {
|
|
85
149
|
if (!r)
|
|
86
150
|
return;
|
|
87
|
-
const o =
|
|
151
|
+
const o = fe({
|
|
88
152
|
name: e,
|
|
89
153
|
value: t,
|
|
90
154
|
expires: n
|
|
@@ -93,332 +157,89 @@ const ee = () => {
|
|
|
93
157
|
} catch (o) {
|
|
94
158
|
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
95
159
|
}
|
|
96
|
-
}, ae = "builder.tests", E = (e) => `${ae}.${e}`, ce = ({
|
|
97
|
-
contentId: e
|
|
98
|
-
}) => N({
|
|
99
|
-
name: E(e),
|
|
100
|
-
canTrack: !0
|
|
101
|
-
}), ue = ({
|
|
102
|
-
contentId: e
|
|
103
|
-
}) => M({
|
|
104
|
-
name: E(e),
|
|
105
|
-
canTrack: !0
|
|
106
|
-
}), de = ({
|
|
107
|
-
contentId: e,
|
|
108
|
-
value: t
|
|
109
|
-
}) => F({
|
|
110
|
-
name: E(e),
|
|
111
|
-
value: t,
|
|
112
|
-
canTrack: !0
|
|
113
|
-
}), j = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, le = ({
|
|
114
|
-
id: e,
|
|
115
|
-
variations: t
|
|
116
|
-
}) => {
|
|
117
|
-
var o;
|
|
118
|
-
let n = 0;
|
|
119
|
-
const r = Math.random();
|
|
120
|
-
for (const s in t) {
|
|
121
|
-
const a = (o = t[s]) == null ? void 0 : o.testRatio;
|
|
122
|
-
if (n += a, r < n)
|
|
123
|
-
return s;
|
|
124
|
-
}
|
|
125
|
-
return e;
|
|
126
|
-
}, D = (e) => {
|
|
127
|
-
const t = le(e);
|
|
128
|
-
return de({
|
|
129
|
-
contentId: e.id,
|
|
130
|
-
value: t
|
|
131
|
-
}).catch((n) => {
|
|
132
|
-
f.error("could not store A/B test variation: ", n);
|
|
133
|
-
}), t;
|
|
134
|
-
}, K = ({
|
|
135
|
-
item: e,
|
|
136
|
-
testGroupId: t
|
|
137
|
-
}) => {
|
|
138
|
-
const n = e.variations[t];
|
|
139
|
-
return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
140
|
-
!n ? {
|
|
141
|
-
testVariationId: e.id,
|
|
142
|
-
testVariationName: "Default"
|
|
143
|
-
} : {
|
|
144
|
-
data: n.data,
|
|
145
|
-
testVariationId: n.id,
|
|
146
|
-
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
147
|
-
};
|
|
148
|
-
}, Ge = ({
|
|
149
|
-
item: e,
|
|
150
|
-
canTrack: t
|
|
151
|
-
}) => {
|
|
152
|
-
if (!t)
|
|
153
|
-
return e;
|
|
154
|
-
if (!e)
|
|
155
|
-
return;
|
|
156
|
-
if (!j(e))
|
|
157
|
-
return e;
|
|
158
|
-
const n = ue({
|
|
159
|
-
contentId: e.id
|
|
160
|
-
}) || D({
|
|
161
|
-
variations: e.variations,
|
|
162
|
-
id: e.id
|
|
163
|
-
}), r = K({
|
|
164
|
-
item: e,
|
|
165
|
-
testGroupId: n
|
|
166
|
-
});
|
|
167
|
-
return {
|
|
168
|
-
...e,
|
|
169
|
-
...r
|
|
170
|
-
};
|
|
171
|
-
}, fe = async ({
|
|
172
|
-
item: e,
|
|
173
|
-
canTrack: t
|
|
174
|
-
}) => {
|
|
175
|
-
if (!t || !j(e))
|
|
176
|
-
return e;
|
|
177
|
-
const r = await ce({
|
|
178
|
-
contentId: e.id
|
|
179
|
-
}) || D({
|
|
180
|
-
variations: e.variations,
|
|
181
|
-
id: e.id
|
|
182
|
-
}), o = K({
|
|
183
|
-
item: e,
|
|
184
|
-
testGroupId: r
|
|
185
|
-
});
|
|
186
|
-
return {
|
|
187
|
-
...e,
|
|
188
|
-
...o
|
|
189
|
-
};
|
|
190
|
-
}, he = (e) => m(e) ? e : !0, ze = (e) => ({
|
|
191
|
-
type: "builder.registerComponent",
|
|
192
|
-
data: me(e)
|
|
193
|
-
}), ge = (e) => {
|
|
194
|
-
const t = e.toString().trim();
|
|
195
|
-
return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
|
|
196
|
-
}, pe = (e) => typeof e == "function" ? ge(e) : U(e), me = ({
|
|
197
|
-
inputs: e,
|
|
198
|
-
...t
|
|
199
|
-
}) => ({
|
|
200
|
-
...U(t),
|
|
201
|
-
inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
|
|
202
|
-
...r,
|
|
203
|
-
[o]: pe(s)
|
|
204
|
-
}), {}))
|
|
205
|
-
});
|
|
206
|
-
function ye() {
|
|
207
|
-
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
208
|
-
}
|
|
209
|
-
function we() {
|
|
210
|
-
const e = ye().fetch;
|
|
211
|
-
if (typeof e == "undefined")
|
|
212
|
-
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
213
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
214
|
-
return e;
|
|
215
|
-
}
|
|
216
|
-
const Se = we();
|
|
217
|
-
function k(e, t = null, n = ".") {
|
|
218
|
-
return Object.keys(e).reduce((r, o) => {
|
|
219
|
-
const s = e[o], a = [t, o].filter(Boolean).join(n);
|
|
220
|
-
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
221
|
-
...r,
|
|
222
|
-
...k(s, a, n)
|
|
223
|
-
} : {
|
|
224
|
-
...r,
|
|
225
|
-
[a]: s
|
|
226
|
-
};
|
|
227
|
-
}, {});
|
|
228
|
-
}
|
|
229
|
-
function W(e, t, n = {}) {
|
|
230
|
-
for (const r in e) {
|
|
231
|
-
const o = e[r], s = t ? t + "." + r : r;
|
|
232
|
-
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? W(o, s, n) : n[s] = o;
|
|
233
|
-
}
|
|
234
|
-
return n;
|
|
235
|
-
}
|
|
236
|
-
const be = "v3", x = "builder.", ve = "options.", _ = (e) => {
|
|
237
|
-
if (!e)
|
|
238
|
-
return {};
|
|
239
|
-
const t = L(e), n = {};
|
|
240
|
-
return Object.keys(t).forEach((r) => {
|
|
241
|
-
if (r.startsWith(x)) {
|
|
242
|
-
const o = r.replace(x, "").replace(ve, "");
|
|
243
|
-
n[o] = t[r];
|
|
244
|
-
}
|
|
245
|
-
}), n;
|
|
246
|
-
}, Ie = () => {
|
|
247
|
-
if (!c())
|
|
248
|
-
return {};
|
|
249
|
-
const e = new URLSearchParams(window.location.search);
|
|
250
|
-
return _(e);
|
|
251
|
-
}, A = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
|
|
252
|
-
const {
|
|
253
|
-
limit: t = 30,
|
|
254
|
-
userAttributes: n,
|
|
255
|
-
query: r,
|
|
256
|
-
model: o,
|
|
257
|
-
apiKey: s,
|
|
258
|
-
enrich: a,
|
|
259
|
-
locale: d,
|
|
260
|
-
apiVersion: y = be,
|
|
261
|
-
fields: p,
|
|
262
|
-
omit: I,
|
|
263
|
-
offset: u,
|
|
264
|
-
cacheSeconds: h,
|
|
265
|
-
staleCacheSeconds: g,
|
|
266
|
-
sort: w,
|
|
267
|
-
includeUnpublished: P
|
|
268
|
-
} = e;
|
|
269
|
-
if (!s)
|
|
270
|
-
throw new Error("Missing API key");
|
|
271
|
-
if (!["v3"].includes(y))
|
|
272
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
273
|
-
const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
274
|
-
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && A(h) && i.searchParams.set("cacheSeconds", String(h)), g && A(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
275
|
-
const l = k({
|
|
276
|
-
sort: w
|
|
277
|
-
});
|
|
278
|
-
for (const S in l)
|
|
279
|
-
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
280
|
-
}
|
|
281
|
-
const q = {
|
|
282
|
-
...Ie(),
|
|
283
|
-
...L(e.options || {})
|
|
284
|
-
}, C = k(q);
|
|
285
|
-
for (const l in C)
|
|
286
|
-
i.searchParams.set(l, String(C[l]));
|
|
287
|
-
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
288
|
-
const l = W({
|
|
289
|
-
query: r
|
|
290
|
-
});
|
|
291
|
-
for (const S in l)
|
|
292
|
-
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
293
|
-
}
|
|
294
|
-
return i;
|
|
295
|
-
}, ke = (e) => "results" in e;
|
|
296
|
-
async function Ee(e) {
|
|
297
|
-
const t = await Ce({
|
|
298
|
-
...e,
|
|
299
|
-
limit: 1
|
|
300
|
-
});
|
|
301
|
-
return t && t[0] || null;
|
|
302
|
-
}
|
|
303
|
-
const Oe = async (e) => {
|
|
304
|
-
var s;
|
|
305
|
-
const t = O(e);
|
|
306
|
-
return await (await ((s = e.fetch) != null ? s : Se)(t.href, e.fetchOptions)).json();
|
|
307
|
-
}, Pe = async (e, t, n = O(e)) => {
|
|
308
|
-
const r = he(e.canTrack);
|
|
309
|
-
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
310
|
-
return t.results;
|
|
311
|
-
try {
|
|
312
|
-
const o = [];
|
|
313
|
-
for (const s of t.results)
|
|
314
|
-
o.push(await fe({
|
|
315
|
-
item: s,
|
|
316
|
-
canTrack: r
|
|
317
|
-
}));
|
|
318
|
-
t.results = o;
|
|
319
|
-
} catch (o) {
|
|
320
|
-
f.error("Could not process A/B tests. ", o);
|
|
321
|
-
}
|
|
322
|
-
return t.results;
|
|
323
160
|
};
|
|
324
|
-
|
|
325
|
-
try {
|
|
326
|
-
const t = O(e), n = await Oe(e);
|
|
327
|
-
return ke(n) ? Pe(e, n) : (f.error("Error fetching data. ", {
|
|
328
|
-
url: t,
|
|
329
|
-
content: n,
|
|
330
|
-
options: e
|
|
331
|
-
}), null);
|
|
332
|
-
} catch (t) {
|
|
333
|
-
return f.error("Error fetching data. ", t), null;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function Je(e) {
|
|
337
|
-
const t = e || (c() ? window.location.search : void 0);
|
|
338
|
-
return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
|
|
339
|
-
}
|
|
340
|
-
function xe() {
|
|
161
|
+
function he() {
|
|
341
162
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
342
163
|
const t = Math.random() * 16 | 0;
|
|
343
164
|
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
344
165
|
});
|
|
345
166
|
}
|
|
346
|
-
function
|
|
347
|
-
return
|
|
167
|
+
function D() {
|
|
168
|
+
return he().replace(/-/g, "");
|
|
348
169
|
}
|
|
349
|
-
const
|
|
170
|
+
const K = "builderSessionId", ge = async ({
|
|
350
171
|
canTrack: e
|
|
351
172
|
}) => {
|
|
352
173
|
if (!e)
|
|
353
174
|
return;
|
|
354
|
-
const t = await
|
|
355
|
-
name:
|
|
175
|
+
const t = await F({
|
|
176
|
+
name: K,
|
|
356
177
|
canTrack: e
|
|
357
178
|
});
|
|
358
179
|
if (m(t))
|
|
359
180
|
return t;
|
|
360
181
|
{
|
|
361
|
-
const n =
|
|
362
|
-
return
|
|
182
|
+
const n = pe();
|
|
183
|
+
return me({
|
|
363
184
|
id: n,
|
|
364
185
|
canTrack: e
|
|
365
186
|
}), n;
|
|
366
187
|
}
|
|
367
|
-
},
|
|
188
|
+
}, pe = () => D(), me = ({
|
|
368
189
|
id: e,
|
|
369
190
|
canTrack: t
|
|
370
|
-
}) =>
|
|
371
|
-
name:
|
|
191
|
+
}) => j({
|
|
192
|
+
name: K,
|
|
372
193
|
value: e,
|
|
373
194
|
canTrack: t
|
|
374
|
-
}),
|
|
195
|
+
}), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ye = ({
|
|
375
196
|
key: e,
|
|
376
197
|
canTrack: t
|
|
377
198
|
}) => {
|
|
378
199
|
var n;
|
|
379
200
|
try {
|
|
380
|
-
return t ? (n =
|
|
201
|
+
return t ? (n = W()) == null ? void 0 : n.getItem(e) : void 0;
|
|
381
202
|
} catch (r) {
|
|
382
203
|
console.debug("[LocalStorage] GET error: ", r);
|
|
383
204
|
return;
|
|
384
205
|
}
|
|
385
|
-
},
|
|
206
|
+
}, we = ({
|
|
386
207
|
key: e,
|
|
387
208
|
canTrack: t,
|
|
388
209
|
value: n
|
|
389
210
|
}) => {
|
|
390
211
|
var r;
|
|
391
212
|
try {
|
|
392
|
-
t && ((r =
|
|
213
|
+
t && ((r = W()) == null || r.setItem(e, n));
|
|
393
214
|
} catch (o) {
|
|
394
215
|
console.debug("[LocalStorage] SET error: ", o);
|
|
395
216
|
}
|
|
396
|
-
},
|
|
217
|
+
}, _ = "builderVisitorId", Se = ({
|
|
397
218
|
canTrack: e
|
|
398
219
|
}) => {
|
|
399
220
|
if (!e)
|
|
400
221
|
return;
|
|
401
|
-
const t =
|
|
402
|
-
key:
|
|
222
|
+
const t = ye({
|
|
223
|
+
key: _,
|
|
403
224
|
canTrack: e
|
|
404
225
|
});
|
|
405
226
|
if (m(t))
|
|
406
227
|
return t;
|
|
407
228
|
{
|
|
408
|
-
const n =
|
|
409
|
-
return
|
|
229
|
+
const n = be();
|
|
230
|
+
return ve({
|
|
410
231
|
id: n,
|
|
411
232
|
canTrack: e
|
|
412
233
|
}), n;
|
|
413
234
|
}
|
|
414
|
-
},
|
|
235
|
+
}, be = () => D(), ve = ({
|
|
415
236
|
id: e,
|
|
416
237
|
canTrack: t
|
|
417
|
-
}) =>
|
|
418
|
-
key:
|
|
238
|
+
}) => we({
|
|
239
|
+
key: _,
|
|
419
240
|
value: e,
|
|
420
241
|
canTrack: t
|
|
421
|
-
}),
|
|
242
|
+
}), Ie = async ({
|
|
422
243
|
canTrack: e
|
|
423
244
|
}) => {
|
|
424
245
|
if (!e)
|
|
@@ -426,16 +247,16 @@ const G = "builderSessionId", Ae = async ({
|
|
|
426
247
|
visitorId: void 0,
|
|
427
248
|
sessionId: void 0
|
|
428
249
|
};
|
|
429
|
-
const t = await
|
|
250
|
+
const t = await ge({
|
|
430
251
|
canTrack: e
|
|
431
|
-
}), n =
|
|
252
|
+
}), n = Se({
|
|
432
253
|
canTrack: e
|
|
433
254
|
});
|
|
434
255
|
return {
|
|
435
256
|
sessionId: t,
|
|
436
257
|
visitorId: n
|
|
437
258
|
};
|
|
438
|
-
},
|
|
259
|
+
}, ke = async ({
|
|
439
260
|
type: e,
|
|
440
261
|
canTrack: t,
|
|
441
262
|
apiKey: n,
|
|
@@ -449,14 +270,14 @@ const G = "builderSessionId", Ae = async ({
|
|
|
449
270
|
url: location.href,
|
|
450
271
|
...r
|
|
451
272
|
},
|
|
452
|
-
...await
|
|
273
|
+
...await Ie({
|
|
453
274
|
canTrack: t
|
|
454
275
|
}),
|
|
455
276
|
userAttributes: ne(),
|
|
456
277
|
ownerId: n
|
|
457
278
|
}
|
|
458
279
|
});
|
|
459
|
-
async function
|
|
280
|
+
async function Ee(e) {
|
|
460
281
|
if (!e.apiKey) {
|
|
461
282
|
f.error("Missing API key for track call. Please provide your API key.");
|
|
462
283
|
return;
|
|
@@ -465,7 +286,7 @@ async function je(e) {
|
|
|
465
286
|
return fetch("https://cdn.builder.io/api/v1/track", {
|
|
466
287
|
method: "POST",
|
|
467
288
|
body: JSON.stringify({
|
|
468
|
-
events: [await
|
|
289
|
+
events: [await ke(e)]
|
|
469
290
|
}),
|
|
470
291
|
headers: {
|
|
471
292
|
"content-type": "application/json"
|
|
@@ -475,36 +296,18 @@ async function je(e) {
|
|
|
475
296
|
console.error("Failed to track: ", t);
|
|
476
297
|
});
|
|
477
298
|
}
|
|
478
|
-
const He = (e) =>
|
|
299
|
+
const He = (e) => Ee({
|
|
479
300
|
...e,
|
|
480
301
|
canTrack: !0
|
|
481
|
-
}),
|
|
482
|
-
function
|
|
302
|
+
}), Oe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
303
|
+
function $(e, t) {
|
|
483
304
|
if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
|
|
484
305
|
return !1;
|
|
485
306
|
const n = new URL(t.origin), r = n.hostname;
|
|
486
|
-
return (e ||
|
|
487
|
-
}
|
|
488
|
-
const Ke = "2.0.1", T = {};
|
|
489
|
-
function We(e, t) {
|
|
490
|
-
let n = T[e];
|
|
491
|
-
if (n || (n = T[e] = []), n.push(t), c()) {
|
|
492
|
-
const r = {
|
|
493
|
-
type: "builder.register",
|
|
494
|
-
data: {
|
|
495
|
-
type: e,
|
|
496
|
-
info: t
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
try {
|
|
500
|
-
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
501
|
-
} catch (o) {
|
|
502
|
-
console.debug("Could not postmessage", o);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
307
|
+
return (e || Oe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
505
308
|
}
|
|
506
|
-
const Xe = () => {
|
|
507
|
-
|
|
309
|
+
const Pe = "2.0.2-0", Xe = () => {
|
|
310
|
+
ie("insertMenu", {
|
|
508
311
|
name: "_default",
|
|
509
312
|
default: !0,
|
|
510
313
|
items: [{
|
|
@@ -527,13 +330,13 @@ const Xe = () => {
|
|
|
527
330
|
});
|
|
528
331
|
};
|
|
529
332
|
let R = !1;
|
|
530
|
-
const
|
|
333
|
+
const Ce = (e = {}) => {
|
|
531
334
|
var t, n;
|
|
532
335
|
R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
533
336
|
type: "builder.sdkInfo",
|
|
534
337
|
data: {
|
|
535
338
|
target: v,
|
|
536
|
-
version:
|
|
339
|
+
version: Pe,
|
|
537
340
|
supportsPatchUpdates: !1,
|
|
538
341
|
// Supports builder-model="..." attribute which is needed to
|
|
539
342
|
// scope our '+ add block' button styling
|
|
@@ -547,7 +350,7 @@ const _e = (e = {}) => {
|
|
|
547
350
|
}
|
|
548
351
|
}, "*"), window.addEventListener("message", (r) => {
|
|
549
352
|
var s, a;
|
|
550
|
-
if (
|
|
353
|
+
if (!$(e.trustedHosts, r))
|
|
551
354
|
return;
|
|
552
355
|
const {
|
|
553
356
|
data: o
|
|
@@ -588,12 +391,12 @@ const _e = (e = {}) => {
|
|
|
588
391
|
}
|
|
589
392
|
}
|
|
590
393
|
})));
|
|
591
|
-
},
|
|
394
|
+
}, xe = ({
|
|
592
395
|
model: e,
|
|
593
396
|
trustedHosts: t,
|
|
594
397
|
callbacks: n
|
|
595
398
|
}) => (r) => {
|
|
596
|
-
if (
|
|
399
|
+
if (!$(t, r))
|
|
597
400
|
return;
|
|
598
401
|
const {
|
|
599
402
|
data: o
|
|
@@ -618,8 +421,8 @@ const _e = (e = {}) => {
|
|
|
618
421
|
if (!c)
|
|
619
422
|
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
620
423
|
};
|
|
621
|
-
|
|
622
|
-
const r =
|
|
424
|
+
Ce();
|
|
425
|
+
const r = xe({
|
|
623
426
|
callbacks: {
|
|
624
427
|
contentUpdate: t,
|
|
625
428
|
animation: () => {
|
|
@@ -633,15 +436,214 @@ const _e = (e = {}) => {
|
|
|
633
436
|
return window.addEventListener("message", r), () => {
|
|
634
437
|
window.removeEventListener("message", r);
|
|
635
438
|
};
|
|
636
|
-
},
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
439
|
+
}, Ae = "builder.tests", E = (e) => `${Ae}.${e}`, Te = ({
|
|
440
|
+
contentId: e
|
|
441
|
+
}) => F({
|
|
442
|
+
name: E(e),
|
|
443
|
+
canTrack: !0
|
|
444
|
+
}), Re = ({
|
|
445
|
+
contentId: e
|
|
446
|
+
}) => N({
|
|
447
|
+
name: E(e),
|
|
448
|
+
canTrack: !0
|
|
449
|
+
}), Be = ({
|
|
450
|
+
contentId: e,
|
|
451
|
+
value: t
|
|
452
|
+
}) => j({
|
|
453
|
+
name: E(e),
|
|
454
|
+
value: t,
|
|
455
|
+
canTrack: !0
|
|
456
|
+
}), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Le = ({
|
|
457
|
+
id: e,
|
|
458
|
+
variations: t
|
|
459
|
+
}) => {
|
|
460
|
+
var o;
|
|
461
|
+
let n = 0;
|
|
462
|
+
const r = Math.random();
|
|
463
|
+
for (const s in t) {
|
|
464
|
+
const a = (o = t[s]) == null ? void 0 : o.testRatio;
|
|
465
|
+
if (n += a, r < n)
|
|
466
|
+
return s;
|
|
467
|
+
}
|
|
468
|
+
return e;
|
|
469
|
+
}, z = (e) => {
|
|
470
|
+
const t = Le(e);
|
|
471
|
+
return Be({
|
|
472
|
+
contentId: e.id,
|
|
473
|
+
value: t
|
|
474
|
+
}).catch((n) => {
|
|
475
|
+
f.error("could not store A/B test variation: ", n);
|
|
476
|
+
}), t;
|
|
477
|
+
}, J = ({
|
|
478
|
+
item: e,
|
|
479
|
+
testGroupId: t
|
|
480
|
+
}) => {
|
|
481
|
+
const n = e.variations[t];
|
|
482
|
+
return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
483
|
+
!n ? {
|
|
484
|
+
testVariationId: e.id,
|
|
485
|
+
testVariationName: "Default"
|
|
486
|
+
} : {
|
|
487
|
+
data: n.data,
|
|
488
|
+
testVariationId: n.id,
|
|
489
|
+
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
490
|
+
};
|
|
491
|
+
}, Qe = ({
|
|
492
|
+
item: e,
|
|
493
|
+
canTrack: t
|
|
494
|
+
}) => {
|
|
495
|
+
if (!t)
|
|
496
|
+
return e;
|
|
497
|
+
if (!e)
|
|
498
|
+
return;
|
|
499
|
+
if (!G(e))
|
|
500
|
+
return e;
|
|
501
|
+
const n = Re({
|
|
502
|
+
contentId: e.id
|
|
503
|
+
}) || z({
|
|
504
|
+
variations: e.variations,
|
|
505
|
+
id: e.id
|
|
506
|
+
}), r = J({
|
|
507
|
+
item: e,
|
|
508
|
+
testGroupId: n
|
|
509
|
+
});
|
|
510
|
+
return {
|
|
511
|
+
...e,
|
|
512
|
+
...r
|
|
513
|
+
};
|
|
514
|
+
}, Ve = async ({
|
|
515
|
+
item: e,
|
|
516
|
+
canTrack: t
|
|
517
|
+
}) => {
|
|
518
|
+
if (!t || !G(e))
|
|
519
|
+
return e;
|
|
520
|
+
const r = await Te({
|
|
521
|
+
contentId: e.id
|
|
522
|
+
}) || z({
|
|
523
|
+
variations: e.variations,
|
|
524
|
+
id: e.id
|
|
525
|
+
}), o = J({
|
|
526
|
+
item: e,
|
|
527
|
+
testGroupId: r
|
|
528
|
+
});
|
|
529
|
+
return {
|
|
530
|
+
...e,
|
|
531
|
+
...o
|
|
532
|
+
};
|
|
533
|
+
}, Ue = (e) => m(e) ? e : !0;
|
|
534
|
+
function Me() {
|
|
535
|
+
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
536
|
+
}
|
|
537
|
+
function Ne() {
|
|
538
|
+
const e = Me().fetch;
|
|
539
|
+
if (typeof e == "undefined")
|
|
540
|
+
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
541
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
542
|
+
return e;
|
|
543
|
+
}
|
|
544
|
+
const Fe = Ne();
|
|
545
|
+
function k(e, t = null, n = ".") {
|
|
546
|
+
return Object.keys(e).reduce((r, o) => {
|
|
547
|
+
const s = e[o], a = [t, o].filter(Boolean).join(n);
|
|
548
|
+
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
549
|
+
...r,
|
|
550
|
+
...k(s, a, n)
|
|
551
|
+
} : {
|
|
552
|
+
...r,
|
|
553
|
+
[a]: s
|
|
643
554
|
};
|
|
644
|
-
|
|
555
|
+
}, {});
|
|
556
|
+
}
|
|
557
|
+
function H(e, t, n = {}) {
|
|
558
|
+
for (const r in e) {
|
|
559
|
+
const o = e[r], s = t ? t + "." + r : r;
|
|
560
|
+
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
|
|
561
|
+
}
|
|
562
|
+
return n;
|
|
563
|
+
}
|
|
564
|
+
const je = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
|
|
565
|
+
const {
|
|
566
|
+
limit: t = 30,
|
|
567
|
+
userAttributes: n,
|
|
568
|
+
query: r,
|
|
569
|
+
model: o,
|
|
570
|
+
apiKey: s,
|
|
571
|
+
enrich: a,
|
|
572
|
+
locale: d,
|
|
573
|
+
apiVersion: y = je,
|
|
574
|
+
fields: p,
|
|
575
|
+
omit: I,
|
|
576
|
+
offset: u,
|
|
577
|
+
cacheSeconds: h,
|
|
578
|
+
staleCacheSeconds: g,
|
|
579
|
+
sort: w,
|
|
580
|
+
includeUnpublished: P
|
|
581
|
+
} = e;
|
|
582
|
+
if (!s)
|
|
583
|
+
throw new Error("Missing API key");
|
|
584
|
+
if (!["v3"].includes(y))
|
|
585
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
586
|
+
const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
587
|
+
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
588
|
+
const l = k({
|
|
589
|
+
sort: w
|
|
590
|
+
});
|
|
591
|
+
for (const S in l)
|
|
592
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
593
|
+
}
|
|
594
|
+
const q = {
|
|
595
|
+
...ce(),
|
|
596
|
+
...L(e.options || {})
|
|
597
|
+
}, C = k(q);
|
|
598
|
+
for (const l in C)
|
|
599
|
+
i.searchParams.set(l, String(C[l]));
|
|
600
|
+
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
601
|
+
const l = H({
|
|
602
|
+
query: r
|
|
603
|
+
});
|
|
604
|
+
for (const S in l)
|
|
605
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
606
|
+
}
|
|
607
|
+
return i;
|
|
608
|
+
}, De = (e) => "results" in e;
|
|
609
|
+
async function Ke(e) {
|
|
610
|
+
const t = await $e({
|
|
611
|
+
...e,
|
|
612
|
+
limit: 1
|
|
613
|
+
});
|
|
614
|
+
return t && t[0] || null;
|
|
615
|
+
}
|
|
616
|
+
const We = async (e) => {
|
|
617
|
+
var s;
|
|
618
|
+
const t = O(e);
|
|
619
|
+
return await (await ((s = e.fetch) != null ? s : Fe)(t.href, e.fetchOptions)).json();
|
|
620
|
+
}, _e = async (e, t, n = O(e)) => {
|
|
621
|
+
const r = Ue(e.canTrack);
|
|
622
|
+
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
623
|
+
return t.results;
|
|
624
|
+
try {
|
|
625
|
+
const o = [];
|
|
626
|
+
for (const s of t.results)
|
|
627
|
+
o.push(await Ve({
|
|
628
|
+
item: s,
|
|
629
|
+
canTrack: r
|
|
630
|
+
}));
|
|
631
|
+
t.results = o;
|
|
632
|
+
} catch (o) {
|
|
633
|
+
f.error("Could not process A/B tests. ", o);
|
|
634
|
+
}
|
|
635
|
+
return t.results;
|
|
636
|
+
};
|
|
637
|
+
async function $e(e) {
|
|
638
|
+
try {
|
|
639
|
+
const t = O(e), n = await We(e);
|
|
640
|
+
return De(n) ? _e(e, n) : (f.error("Error fetching data. ", {
|
|
641
|
+
url: t,
|
|
642
|
+
content: n,
|
|
643
|
+
options: e
|
|
644
|
+
}), null);
|
|
645
|
+
} catch (t) {
|
|
646
|
+
return f.error("Error fetching data. ", t), null;
|
|
645
647
|
}
|
|
646
648
|
}
|
|
647
649
|
const Ye = async (e) => {
|
|
@@ -656,40 +658,40 @@ const Ye = async (e) => {
|
|
|
656
658
|
urlPath: t
|
|
657
659
|
} : {}
|
|
658
660
|
},
|
|
659
|
-
options:
|
|
661
|
+
options: M(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
|
|
660
662
|
};
|
|
661
663
|
return {
|
|
662
664
|
apiKey: n.apiKey,
|
|
663
665
|
model: n.model,
|
|
664
|
-
content: await
|
|
666
|
+
content: await Ke(n)
|
|
665
667
|
};
|
|
666
668
|
};
|
|
667
669
|
export {
|
|
668
670
|
b as MSG_PREFIX,
|
|
669
671
|
v as TARGET,
|
|
670
|
-
|
|
671
|
-
|
|
672
|
+
_e as _processContentResult,
|
|
673
|
+
Ee as _track,
|
|
672
674
|
m as checkIsDefined,
|
|
673
|
-
|
|
675
|
+
xe as createEditorListener,
|
|
674
676
|
ze as createRegisterComponentMessage,
|
|
675
677
|
U as fastClone,
|
|
676
|
-
|
|
678
|
+
Fe as fetch,
|
|
677
679
|
Ye as fetchBuilderProps,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
680
|
+
$e as fetchEntries,
|
|
681
|
+
Ke as fetchOneEntry,
|
|
682
|
+
M as getBuilderSearchParams,
|
|
683
|
+
Ue as getDefaultCanTrack,
|
|
682
684
|
ne as getUserAttributes,
|
|
683
|
-
|
|
685
|
+
Qe as handleABTestingSync,
|
|
684
686
|
c as isBrowser,
|
|
685
687
|
Z as isEditing,
|
|
686
|
-
|
|
688
|
+
Ge as isPreviewing,
|
|
687
689
|
f as logger,
|
|
688
|
-
|
|
690
|
+
ie as register,
|
|
689
691
|
Xe as registerInsertMenu,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
692
|
+
se as serializeComponentInfo,
|
|
693
|
+
Je as setEditorSettings,
|
|
694
|
+
Ce as setupBrowserForEditing,
|
|
693
695
|
qe as subscribeToEditor,
|
|
694
696
|
He as track
|
|
695
697
|
};
|