@builder.io/sdk-react 2.0.9 → 2.0.13
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 +31 -31
- package/lib/browser/blocks-exports.mjs +1032 -996
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +3 -3
- package/lib/browser/init.mjs +3 -3
- package/lib/{node/server-entry-8bf52a55.js → browser/server-entry-288f3748.js} +333 -330
- package/lib/browser/server-entry-7304506e.cjs +2 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-589b3ac8.js → accordion-3cfa3eee.js} +1 -1
- package/lib/edge/{accordion-afed3bd3.cjs → accordion-807094e8.cjs} +1 -1
- package/lib/edge/blocks-54e76c48.js +842 -0
- package/lib/edge/blocks-ec210226.cjs +12 -0
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-08412b69.js → button-0d89818e.js} +2 -2
- package/lib/edge/{button-26b76a4a.cjs → button-e3dbd868.cjs} +1 -1
- package/lib/edge/{columns-ccdafcc7.cjs → columns-f4875265.cjs} +1 -1
- package/lib/edge/{columns-bd2a004b.js → columns-f9a7710d.js} +4 -4
- package/lib/edge/{content-variants-dd7ea0f9.js → content-variants-8ab0c195.js} +13 -12
- package/lib/edge/{content-variants-fc207487.cjs → content-variants-aadc6d6c.cjs} +1 -1
- package/lib/edge/{evaluate-e2f692df.js → evaluate-1ef00edc.js} +87 -87
- package/lib/edge/{evaluate-3991fda5.cjs → evaluate-4d70dcda.cjs} +6 -6
- package/lib/edge/{form-b9148162.js → form-0e3e79d5.js} +4 -4
- package/lib/edge/{form-5eb85abf.cjs → form-8edb1a1e.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-0c783f8c.js → get-class-prop-name-c8375d5b.js} +1 -1
- package/lib/edge/{get-class-prop-name-2fa91d70.cjs → get-class-prop-name-f64b085a.cjs} +1 -1
- package/lib/edge/{img-602f7d3a.js → img-411548cf.js} +1 -1
- package/lib/edge/{img-2f30658b.cjs → img-a63de542.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +3 -3
- package/lib/edge/init.mjs +3 -3
- package/lib/edge/{input-551362f3.cjs → input-59f88558.cjs} +1 -1
- package/lib/edge/{input-4c791db9.js → input-a31ad183.js} +1 -1
- package/lib/edge/{select-eb26f837.cjs → select-31a4a930.cjs} +1 -1
- package/lib/edge/{select-d1391d12.js → select-bfc6e2dd.js} +1 -1
- package/lib/edge/{server-entry-c537d834.js → server-entry-899f7119.js} +1 -1
- package/lib/edge/{server-entry-7b4fa72f.cjs → server-entry-f0b40e5b.cjs} +1 -1
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-d375d5eb.js → slot-634372d2.js} +12 -11
- package/lib/edge/slot-c9228b15.cjs +1 -0
- package/lib/edge/{symbol-6c18ca90.cjs → symbol-10d573de.cjs} +1 -1
- package/lib/edge/{symbol-8b3a6b98.js → symbol-32a5d0f7.js} +2 -2
- package/lib/edge/{tabs-1e47cfd4.js → tabs-52ed1067.js} +4 -4
- package/lib/edge/{tabs-8296bce7.cjs → tabs-71e3e002.cjs} +1 -1
- package/lib/edge/{text-9eac9e4d.cjs → text-853d6ef4.cjs} +1 -1
- package/lib/edge/{text-d3c86634.js → text-ea8a6161.js} +2 -2
- package/lib/node/blocks-exports.cjs +32 -32
- package/lib/node/blocks-exports.mjs +1032 -996
- 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-e41e9eb6.js → node-runtime-792d0497.js} +3 -3
- package/lib/node/{node-runtime-c7c85f6c.cjs → node-runtime-8348be9f.cjs} +4 -4
- package/lib/{browser/server-entry-8bf52a55.js → node/server-entry-288f3748.js} +333 -330
- package/lib/node/server-entry-7304506e.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +3 -3
- package/types/blocks/slot/slot.d.ts +2 -2
- package/types/components/block/block.helpers.d.ts +1 -2
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/evaluate/node-runtime/init.d.ts +1 -0
- package/types/functions/get-processed-block.d.ts +1 -0
- package/lib/browser/server-entry-16fc27fe.cjs +0 -2
- package/lib/edge/blocks-854f4022.cjs +0 -12
- package/lib/edge/blocks-fdb24842.js +0 -808
- package/lib/edge/slot-d723d000.cjs +0 -1
- package/lib/node/server-entry-16fc27fe.cjs +0 -2
|
@@ -52,12 +52,72 @@ const tt = () => {
|
|
|
52
52
|
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
53
53
|
device: n ? "tablet" : e.any() ? "mobile" : "desktop"
|
|
54
54
|
};
|
|
55
|
-
}, m = (t) => t != null
|
|
55
|
+
}, m = (t) => t != null;
|
|
56
|
+
function _t(t) {
|
|
57
|
+
const e = t || (c() ? window.location.search : void 0);
|
|
58
|
+
return e ? V(e).indexOf("builder.preview=") !== -1 : !1;
|
|
59
|
+
}
|
|
60
|
+
const $t = (t) => ({
|
|
61
|
+
type: "builder.registerComponent",
|
|
62
|
+
data: U(t)
|
|
63
|
+
}), rt = (t) => {
|
|
64
|
+
const e = t.toString().trim();
|
|
65
|
+
return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
|
|
66
|
+
};
|
|
67
|
+
function U(t) {
|
|
68
|
+
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? rt(n) : n));
|
|
69
|
+
}
|
|
70
|
+
const x = {};
|
|
71
|
+
function ot(t, e) {
|
|
72
|
+
t === "plugin" && (e = U(e));
|
|
73
|
+
let n = x[t];
|
|
74
|
+
if (n || (n = x[t] = []), n.push(e), c()) {
|
|
75
|
+
const r = {
|
|
76
|
+
type: "builder.register",
|
|
77
|
+
data: {
|
|
78
|
+
type: t,
|
|
79
|
+
info: e
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
84
|
+
} catch (o) {
|
|
85
|
+
console.debug("Could not postmessage", o);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const A = {};
|
|
90
|
+
function Gt(t) {
|
|
91
|
+
if (c()) {
|
|
92
|
+
Object.assign(A, t);
|
|
93
|
+
const e = {
|
|
94
|
+
type: "builder.settingsChange",
|
|
95
|
+
data: A
|
|
96
|
+
};
|
|
97
|
+
parent.postMessage(e, "*");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const T = "builder.", st = "options.", M = (t) => {
|
|
101
|
+
if (!t)
|
|
102
|
+
return {};
|
|
103
|
+
const e = L(t), n = {};
|
|
104
|
+
return Object.keys(e).forEach((r) => {
|
|
105
|
+
if (r.startsWith(T)) {
|
|
106
|
+
const o = r.replace(T, "").replace(st, "");
|
|
107
|
+
n[o] = e[r];
|
|
108
|
+
}
|
|
109
|
+
}), n;
|
|
110
|
+
}, it = () => {
|
|
111
|
+
if (!c())
|
|
112
|
+
return {};
|
|
113
|
+
const t = new URLSearchParams(window.location.search);
|
|
114
|
+
return M(t);
|
|
115
|
+
}, at = (t) => {
|
|
56
116
|
if (t === "localhost" || t === "127.0.0.1")
|
|
57
117
|
return t;
|
|
58
118
|
const e = t.split(".");
|
|
59
119
|
return e.length > 2 ? e.slice(1).join(".") : t;
|
|
60
|
-
},
|
|
120
|
+
}, F = ({
|
|
61
121
|
name: t,
|
|
62
122
|
canTrack: e
|
|
63
123
|
}) => {
|
|
@@ -68,14 +128,14 @@ const tt = () => {
|
|
|
68
128
|
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
69
129
|
return;
|
|
70
130
|
}
|
|
71
|
-
},
|
|
131
|
+
}, N = async (t) => F(t), ct = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(m).join("; "), ut = [["secure", ""], ["SameSite", "None"]], dt = ({
|
|
72
132
|
name: t,
|
|
73
133
|
value: e,
|
|
74
134
|
expires: n
|
|
75
135
|
}) => {
|
|
76
|
-
const o = (c() ? location.protocol === "https:" : !0) ?
|
|
77
|
-
return
|
|
78
|
-
},
|
|
136
|
+
const o = (c() ? location.protocol === "https:" : !0) ? ut : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", at(window.location.hostname)], ...o];
|
|
137
|
+
return ct(a);
|
|
138
|
+
}, j = async ({
|
|
79
139
|
name: t,
|
|
80
140
|
value: e,
|
|
81
141
|
expires: n,
|
|
@@ -84,7 +144,7 @@ const tt = () => {
|
|
|
84
144
|
try {
|
|
85
145
|
if (!r)
|
|
86
146
|
return;
|
|
87
|
-
const o =
|
|
147
|
+
const o = dt({
|
|
88
148
|
name: t,
|
|
89
149
|
value: e,
|
|
90
150
|
expires: n
|
|
@@ -93,326 +153,89 @@ const tt = () => {
|
|
|
93
153
|
} catch (o) {
|
|
94
154
|
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
95
155
|
}
|
|
96
|
-
}, at = "builder.tests", E = (t) => `${at}.${t}`, ct = ({
|
|
97
|
-
contentId: t
|
|
98
|
-
}) => M({
|
|
99
|
-
name: E(t),
|
|
100
|
-
canTrack: !0
|
|
101
|
-
}), ut = ({
|
|
102
|
-
contentId: t
|
|
103
|
-
}) => U({
|
|
104
|
-
name: E(t),
|
|
105
|
-
canTrack: !0
|
|
106
|
-
}), dt = ({
|
|
107
|
-
contentId: t,
|
|
108
|
-
value: e
|
|
109
|
-
}) => F({
|
|
110
|
-
name: E(t),
|
|
111
|
-
value: e,
|
|
112
|
-
canTrack: !0
|
|
113
|
-
}), N = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, lt = ({
|
|
114
|
-
id: t,
|
|
115
|
-
variations: e
|
|
116
|
-
}) => {
|
|
117
|
-
var o;
|
|
118
|
-
let n = 0;
|
|
119
|
-
const r = Math.random();
|
|
120
|
-
for (const s in e) {
|
|
121
|
-
const a = (o = e[s]) == null ? void 0 : o.testRatio;
|
|
122
|
-
if (n += a, r < n)
|
|
123
|
-
return s;
|
|
124
|
-
}
|
|
125
|
-
return t;
|
|
126
|
-
}, j = (t) => {
|
|
127
|
-
const e = lt(t);
|
|
128
|
-
return dt({
|
|
129
|
-
contentId: t.id,
|
|
130
|
-
value: e
|
|
131
|
-
}).catch((n) => {
|
|
132
|
-
f.error("could not store A/B test variation: ", n);
|
|
133
|
-
}), e;
|
|
134
|
-
}, D = ({
|
|
135
|
-
item: t,
|
|
136
|
-
testGroupId: e
|
|
137
|
-
}) => {
|
|
138
|
-
const n = t.variations[e];
|
|
139
|
-
return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
140
|
-
!n ? {
|
|
141
|
-
testVariationId: t.id,
|
|
142
|
-
testVariationName: "Default"
|
|
143
|
-
} : {
|
|
144
|
-
data: n.data,
|
|
145
|
-
testVariationId: n.id,
|
|
146
|
-
testVariationName: n.name || (n.id === t.id ? "Default" : "")
|
|
147
|
-
};
|
|
148
|
-
}, _t = ({
|
|
149
|
-
item: t,
|
|
150
|
-
canTrack: e
|
|
151
|
-
}) => {
|
|
152
|
-
if (!e)
|
|
153
|
-
return t;
|
|
154
|
-
if (!t)
|
|
155
|
-
return;
|
|
156
|
-
if (!N(t))
|
|
157
|
-
return t;
|
|
158
|
-
const n = ut({
|
|
159
|
-
contentId: t.id
|
|
160
|
-
}) || j({
|
|
161
|
-
variations: t.variations,
|
|
162
|
-
id: t.id
|
|
163
|
-
}), r = D({
|
|
164
|
-
item: t,
|
|
165
|
-
testGroupId: n
|
|
166
|
-
});
|
|
167
|
-
return {
|
|
168
|
-
...t,
|
|
169
|
-
...r
|
|
170
|
-
};
|
|
171
|
-
}, ft = async ({
|
|
172
|
-
item: t,
|
|
173
|
-
canTrack: e
|
|
174
|
-
}) => {
|
|
175
|
-
if (!e || !N(t))
|
|
176
|
-
return t;
|
|
177
|
-
const r = await ct({
|
|
178
|
-
contentId: t.id
|
|
179
|
-
}) || j({
|
|
180
|
-
variations: t.variations,
|
|
181
|
-
id: t.id
|
|
182
|
-
}), o = D({
|
|
183
|
-
item: t,
|
|
184
|
-
testGroupId: r
|
|
185
|
-
});
|
|
186
|
-
return {
|
|
187
|
-
...t,
|
|
188
|
-
...o
|
|
189
|
-
};
|
|
190
|
-
}, ht = (t) => m(t) ? t : !0, $t = (t) => ({
|
|
191
|
-
type: "builder.registerComponent",
|
|
192
|
-
data: K(t)
|
|
193
|
-
}), gt = (t) => {
|
|
194
|
-
const e = t.toString().trim();
|
|
195
|
-
return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
|
|
196
|
-
};
|
|
197
|
-
function K(t) {
|
|
198
|
-
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? gt(n) : n));
|
|
199
|
-
}
|
|
200
|
-
function pt() {
|
|
201
|
-
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
202
|
-
}
|
|
203
|
-
function mt() {
|
|
204
|
-
const t = pt().fetch;
|
|
205
|
-
if (typeof t == "undefined")
|
|
206
|
-
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
207
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
208
|
-
return t;
|
|
209
|
-
}
|
|
210
|
-
const yt = mt();
|
|
211
|
-
function k(t, e = null, n = ".") {
|
|
212
|
-
return Object.keys(t).reduce((r, o) => {
|
|
213
|
-
const s = t[o], a = [e, o].filter(Boolean).join(n);
|
|
214
|
-
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
215
|
-
...r,
|
|
216
|
-
...k(s, a, n)
|
|
217
|
-
} : {
|
|
218
|
-
...r,
|
|
219
|
-
[a]: s
|
|
220
|
-
};
|
|
221
|
-
}, {});
|
|
222
|
-
}
|
|
223
|
-
function W(t, e, n = {}) {
|
|
224
|
-
for (const r in t) {
|
|
225
|
-
const o = t[r], s = e ? e + "." + r : r;
|
|
226
|
-
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? W(o, s, n) : n[s] = o;
|
|
227
|
-
}
|
|
228
|
-
return n;
|
|
229
|
-
}
|
|
230
|
-
const wt = "v3", x = "builder.", St = "options.", _ = (t) => {
|
|
231
|
-
if (!t)
|
|
232
|
-
return {};
|
|
233
|
-
const e = L(t), n = {};
|
|
234
|
-
return Object.keys(e).forEach((r) => {
|
|
235
|
-
if (r.startsWith(x)) {
|
|
236
|
-
const o = r.replace(x, "").replace(St, "");
|
|
237
|
-
n[o] = e[r];
|
|
238
|
-
}
|
|
239
|
-
}), n;
|
|
240
|
-
}, bt = () => {
|
|
241
|
-
if (!c())
|
|
242
|
-
return {};
|
|
243
|
-
const t = new URLSearchParams(window.location.search);
|
|
244
|
-
return _(t);
|
|
245
|
-
}, A = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t) => {
|
|
246
|
-
const {
|
|
247
|
-
limit: e = 30,
|
|
248
|
-
userAttributes: n,
|
|
249
|
-
query: r,
|
|
250
|
-
model: o,
|
|
251
|
-
apiKey: s,
|
|
252
|
-
enrich: a,
|
|
253
|
-
locale: d,
|
|
254
|
-
apiVersion: y = wt,
|
|
255
|
-
fields: p,
|
|
256
|
-
omit: I,
|
|
257
|
-
offset: u,
|
|
258
|
-
cacheSeconds: h,
|
|
259
|
-
staleCacheSeconds: g,
|
|
260
|
-
sort: w,
|
|
261
|
-
includeUnpublished: O
|
|
262
|
-
} = t;
|
|
263
|
-
if (!s)
|
|
264
|
-
throw new Error("Missing API key");
|
|
265
|
-
if (!["v3"].includes(y))
|
|
266
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
267
|
-
const X = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
268
|
-
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), 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 O == "boolean" && i.searchParams.set("includeUnpublished", String(O)), h && A(h) && i.searchParams.set("cacheSeconds", String(h)), g && A(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
269
|
-
const l = k({
|
|
270
|
-
sort: w
|
|
271
|
-
});
|
|
272
|
-
for (const S in l)
|
|
273
|
-
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
274
|
-
}
|
|
275
|
-
const q = {
|
|
276
|
-
...bt(),
|
|
277
|
-
...L(t.options || {})
|
|
278
|
-
}, C = k(q);
|
|
279
|
-
for (const l in C)
|
|
280
|
-
i.searchParams.set(l, String(C[l]));
|
|
281
|
-
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
282
|
-
const l = W({
|
|
283
|
-
query: r
|
|
284
|
-
});
|
|
285
|
-
for (const S in l)
|
|
286
|
-
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
287
|
-
}
|
|
288
|
-
return i;
|
|
289
|
-
}, vt = (t) => "results" in t;
|
|
290
|
-
async function It(t) {
|
|
291
|
-
const e = await Pt({
|
|
292
|
-
...t,
|
|
293
|
-
limit: 1
|
|
294
|
-
});
|
|
295
|
-
return e && e[0] || null;
|
|
296
|
-
}
|
|
297
|
-
const kt = async (t) => {
|
|
298
|
-
var s;
|
|
299
|
-
const e = P(t);
|
|
300
|
-
return await (await ((s = t.fetch) != null ? s : yt)(e.href, t.fetchOptions)).json();
|
|
301
|
-
}, Et = async (t, e, n = P(t)) => {
|
|
302
|
-
const r = ht(t.canTrack);
|
|
303
|
-
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
304
|
-
return e.results;
|
|
305
|
-
try {
|
|
306
|
-
const o = [];
|
|
307
|
-
for (const s of e.results)
|
|
308
|
-
o.push(await ft({
|
|
309
|
-
item: s,
|
|
310
|
-
canTrack: r
|
|
311
|
-
}));
|
|
312
|
-
e.results = o;
|
|
313
|
-
} catch (o) {
|
|
314
|
-
f.error("Could not process A/B tests. ", o);
|
|
315
|
-
}
|
|
316
|
-
return e.results;
|
|
317
156
|
};
|
|
318
|
-
|
|
319
|
-
try {
|
|
320
|
-
const e = P(t), n = await kt(t);
|
|
321
|
-
return vt(n) ? Et(t, n) : (f.error("Error fetching data. ", {
|
|
322
|
-
url: e,
|
|
323
|
-
content: n,
|
|
324
|
-
options: t
|
|
325
|
-
}), null);
|
|
326
|
-
} catch (e) {
|
|
327
|
-
return f.error("Error fetching data. ", e), null;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function Gt(t) {
|
|
331
|
-
const e = t || (c() ? window.location.search : void 0);
|
|
332
|
-
return e ? V(e).indexOf("builder.preview=") !== -1 : !1;
|
|
333
|
-
}
|
|
334
|
-
function Ot() {
|
|
157
|
+
function lt() {
|
|
335
158
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
336
159
|
const e = Math.random() * 16 | 0;
|
|
337
160
|
return (t == "x" ? e : e & 3 | 8).toString(16);
|
|
338
161
|
});
|
|
339
162
|
}
|
|
340
|
-
function
|
|
341
|
-
return
|
|
163
|
+
function D() {
|
|
164
|
+
return lt().replace(/-/g, "");
|
|
342
165
|
}
|
|
343
|
-
const
|
|
166
|
+
const K = "builderSessionId", ft = async ({
|
|
344
167
|
canTrack: t
|
|
345
168
|
}) => {
|
|
346
169
|
if (!t)
|
|
347
170
|
return;
|
|
348
|
-
const e = await
|
|
349
|
-
name:
|
|
171
|
+
const e = await N({
|
|
172
|
+
name: K,
|
|
350
173
|
canTrack: t
|
|
351
174
|
});
|
|
352
175
|
if (m(e))
|
|
353
176
|
return e;
|
|
354
177
|
{
|
|
355
|
-
const n =
|
|
356
|
-
return
|
|
178
|
+
const n = ht();
|
|
179
|
+
return gt({
|
|
357
180
|
id: n,
|
|
358
181
|
canTrack: t
|
|
359
182
|
}), n;
|
|
360
183
|
}
|
|
361
|
-
},
|
|
184
|
+
}, ht = () => D(), gt = ({
|
|
362
185
|
id: t,
|
|
363
186
|
canTrack: e
|
|
364
|
-
}) =>
|
|
365
|
-
name:
|
|
187
|
+
}) => j({
|
|
188
|
+
name: K,
|
|
366
189
|
value: t,
|
|
367
190
|
canTrack: e
|
|
368
|
-
}),
|
|
191
|
+
}), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, pt = ({
|
|
369
192
|
key: t,
|
|
370
193
|
canTrack: e
|
|
371
194
|
}) => {
|
|
372
195
|
var n;
|
|
373
196
|
try {
|
|
374
|
-
return e ? (n =
|
|
197
|
+
return e ? (n = W()) == null ? void 0 : n.getItem(t) : void 0;
|
|
375
198
|
} catch (r) {
|
|
376
199
|
console.debug("[LocalStorage] GET error: ", r);
|
|
377
200
|
return;
|
|
378
201
|
}
|
|
379
|
-
},
|
|
202
|
+
}, mt = ({
|
|
380
203
|
key: t,
|
|
381
204
|
canTrack: e,
|
|
382
205
|
value: n
|
|
383
206
|
}) => {
|
|
384
207
|
var r;
|
|
385
208
|
try {
|
|
386
|
-
e && ((r =
|
|
209
|
+
e && ((r = W()) == null || r.setItem(t, n));
|
|
387
210
|
} catch (o) {
|
|
388
211
|
console.debug("[LocalStorage] SET error: ", o);
|
|
389
212
|
}
|
|
390
|
-
},
|
|
213
|
+
}, _ = "builderVisitorId", yt = ({
|
|
391
214
|
canTrack: t
|
|
392
215
|
}) => {
|
|
393
216
|
if (!t)
|
|
394
217
|
return;
|
|
395
|
-
const e =
|
|
396
|
-
key:
|
|
218
|
+
const e = pt({
|
|
219
|
+
key: _,
|
|
397
220
|
canTrack: t
|
|
398
221
|
});
|
|
399
222
|
if (m(e))
|
|
400
223
|
return e;
|
|
401
224
|
{
|
|
402
|
-
const n =
|
|
403
|
-
return
|
|
225
|
+
const n = wt();
|
|
226
|
+
return St({
|
|
404
227
|
id: n,
|
|
405
228
|
canTrack: t
|
|
406
229
|
}), n;
|
|
407
230
|
}
|
|
408
|
-
},
|
|
231
|
+
}, wt = () => D(), St = ({
|
|
409
232
|
id: t,
|
|
410
233
|
canTrack: e
|
|
411
|
-
}) =>
|
|
412
|
-
key:
|
|
234
|
+
}) => mt({
|
|
235
|
+
key: _,
|
|
413
236
|
value: t,
|
|
414
237
|
canTrack: e
|
|
415
|
-
}),
|
|
238
|
+
}), bt = async ({
|
|
416
239
|
canTrack: t
|
|
417
240
|
}) => {
|
|
418
241
|
if (!t)
|
|
@@ -420,16 +243,16 @@ const G = "builderSessionId", Ct = async ({
|
|
|
420
243
|
visitorId: void 0,
|
|
421
244
|
sessionId: void 0
|
|
422
245
|
};
|
|
423
|
-
const e = await
|
|
246
|
+
const e = await ft({
|
|
424
247
|
canTrack: t
|
|
425
|
-
}), n =
|
|
248
|
+
}), n = yt({
|
|
426
249
|
canTrack: t
|
|
427
250
|
});
|
|
428
251
|
return {
|
|
429
252
|
sessionId: e,
|
|
430
253
|
visitorId: n
|
|
431
254
|
};
|
|
432
|
-
},
|
|
255
|
+
}, vt = async ({
|
|
433
256
|
type: t,
|
|
434
257
|
canTrack: e,
|
|
435
258
|
apiKey: n,
|
|
@@ -443,14 +266,14 @@ const G = "builderSessionId", Ct = async ({
|
|
|
443
266
|
url: location.href,
|
|
444
267
|
...r
|
|
445
268
|
},
|
|
446
|
-
...await
|
|
269
|
+
...await bt({
|
|
447
270
|
canTrack: e
|
|
448
271
|
}),
|
|
449
272
|
userAttributes: nt(),
|
|
450
273
|
ownerId: n
|
|
451
274
|
}
|
|
452
275
|
});
|
|
453
|
-
async function
|
|
276
|
+
async function It(t) {
|
|
454
277
|
if (!t.apiKey) {
|
|
455
278
|
f.error("Missing API key for track call. Please provide your API key.");
|
|
456
279
|
return;
|
|
@@ -459,7 +282,7 @@ async function Ft(t) {
|
|
|
459
282
|
return fetch("https://cdn.builder.io/api/v1/track", {
|
|
460
283
|
method: "POST",
|
|
461
284
|
body: JSON.stringify({
|
|
462
|
-
events: [await
|
|
285
|
+
events: [await vt(t)]
|
|
463
286
|
}),
|
|
464
287
|
headers: {
|
|
465
288
|
"content-type": "application/json"
|
|
@@ -469,37 +292,18 @@ async function Ft(t) {
|
|
|
469
292
|
console.error("Failed to track: ", e);
|
|
470
293
|
});
|
|
471
294
|
}
|
|
472
|
-
const Jt = (t) =>
|
|
295
|
+
const Jt = (t) => It({
|
|
473
296
|
...t,
|
|
474
297
|
canTrack: !0
|
|
475
|
-
}),
|
|
476
|
-
function
|
|
298
|
+
}), kt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
299
|
+
function $(t, e) {
|
|
477
300
|
if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
|
|
478
301
|
return !1;
|
|
479
302
|
const n = new URL(e.origin), r = n.hostname;
|
|
480
|
-
return (t ||
|
|
481
|
-
}
|
|
482
|
-
const jt = "2.0.9", T = {};
|
|
483
|
-
function Dt(t, e) {
|
|
484
|
-
t === "plugin" && (e = K(e));
|
|
485
|
-
let n = T[t];
|
|
486
|
-
if (n || (n = T[t] = []), n.push(e), c()) {
|
|
487
|
-
const r = {
|
|
488
|
-
type: "builder.register",
|
|
489
|
-
data: {
|
|
490
|
-
type: t,
|
|
491
|
-
info: e
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
try {
|
|
495
|
-
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
496
|
-
} catch (o) {
|
|
497
|
-
console.debug("Could not postmessage", o);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
303
|
+
return (t || kt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
500
304
|
}
|
|
501
|
-
const zt = () => {
|
|
502
|
-
|
|
305
|
+
const Et = "2.0.13", zt = () => {
|
|
306
|
+
ot("insertMenu", {
|
|
503
307
|
name: "_default",
|
|
504
308
|
default: !0,
|
|
505
309
|
items: [{
|
|
@@ -522,13 +326,13 @@ const zt = () => {
|
|
|
522
326
|
});
|
|
523
327
|
};
|
|
524
328
|
let R = !1;
|
|
525
|
-
const
|
|
329
|
+
const Pt = (t = {}) => {
|
|
526
330
|
var e, n;
|
|
527
331
|
R || (R = !0, c() && ((e = window.parent) == null || e.postMessage({
|
|
528
332
|
type: "builder.sdkInfo",
|
|
529
333
|
data: {
|
|
530
334
|
target: v,
|
|
531
|
-
version:
|
|
335
|
+
version: Et,
|
|
532
336
|
supportsPatchUpdates: !1,
|
|
533
337
|
// Supports builder-model="..." attribute which is needed to
|
|
534
338
|
// scope our '+ add block' button styling
|
|
@@ -542,7 +346,7 @@ const Kt = (t = {}) => {
|
|
|
542
346
|
}
|
|
543
347
|
}, "*"), window.addEventListener("message", (r) => {
|
|
544
348
|
var s, a;
|
|
545
|
-
if (
|
|
349
|
+
if (!$(t.trustedHosts, r))
|
|
546
350
|
return;
|
|
547
351
|
const {
|
|
548
352
|
data: o
|
|
@@ -583,12 +387,12 @@ const Kt = (t = {}) => {
|
|
|
583
387
|
}
|
|
584
388
|
}
|
|
585
389
|
})));
|
|
586
|
-
},
|
|
390
|
+
}, Ot = ({
|
|
587
391
|
model: t,
|
|
588
392
|
trustedHosts: e,
|
|
589
393
|
callbacks: n
|
|
590
394
|
}) => (r) => {
|
|
591
|
-
if (
|
|
395
|
+
if (!$(e, r))
|
|
592
396
|
return;
|
|
593
397
|
const {
|
|
594
398
|
data: o
|
|
@@ -613,8 +417,8 @@ const Kt = (t = {}) => {
|
|
|
613
417
|
if (!c)
|
|
614
418
|
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
615
419
|
};
|
|
616
|
-
|
|
617
|
-
const r =
|
|
420
|
+
Pt();
|
|
421
|
+
const r = Ot({
|
|
618
422
|
callbacks: {
|
|
619
423
|
contentUpdate: e,
|
|
620
424
|
animation: () => {
|
|
@@ -628,15 +432,214 @@ const Kt = (t = {}) => {
|
|
|
628
432
|
return window.addEventListener("message", r), () => {
|
|
629
433
|
window.removeEventListener("message", r);
|
|
630
434
|
};
|
|
631
|
-
},
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
435
|
+
}, Ct = "builder.tests", E = (t) => `${Ct}.${t}`, xt = ({
|
|
436
|
+
contentId: t
|
|
437
|
+
}) => N({
|
|
438
|
+
name: E(t),
|
|
439
|
+
canTrack: !0
|
|
440
|
+
}), At = ({
|
|
441
|
+
contentId: t
|
|
442
|
+
}) => F({
|
|
443
|
+
name: E(t),
|
|
444
|
+
canTrack: !0
|
|
445
|
+
}), Tt = ({
|
|
446
|
+
contentId: t,
|
|
447
|
+
value: e
|
|
448
|
+
}) => j({
|
|
449
|
+
name: E(t),
|
|
450
|
+
value: e,
|
|
451
|
+
canTrack: !0
|
|
452
|
+
}), G = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, Rt = ({
|
|
453
|
+
id: t,
|
|
454
|
+
variations: e
|
|
455
|
+
}) => {
|
|
456
|
+
var o;
|
|
457
|
+
let n = 0;
|
|
458
|
+
const r = Math.random();
|
|
459
|
+
for (const s in e) {
|
|
460
|
+
const a = (o = e[s]) == null ? void 0 : o.testRatio;
|
|
461
|
+
if (n += a, r < n)
|
|
462
|
+
return s;
|
|
463
|
+
}
|
|
464
|
+
return t;
|
|
465
|
+
}, J = (t) => {
|
|
466
|
+
const e = Rt(t);
|
|
467
|
+
return Tt({
|
|
468
|
+
contentId: t.id,
|
|
469
|
+
value: e
|
|
470
|
+
}).catch((n) => {
|
|
471
|
+
f.error("could not store A/B test variation: ", n);
|
|
472
|
+
}), e;
|
|
473
|
+
}, z = ({
|
|
474
|
+
item: t,
|
|
475
|
+
testGroupId: e
|
|
476
|
+
}) => {
|
|
477
|
+
const n = t.variations[e];
|
|
478
|
+
return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
479
|
+
!n ? {
|
|
480
|
+
testVariationId: t.id,
|
|
481
|
+
testVariationName: "Default"
|
|
482
|
+
} : {
|
|
483
|
+
data: n.data,
|
|
484
|
+
testVariationId: n.id,
|
|
485
|
+
testVariationName: n.name || (n.id === t.id ? "Default" : "")
|
|
486
|
+
};
|
|
487
|
+
}, Xt = ({
|
|
488
|
+
item: t,
|
|
489
|
+
canTrack: e
|
|
490
|
+
}) => {
|
|
491
|
+
if (!e)
|
|
492
|
+
return t;
|
|
493
|
+
if (!t)
|
|
494
|
+
return;
|
|
495
|
+
if (!G(t))
|
|
496
|
+
return t;
|
|
497
|
+
const n = At({
|
|
498
|
+
contentId: t.id
|
|
499
|
+
}) || J({
|
|
500
|
+
variations: t.variations,
|
|
501
|
+
id: t.id
|
|
502
|
+
}), r = z({
|
|
503
|
+
item: t,
|
|
504
|
+
testGroupId: n
|
|
505
|
+
});
|
|
506
|
+
return {
|
|
507
|
+
...t,
|
|
508
|
+
...r
|
|
509
|
+
};
|
|
510
|
+
}, Bt = async ({
|
|
511
|
+
item: t,
|
|
512
|
+
canTrack: e
|
|
513
|
+
}) => {
|
|
514
|
+
if (!e || !G(t))
|
|
515
|
+
return t;
|
|
516
|
+
const r = await xt({
|
|
517
|
+
contentId: t.id
|
|
518
|
+
}) || J({
|
|
519
|
+
variations: t.variations,
|
|
520
|
+
id: t.id
|
|
521
|
+
}), o = z({
|
|
522
|
+
item: t,
|
|
523
|
+
testGroupId: r
|
|
524
|
+
});
|
|
525
|
+
return {
|
|
526
|
+
...t,
|
|
527
|
+
...o
|
|
528
|
+
};
|
|
529
|
+
}, Lt = (t) => m(t) ? t : !0;
|
|
530
|
+
function Vt() {
|
|
531
|
+
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
532
|
+
}
|
|
533
|
+
function Ut() {
|
|
534
|
+
const t = Vt().fetch;
|
|
535
|
+
if (typeof t == "undefined")
|
|
536
|
+
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
537
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
538
|
+
return t;
|
|
539
|
+
}
|
|
540
|
+
const Mt = Ut();
|
|
541
|
+
function k(t, e = null, n = ".") {
|
|
542
|
+
return Object.keys(t).reduce((r, o) => {
|
|
543
|
+
const s = t[o], a = [e, o].filter(Boolean).join(n);
|
|
544
|
+
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
545
|
+
...r,
|
|
546
|
+
...k(s, a, n)
|
|
547
|
+
} : {
|
|
548
|
+
...r,
|
|
549
|
+
[a]: s
|
|
638
550
|
};
|
|
639
|
-
|
|
551
|
+
}, {});
|
|
552
|
+
}
|
|
553
|
+
function H(t, e, n = {}) {
|
|
554
|
+
for (const r in t) {
|
|
555
|
+
const o = t[r], s = e ? e + "." + r : r;
|
|
556
|
+
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
|
|
557
|
+
}
|
|
558
|
+
return n;
|
|
559
|
+
}
|
|
560
|
+
const Ft = "v3", B = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t) => {
|
|
561
|
+
const {
|
|
562
|
+
limit: e = 30,
|
|
563
|
+
userAttributes: n,
|
|
564
|
+
query: r,
|
|
565
|
+
model: o,
|
|
566
|
+
apiKey: s,
|
|
567
|
+
enrich: a,
|
|
568
|
+
locale: d,
|
|
569
|
+
apiVersion: y = Ft,
|
|
570
|
+
fields: p,
|
|
571
|
+
omit: I,
|
|
572
|
+
offset: u,
|
|
573
|
+
cacheSeconds: h,
|
|
574
|
+
staleCacheSeconds: g,
|
|
575
|
+
sort: w,
|
|
576
|
+
includeUnpublished: O
|
|
577
|
+
} = t;
|
|
578
|
+
if (!s)
|
|
579
|
+
throw new Error("Missing API key");
|
|
580
|
+
if (!["v3"].includes(y))
|
|
581
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
582
|
+
const X = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
583
|
+
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), 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 O == "boolean" && i.searchParams.set("includeUnpublished", String(O)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
584
|
+
const l = k({
|
|
585
|
+
sort: w
|
|
586
|
+
});
|
|
587
|
+
for (const S in l)
|
|
588
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
589
|
+
}
|
|
590
|
+
const q = {
|
|
591
|
+
...it(),
|
|
592
|
+
...L(t.options || {})
|
|
593
|
+
}, C = k(q);
|
|
594
|
+
for (const l in C)
|
|
595
|
+
i.searchParams.set(l, String(C[l]));
|
|
596
|
+
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
597
|
+
const l = H({
|
|
598
|
+
query: r
|
|
599
|
+
});
|
|
600
|
+
for (const S in l)
|
|
601
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
602
|
+
}
|
|
603
|
+
return i;
|
|
604
|
+
}, Nt = (t) => "results" in t;
|
|
605
|
+
async function jt(t) {
|
|
606
|
+
const e = await Wt({
|
|
607
|
+
...t,
|
|
608
|
+
limit: 1
|
|
609
|
+
});
|
|
610
|
+
return e && e[0] || null;
|
|
611
|
+
}
|
|
612
|
+
const Dt = async (t) => {
|
|
613
|
+
var s;
|
|
614
|
+
const e = P(t);
|
|
615
|
+
return await (await ((s = t.fetch) != null ? s : Mt)(e.href, t.fetchOptions)).json();
|
|
616
|
+
}, Kt = async (t, e, n = P(t)) => {
|
|
617
|
+
const r = Lt(t.canTrack);
|
|
618
|
+
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
619
|
+
return e.results;
|
|
620
|
+
try {
|
|
621
|
+
const o = [];
|
|
622
|
+
for (const s of e.results)
|
|
623
|
+
o.push(await Bt({
|
|
624
|
+
item: s,
|
|
625
|
+
canTrack: r
|
|
626
|
+
}));
|
|
627
|
+
e.results = o;
|
|
628
|
+
} catch (o) {
|
|
629
|
+
f.error("Could not process A/B tests. ", o);
|
|
630
|
+
}
|
|
631
|
+
return e.results;
|
|
632
|
+
};
|
|
633
|
+
async function Wt(t) {
|
|
634
|
+
try {
|
|
635
|
+
const e = P(t), n = await Dt(t);
|
|
636
|
+
return Nt(n) ? Kt(t, n) : (f.error("Error fetching data. ", {
|
|
637
|
+
url: e,
|
|
638
|
+
content: n,
|
|
639
|
+
options: t
|
|
640
|
+
}), null);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
return f.error("Error fetching data. ", e), null;
|
|
640
643
|
}
|
|
641
644
|
}
|
|
642
645
|
const qt = async (t) => {
|
|
@@ -651,39 +654,39 @@ const qt = async (t) => {
|
|
|
651
654
|
urlPath: e
|
|
652
655
|
} : {}
|
|
653
656
|
},
|
|
654
|
-
options:
|
|
657
|
+
options: M(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
|
|
655
658
|
};
|
|
656
659
|
return {
|
|
657
660
|
apiKey: n.apiKey,
|
|
658
661
|
model: n.model,
|
|
659
|
-
content: await
|
|
662
|
+
content: await jt(n)
|
|
660
663
|
};
|
|
661
664
|
};
|
|
662
665
|
export {
|
|
663
666
|
b as MSG_PREFIX,
|
|
664
667
|
v as TARGET,
|
|
665
|
-
|
|
666
|
-
|
|
668
|
+
Kt as _processContentResult,
|
|
669
|
+
It as _track,
|
|
667
670
|
m as checkIsDefined,
|
|
668
|
-
|
|
671
|
+
Ot as createEditorListener,
|
|
669
672
|
$t as createRegisterComponentMessage,
|
|
670
|
-
|
|
673
|
+
Mt as fetch,
|
|
671
674
|
qt as fetchBuilderProps,
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
675
|
+
Wt as fetchEntries,
|
|
676
|
+
jt as fetchOneEntry,
|
|
677
|
+
M as getBuilderSearchParams,
|
|
678
|
+
Lt as getDefaultCanTrack,
|
|
676
679
|
nt as getUserAttributes,
|
|
677
|
-
|
|
680
|
+
Xt as handleABTestingSync,
|
|
678
681
|
c as isBrowser,
|
|
679
682
|
Z as isEditing,
|
|
680
|
-
|
|
683
|
+
_t as isPreviewing,
|
|
681
684
|
f as logger,
|
|
682
|
-
|
|
685
|
+
ot as register,
|
|
683
686
|
zt as registerInsertMenu,
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
+
U as serializeIncludingFunctions,
|
|
688
|
+
Gt as setEditorSettings,
|
|
689
|
+
Pt as setupBrowserForEditing,
|
|
687
690
|
Ht as subscribeToEditor,
|
|
688
691
|
Jt as track
|
|
689
692
|
};
|