@builder.io/sdk-react 2.0.2 → 2.0.5
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 +29 -29
- package/lib/browser/blocks-exports.mjs +300 -278
- 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-0c6c220c.js +688 -0
- package/lib/browser/server-entry-7e145817.cjs +2 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-4f96554c.cjs → accordion-72dab8ce.cjs} +1 -1
- package/lib/edge/{accordion-ca081054.js → accordion-99129d68.js} +1 -1
- package/lib/edge/blocks-426e0c44.js +808 -0
- package/lib/edge/blocks-53ae1b87.cjs +12 -0
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-41169061.js → button-778062cd.js} +2 -2
- package/lib/edge/{button-5d140f8e.cjs → button-967d0268.cjs} +1 -1
- package/lib/edge/{columns-f8916a18.js → columns-3a8c4d3f.js} +53 -51
- package/lib/edge/columns-3b921658.cjs +28 -0
- package/lib/edge/{content-variants-71ee0c76.js → content-variants-15d191de.js} +28 -26
- package/lib/edge/content-variants-4b8718f8.cjs +134 -0
- package/lib/edge/evaluate-26c0fdb7.js +2615 -0
- package/lib/edge/evaluate-c0eeb4f8.cjs +21 -0
- package/lib/edge/form-9d9dce5d.cjs +1 -0
- package/lib/edge/{form-ac2f2a0e.js → form-ccb0b912.js} +8 -7
- package/lib/edge/{get-class-prop-name-a677d7a5.js → get-class-prop-name-0a91c3bd.js} +1 -1
- package/lib/edge/{get-class-prop-name-a9b4959e.cjs → get-class-prop-name-eae60eae.cjs} +1 -1
- package/lib/edge/{image-e3fcd611.js → image-6a074aab.js} +27 -25
- package/lib/edge/image-eebfcbac.cjs +17 -0
- package/lib/edge/{img-b91cb4fd.cjs → img-183de27d.cjs} +1 -1
- package/lib/edge/{img-8fc26395.js → img-75751c89.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-549f090e.js → input-27972020.js} +1 -1
- package/lib/edge/{input-ec7c695a.cjs → input-fd18a67d.cjs} +1 -1
- package/lib/edge/{select-6a5a28ac.js → select-60ff549c.js} +1 -1
- package/lib/edge/{select-3ffa9294.cjs → select-6ea0d59f.cjs} +1 -1
- package/lib/edge/server-entry-4133a544.cjs +2 -0
- package/lib/edge/server-entry-feff6177.js +689 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-40de071b.js → slot-2347377e.js} +12 -11
- package/lib/edge/slot-a4509cae.cjs +1 -0
- package/lib/edge/{symbol-76e76298.cjs → symbol-98650b06.cjs} +1 -1
- package/lib/edge/{symbol-e6515a5f.js → symbol-dcef0d8e.js} +2 -2
- package/lib/edge/{tabs-b75be82d.js → tabs-0784574b.js} +10 -9
- package/lib/edge/tabs-4c131e17.cjs +1 -0
- package/lib/edge/text-1c1986aa.cjs +1 -0
- package/lib/edge/text-6f7cbc35.js +38 -0
- package/lib/node/blocks-exports.cjs +16 -16
- package/lib/node/blocks-exports.mjs +255 -233
- 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-0e37d6f7.cjs → node-runtime-4978bc21.cjs} +2 -2
- package/lib/node/{node-runtime-0f3a5df1.js → node-runtime-ce5c71e5.js} +3 -2
- package/lib/node/server-entry-0c6c220c.js +688 -0
- package/lib/node/server-entry-7e145817.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +1 -1
- package/types/blocks/image/image.types.d.ts +2 -0
- package/types/blocks/symbol/symbol.types.d.ts +1 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/register-component.d.ts +2 -2
- package/lib/browser/server-entry-419c051e.cjs +0 -2
- package/lib/browser/server-entry-825b4408.js +0 -695
- package/lib/edge/blocks-078044bc.cjs +0 -32
- package/lib/edge/blocks-f55c7d3e.js +0 -3418
- package/lib/edge/columns-354bf349.cjs +0 -28
- package/lib/edge/content-variants-89a9389a.cjs +0 -134
- package/lib/edge/form-f2d2c2bf.cjs +0 -1
- package/lib/edge/image-344ddbb0.cjs +0 -17
- package/lib/edge/server-entry-966ac144.cjs +0 -2
- package/lib/edge/server-entry-d2020acf.js +0 -695
- package/lib/edge/slot-8b27e15e.cjs +0 -1
- package/lib/edge/tabs-9c5af0ec.cjs +0 -1
- package/lib/edge/text-5915f038.js +0 -17
- package/lib/edge/text-e6dbb721.cjs +0 -1
- package/lib/node/server-entry-5ebd1c9b.js +0 -695
- package/lib/node/server-entry-8002325b.cjs +0 -2
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
const v = "react", q = (t) => {
|
|
2
|
+
const e = {};
|
|
3
|
+
return t.forEach((n, r) => {
|
|
4
|
+
e[r] = n;
|
|
5
|
+
}), e;
|
|
6
|
+
}, L = (t) => t instanceof URLSearchParams ? q(t) : t, V = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
|
|
7
|
+
function c() {
|
|
8
|
+
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
|
+
}
|
|
10
|
+
function Q() {
|
|
11
|
+
return c() && window.self !== window.top;
|
|
12
|
+
}
|
|
13
|
+
function Y(t) {
|
|
14
|
+
return Q() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
15
|
+
V(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
16
|
+
}
|
|
17
|
+
function _t(t) {
|
|
18
|
+
const e = t || (c() ? window.location.search : void 0);
|
|
19
|
+
return e ? V(e).indexOf("builder.preview=") !== -1 : !1;
|
|
20
|
+
}
|
|
21
|
+
const $t = (t) => ({
|
|
22
|
+
type: "builder.registerComponent",
|
|
23
|
+
data: tt(t)
|
|
24
|
+
}), Z = (t) => {
|
|
25
|
+
const e = t.toString().trim();
|
|
26
|
+
return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
|
|
27
|
+
};
|
|
28
|
+
function tt(t) {
|
|
29
|
+
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? Z(n) : n));
|
|
30
|
+
}
|
|
31
|
+
const x = {};
|
|
32
|
+
function et(t, e) {
|
|
33
|
+
let n = x[t];
|
|
34
|
+
if (n || (n = x[t] = []), n.push(e), c()) {
|
|
35
|
+
const r = {
|
|
36
|
+
type: "builder.register",
|
|
37
|
+
data: {
|
|
38
|
+
type: t,
|
|
39
|
+
info: e
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
44
|
+
} catch (o) {
|
|
45
|
+
console.debug("Could not postmessage", o);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const A = {};
|
|
50
|
+
function Gt(t) {
|
|
51
|
+
if (c()) {
|
|
52
|
+
Object.assign(A, t);
|
|
53
|
+
const e = {
|
|
54
|
+
type: "builder.settingsChange",
|
|
55
|
+
data: A
|
|
56
|
+
};
|
|
57
|
+
parent.postMessage(e, "*");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const T = "builder.", nt = "options.", U = (t) => {
|
|
61
|
+
if (!t)
|
|
62
|
+
return {};
|
|
63
|
+
const e = L(t), n = {};
|
|
64
|
+
return Object.keys(e).forEach((r) => {
|
|
65
|
+
if (r.startsWith(T)) {
|
|
66
|
+
const o = r.replace(T, "").replace(nt, "");
|
|
67
|
+
n[o] = e[r];
|
|
68
|
+
}
|
|
69
|
+
}), n;
|
|
70
|
+
}, rt = () => {
|
|
71
|
+
if (!c())
|
|
72
|
+
return {};
|
|
73
|
+
const t = new URLSearchParams(window.location.search);
|
|
74
|
+
return U(t);
|
|
75
|
+
}, b = "[Builder.io]: ", f = {
|
|
76
|
+
log: (...t) => console.log(b, ...t),
|
|
77
|
+
error: (...t) => console.error(b, ...t),
|
|
78
|
+
warn: (...t) => console.warn(b, ...t),
|
|
79
|
+
debug: (...t) => console.debug(b, ...t)
|
|
80
|
+
}, m = (t) => t != null, ot = (t) => {
|
|
81
|
+
if (t === "localhost" || t === "127.0.0.1")
|
|
82
|
+
return t;
|
|
83
|
+
const e = t.split(".");
|
|
84
|
+
return e.length > 2 ? e.slice(1).join(".") : t;
|
|
85
|
+
}, M = ({
|
|
86
|
+
name: t,
|
|
87
|
+
canTrack: e
|
|
88
|
+
}) => {
|
|
89
|
+
var n;
|
|
90
|
+
try {
|
|
91
|
+
return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
|
|
92
|
+
} catch (r) {
|
|
93
|
+
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}, N = async (t) => M(t), st = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(m).join("; "), it = [["secure", ""], ["SameSite", "None"]], at = ({
|
|
97
|
+
name: t,
|
|
98
|
+
value: e,
|
|
99
|
+
expires: n
|
|
100
|
+
}) => {
|
|
101
|
+
const o = (c() ? location.protocol === "https:" : !0) ? it : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", ot(window.location.hostname)], ...o];
|
|
102
|
+
return st(a);
|
|
103
|
+
}, F = async ({
|
|
104
|
+
name: t,
|
|
105
|
+
value: e,
|
|
106
|
+
expires: n,
|
|
107
|
+
canTrack: r
|
|
108
|
+
}) => {
|
|
109
|
+
try {
|
|
110
|
+
if (!r)
|
|
111
|
+
return;
|
|
112
|
+
const o = at({
|
|
113
|
+
name: t,
|
|
114
|
+
value: e,
|
|
115
|
+
expires: n
|
|
116
|
+
});
|
|
117
|
+
document.cookie = o;
|
|
118
|
+
} catch (o) {
|
|
119
|
+
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
function ct() {
|
|
123
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
124
|
+
const e = Math.random() * 16 | 0;
|
|
125
|
+
return (t == "x" ? e : e & 3 | 8).toString(16);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function j() {
|
|
129
|
+
return ct().replace(/-/g, "");
|
|
130
|
+
}
|
|
131
|
+
const D = "builderSessionId", ut = async ({
|
|
132
|
+
canTrack: t
|
|
133
|
+
}) => {
|
|
134
|
+
if (!t)
|
|
135
|
+
return;
|
|
136
|
+
const e = await N({
|
|
137
|
+
name: D,
|
|
138
|
+
canTrack: t
|
|
139
|
+
});
|
|
140
|
+
if (m(e))
|
|
141
|
+
return e;
|
|
142
|
+
{
|
|
143
|
+
const n = dt();
|
|
144
|
+
return lt({
|
|
145
|
+
id: n,
|
|
146
|
+
canTrack: t
|
|
147
|
+
}), n;
|
|
148
|
+
}
|
|
149
|
+
}, dt = () => j(), lt = ({
|
|
150
|
+
id: t,
|
|
151
|
+
canTrack: e
|
|
152
|
+
}) => F({
|
|
153
|
+
name: D,
|
|
154
|
+
value: t,
|
|
155
|
+
canTrack: e
|
|
156
|
+
}), K = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ft = ({
|
|
157
|
+
key: t,
|
|
158
|
+
canTrack: e
|
|
159
|
+
}) => {
|
|
160
|
+
var n;
|
|
161
|
+
try {
|
|
162
|
+
return e ? (n = K()) == null ? void 0 : n.getItem(t) : void 0;
|
|
163
|
+
} catch (r) {
|
|
164
|
+
console.debug("[LocalStorage] GET error: ", r);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}, ht = ({
|
|
168
|
+
key: t,
|
|
169
|
+
canTrack: e,
|
|
170
|
+
value: n
|
|
171
|
+
}) => {
|
|
172
|
+
var r;
|
|
173
|
+
try {
|
|
174
|
+
e && ((r = K()) == null || r.setItem(t, n));
|
|
175
|
+
} catch (o) {
|
|
176
|
+
console.debug("[LocalStorage] SET error: ", o);
|
|
177
|
+
}
|
|
178
|
+
}, W = "builderVisitorId", gt = ({
|
|
179
|
+
canTrack: t
|
|
180
|
+
}) => {
|
|
181
|
+
if (!t)
|
|
182
|
+
return;
|
|
183
|
+
const e = ft({
|
|
184
|
+
key: W,
|
|
185
|
+
canTrack: t
|
|
186
|
+
});
|
|
187
|
+
if (m(e))
|
|
188
|
+
return e;
|
|
189
|
+
{
|
|
190
|
+
const n = pt();
|
|
191
|
+
return mt({
|
|
192
|
+
id: n,
|
|
193
|
+
canTrack: t
|
|
194
|
+
}), n;
|
|
195
|
+
}
|
|
196
|
+
}, pt = () => j(), mt = ({
|
|
197
|
+
id: t,
|
|
198
|
+
canTrack: e
|
|
199
|
+
}) => ht({
|
|
200
|
+
key: W,
|
|
201
|
+
value: t,
|
|
202
|
+
canTrack: e
|
|
203
|
+
}), yt = () => {
|
|
204
|
+
if (c()) {
|
|
205
|
+
const t = new URL(location.href);
|
|
206
|
+
return t.pathname === "" && (t.pathname = "/"), t;
|
|
207
|
+
} else
|
|
208
|
+
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
209
|
+
}, wt = () => typeof navigator == "object" && navigator.userAgent || "", St = () => {
|
|
210
|
+
const t = wt(), e = {
|
|
211
|
+
Android() {
|
|
212
|
+
return t.match(/Android/i);
|
|
213
|
+
},
|
|
214
|
+
BlackBerry() {
|
|
215
|
+
return t.match(/BlackBerry/i);
|
|
216
|
+
},
|
|
217
|
+
iOS() {
|
|
218
|
+
return t.match(/iPhone|iPod/i);
|
|
219
|
+
},
|
|
220
|
+
Opera() {
|
|
221
|
+
return t.match(/Opera Mini/i);
|
|
222
|
+
},
|
|
223
|
+
Windows() {
|
|
224
|
+
return t.match(/IEMobile/i) || t.match(/WPDesktop/i);
|
|
225
|
+
},
|
|
226
|
+
any() {
|
|
227
|
+
return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || v === "reactNative";
|
|
228
|
+
}
|
|
229
|
+
}, n = t.match(/Tablet|iPad/i), r = yt();
|
|
230
|
+
return {
|
|
231
|
+
urlPath: r == null ? void 0 : r.pathname,
|
|
232
|
+
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
233
|
+
device: n ? "tablet" : e.any() ? "mobile" : "desktop"
|
|
234
|
+
};
|
|
235
|
+
}, bt = async ({
|
|
236
|
+
canTrack: t
|
|
237
|
+
}) => {
|
|
238
|
+
if (!t)
|
|
239
|
+
return {
|
|
240
|
+
visitorId: void 0,
|
|
241
|
+
sessionId: void 0
|
|
242
|
+
};
|
|
243
|
+
const e = await ut({
|
|
244
|
+
canTrack: t
|
|
245
|
+
}), n = gt({
|
|
246
|
+
canTrack: t
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
sessionId: e,
|
|
250
|
+
visitorId: n
|
|
251
|
+
};
|
|
252
|
+
}, vt = async ({
|
|
253
|
+
type: t,
|
|
254
|
+
canTrack: e,
|
|
255
|
+
apiKey: n,
|
|
256
|
+
metadata: r,
|
|
257
|
+
...o
|
|
258
|
+
}) => ({
|
|
259
|
+
type: t,
|
|
260
|
+
data: {
|
|
261
|
+
...o,
|
|
262
|
+
metadata: {
|
|
263
|
+
url: location.href,
|
|
264
|
+
...r
|
|
265
|
+
},
|
|
266
|
+
...await bt({
|
|
267
|
+
canTrack: e
|
|
268
|
+
}),
|
|
269
|
+
userAttributes: St(),
|
|
270
|
+
ownerId: n
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
async function It(t) {
|
|
274
|
+
if (!t.apiKey) {
|
|
275
|
+
f.error("Missing API key for track call. Please provide your API key.");
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (t.canTrack && !Y() && (c() || v === "reactNative"))
|
|
279
|
+
return fetch("https://cdn.builder.io/api/v1/track", {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: JSON.stringify({
|
|
282
|
+
events: [await vt(t)]
|
|
283
|
+
}),
|
|
284
|
+
headers: {
|
|
285
|
+
"content-type": "application/json"
|
|
286
|
+
},
|
|
287
|
+
mode: "cors"
|
|
288
|
+
}).catch((e) => {
|
|
289
|
+
console.error("Failed to track: ", e);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const Jt = (t) => It({
|
|
293
|
+
...t,
|
|
294
|
+
canTrack: !0
|
|
295
|
+
}), kt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
296
|
+
function _(t, e) {
|
|
297
|
+
if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
|
|
298
|
+
return !1;
|
|
299
|
+
const n = new URL(e.origin), r = n.hostname;
|
|
300
|
+
return (t || kt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
301
|
+
}
|
|
302
|
+
const Et = "2.0.5", zt = () => {
|
|
303
|
+
et("insertMenu", {
|
|
304
|
+
name: "_default",
|
|
305
|
+
default: !0,
|
|
306
|
+
items: [{
|
|
307
|
+
name: "Box"
|
|
308
|
+
}, {
|
|
309
|
+
name: "Text"
|
|
310
|
+
}, {
|
|
311
|
+
name: "Image"
|
|
312
|
+
}, {
|
|
313
|
+
name: "Columns"
|
|
314
|
+
}, {
|
|
315
|
+
name: "Core:Section"
|
|
316
|
+
}, {
|
|
317
|
+
name: "Core:Button"
|
|
318
|
+
}, {
|
|
319
|
+
name: "Embed"
|
|
320
|
+
}, {
|
|
321
|
+
name: "Custom Code"
|
|
322
|
+
}]
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
let R = !1;
|
|
326
|
+
const Pt = (t = {}) => {
|
|
327
|
+
var e, n;
|
|
328
|
+
R || (R = !0, c() && ((e = window.parent) == null || e.postMessage({
|
|
329
|
+
type: "builder.sdkInfo",
|
|
330
|
+
data: {
|
|
331
|
+
target: v,
|
|
332
|
+
version: Et,
|
|
333
|
+
supportsPatchUpdates: !1,
|
|
334
|
+
// Supports builder-model="..." attribute which is needed to
|
|
335
|
+
// scope our '+ add block' button styling
|
|
336
|
+
supportsAddBlockScoping: !0,
|
|
337
|
+
supportsCustomBreakpoints: !0
|
|
338
|
+
}
|
|
339
|
+
}, "*"), (n = window.parent) == null || n.postMessage({
|
|
340
|
+
type: "builder.updateContent",
|
|
341
|
+
data: {
|
|
342
|
+
options: t
|
|
343
|
+
}
|
|
344
|
+
}, "*"), window.addEventListener("message", (r) => {
|
|
345
|
+
var s, a;
|
|
346
|
+
if (!_(t.trustedHosts, r))
|
|
347
|
+
return;
|
|
348
|
+
const {
|
|
349
|
+
data: o
|
|
350
|
+
} = r;
|
|
351
|
+
if (o != null && o.type)
|
|
352
|
+
switch (o.type) {
|
|
353
|
+
case "builder.evaluate": {
|
|
354
|
+
const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
|
|
355
|
+
let u, h = null;
|
|
356
|
+
try {
|
|
357
|
+
u = I.apply(null, y);
|
|
358
|
+
} catch (g) {
|
|
359
|
+
h = g;
|
|
360
|
+
}
|
|
361
|
+
h ? (s = window.parent) == null || s.postMessage({
|
|
362
|
+
type: "builder.evaluateError",
|
|
363
|
+
data: {
|
|
364
|
+
id: p,
|
|
365
|
+
error: h.message
|
|
366
|
+
}
|
|
367
|
+
}, "*") : u && typeof u.then == "function" ? u.then((g) => {
|
|
368
|
+
var w;
|
|
369
|
+
(w = window.parent) == null || w.postMessage({
|
|
370
|
+
type: "builder.evaluateResult",
|
|
371
|
+
data: {
|
|
372
|
+
id: p,
|
|
373
|
+
result: g
|
|
374
|
+
}
|
|
375
|
+
}, "*");
|
|
376
|
+
}).catch(console.error) : (a = window.parent) == null || a.postMessage({
|
|
377
|
+
type: "builder.evaluateResult",
|
|
378
|
+
data: {
|
|
379
|
+
result: u,
|
|
380
|
+
id: p
|
|
381
|
+
}
|
|
382
|
+
}, "*");
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
})));
|
|
387
|
+
}, Ot = ({
|
|
388
|
+
model: t,
|
|
389
|
+
trustedHosts: e,
|
|
390
|
+
callbacks: n
|
|
391
|
+
}) => (r) => {
|
|
392
|
+
if (!_(e, r))
|
|
393
|
+
return;
|
|
394
|
+
const {
|
|
395
|
+
data: o
|
|
396
|
+
} = r;
|
|
397
|
+
if (o)
|
|
398
|
+
switch (o.type) {
|
|
399
|
+
case "builder.configureSdk": {
|
|
400
|
+
n.configureSdk(o.data);
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
case "builder.triggerAnimation": {
|
|
404
|
+
n.animation(o.data);
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
case "builder.contentUpdate": {
|
|
408
|
+
const s = o.data, a = s.key || s.alias || s.entry || s.modelName, d = s.data;
|
|
409
|
+
a === t && n.contentUpdate(d);
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}, Ht = (t, e, n) => {
|
|
414
|
+
if (!c)
|
|
415
|
+
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
416
|
+
};
|
|
417
|
+
Pt();
|
|
418
|
+
const r = Ot({
|
|
419
|
+
callbacks: {
|
|
420
|
+
contentUpdate: e,
|
|
421
|
+
animation: () => {
|
|
422
|
+
},
|
|
423
|
+
configureSdk: () => {
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
model: t,
|
|
427
|
+
trustedHosts: n == null ? void 0 : n.trustedHosts
|
|
428
|
+
});
|
|
429
|
+
return window.addEventListener("message", r), () => {
|
|
430
|
+
window.removeEventListener("message", r);
|
|
431
|
+
};
|
|
432
|
+
}, Ct = "builder.tests", E = (t) => `${Ct}.${t}`, xt = ({
|
|
433
|
+
contentId: t
|
|
434
|
+
}) => N({
|
|
435
|
+
name: E(t),
|
|
436
|
+
canTrack: !0
|
|
437
|
+
}), At = ({
|
|
438
|
+
contentId: t
|
|
439
|
+
}) => M({
|
|
440
|
+
name: E(t),
|
|
441
|
+
canTrack: !0
|
|
442
|
+
}), Tt = ({
|
|
443
|
+
contentId: t,
|
|
444
|
+
value: e
|
|
445
|
+
}) => F({
|
|
446
|
+
name: E(t),
|
|
447
|
+
value: e,
|
|
448
|
+
canTrack: !0
|
|
449
|
+
}), $ = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, Rt = ({
|
|
450
|
+
id: t,
|
|
451
|
+
variations: e
|
|
452
|
+
}) => {
|
|
453
|
+
var o;
|
|
454
|
+
let n = 0;
|
|
455
|
+
const r = Math.random();
|
|
456
|
+
for (const s in e) {
|
|
457
|
+
const a = (o = e[s]) == null ? void 0 : o.testRatio;
|
|
458
|
+
if (n += a, r < n)
|
|
459
|
+
return s;
|
|
460
|
+
}
|
|
461
|
+
return t;
|
|
462
|
+
}, G = (t) => {
|
|
463
|
+
const e = Rt(t);
|
|
464
|
+
return Tt({
|
|
465
|
+
contentId: t.id,
|
|
466
|
+
value: e
|
|
467
|
+
}).catch((n) => {
|
|
468
|
+
f.error("could not store A/B test variation: ", n);
|
|
469
|
+
}), e;
|
|
470
|
+
}, J = ({
|
|
471
|
+
item: t,
|
|
472
|
+
testGroupId: e
|
|
473
|
+
}) => {
|
|
474
|
+
const n = t.variations[e];
|
|
475
|
+
return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
476
|
+
!n ? {
|
|
477
|
+
testVariationId: t.id,
|
|
478
|
+
testVariationName: "Default"
|
|
479
|
+
} : {
|
|
480
|
+
data: n.data,
|
|
481
|
+
testVariationId: n.id,
|
|
482
|
+
testVariationName: n.name || (n.id === t.id ? "Default" : "")
|
|
483
|
+
};
|
|
484
|
+
}, Xt = ({
|
|
485
|
+
item: t,
|
|
486
|
+
canTrack: e
|
|
487
|
+
}) => {
|
|
488
|
+
if (!e)
|
|
489
|
+
return t;
|
|
490
|
+
if (!t)
|
|
491
|
+
return;
|
|
492
|
+
if (!$(t))
|
|
493
|
+
return t;
|
|
494
|
+
const n = At({
|
|
495
|
+
contentId: t.id
|
|
496
|
+
}) || G({
|
|
497
|
+
variations: t.variations,
|
|
498
|
+
id: t.id
|
|
499
|
+
}), r = J({
|
|
500
|
+
item: t,
|
|
501
|
+
testGroupId: n
|
|
502
|
+
});
|
|
503
|
+
return {
|
|
504
|
+
...t,
|
|
505
|
+
...r
|
|
506
|
+
};
|
|
507
|
+
}, Bt = async ({
|
|
508
|
+
item: t,
|
|
509
|
+
canTrack: e
|
|
510
|
+
}) => {
|
|
511
|
+
if (!e || !$(t))
|
|
512
|
+
return t;
|
|
513
|
+
const r = await xt({
|
|
514
|
+
contentId: t.id
|
|
515
|
+
}) || G({
|
|
516
|
+
variations: t.variations,
|
|
517
|
+
id: t.id
|
|
518
|
+
}), o = J({
|
|
519
|
+
item: t,
|
|
520
|
+
testGroupId: r
|
|
521
|
+
});
|
|
522
|
+
return {
|
|
523
|
+
...t,
|
|
524
|
+
...o
|
|
525
|
+
};
|
|
526
|
+
}, Lt = (t) => m(t) ? t : !0;
|
|
527
|
+
function Vt() {
|
|
528
|
+
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
529
|
+
}
|
|
530
|
+
function Ut() {
|
|
531
|
+
const t = Vt().fetch;
|
|
532
|
+
if (typeof t == "undefined")
|
|
533
|
+
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
534
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
535
|
+
return t;
|
|
536
|
+
}
|
|
537
|
+
const Mt = Ut();
|
|
538
|
+
function k(t, e = null, n = ".") {
|
|
539
|
+
return Object.keys(t).reduce((r, o) => {
|
|
540
|
+
const s = t[o], a = [e, o].filter(Boolean).join(n);
|
|
541
|
+
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
542
|
+
...r,
|
|
543
|
+
...k(s, a, n)
|
|
544
|
+
} : {
|
|
545
|
+
...r,
|
|
546
|
+
[a]: s
|
|
547
|
+
};
|
|
548
|
+
}, {});
|
|
549
|
+
}
|
|
550
|
+
function z(t, e, n = {}) {
|
|
551
|
+
for (const r in t) {
|
|
552
|
+
const o = t[r], s = e ? e + "." + r : r;
|
|
553
|
+
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? z(o, s, n) : n[s] = o;
|
|
554
|
+
}
|
|
555
|
+
return n;
|
|
556
|
+
}
|
|
557
|
+
const Nt = "v3", B = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t) => {
|
|
558
|
+
const {
|
|
559
|
+
limit: e = 30,
|
|
560
|
+
userAttributes: n,
|
|
561
|
+
query: r,
|
|
562
|
+
model: o,
|
|
563
|
+
apiKey: s,
|
|
564
|
+
enrich: a,
|
|
565
|
+
locale: d,
|
|
566
|
+
apiVersion: y = Nt,
|
|
567
|
+
fields: p,
|
|
568
|
+
omit: I,
|
|
569
|
+
offset: u,
|
|
570
|
+
cacheSeconds: h,
|
|
571
|
+
staleCacheSeconds: g,
|
|
572
|
+
sort: w,
|
|
573
|
+
includeUnpublished: O
|
|
574
|
+
} = t;
|
|
575
|
+
if (!s)
|
|
576
|
+
throw new Error("Missing API key");
|
|
577
|
+
if (!["v3"].includes(y))
|
|
578
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
579
|
+
const H = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
580
|
+
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), i.searchParams.set("noTraverse", String(H)), 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) {
|
|
581
|
+
const l = k({
|
|
582
|
+
sort: w
|
|
583
|
+
});
|
|
584
|
+
for (const S in l)
|
|
585
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
586
|
+
}
|
|
587
|
+
const X = {
|
|
588
|
+
...rt(),
|
|
589
|
+
...L(t.options || {})
|
|
590
|
+
}, C = k(X);
|
|
591
|
+
for (const l in C)
|
|
592
|
+
i.searchParams.set(l, String(C[l]));
|
|
593
|
+
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
594
|
+
const l = z({
|
|
595
|
+
query: r
|
|
596
|
+
});
|
|
597
|
+
for (const S in l)
|
|
598
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
599
|
+
}
|
|
600
|
+
return i;
|
|
601
|
+
}, Ft = (t) => "results" in t;
|
|
602
|
+
async function jt(t) {
|
|
603
|
+
const e = await Wt({
|
|
604
|
+
...t,
|
|
605
|
+
limit: 1
|
|
606
|
+
});
|
|
607
|
+
return e && e[0] || null;
|
|
608
|
+
}
|
|
609
|
+
const Dt = async (t) => {
|
|
610
|
+
var s;
|
|
611
|
+
const e = P(t);
|
|
612
|
+
return await (await ((s = t.fetch) != null ? s : Mt)(e.href, t.fetchOptions)).json();
|
|
613
|
+
}, Kt = async (t, e, n = P(t)) => {
|
|
614
|
+
const r = Lt(t.canTrack);
|
|
615
|
+
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
616
|
+
return e.results;
|
|
617
|
+
try {
|
|
618
|
+
const o = [];
|
|
619
|
+
for (const s of e.results)
|
|
620
|
+
o.push(await Bt({
|
|
621
|
+
item: s,
|
|
622
|
+
canTrack: r
|
|
623
|
+
}));
|
|
624
|
+
e.results = o;
|
|
625
|
+
} catch (o) {
|
|
626
|
+
f.error("Could not process A/B tests. ", o);
|
|
627
|
+
}
|
|
628
|
+
return e.results;
|
|
629
|
+
};
|
|
630
|
+
async function Wt(t) {
|
|
631
|
+
try {
|
|
632
|
+
const e = P(t), n = await Dt(t);
|
|
633
|
+
return Ft(n) ? Kt(t, n) : (f.error("Error fetching data. ", {
|
|
634
|
+
url: e,
|
|
635
|
+
content: n,
|
|
636
|
+
options: t
|
|
637
|
+
}), null);
|
|
638
|
+
} catch (e) {
|
|
639
|
+
return f.error("Error fetching data. ", e), null;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const qt = async (t) => {
|
|
643
|
+
var r, o, s;
|
|
644
|
+
const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((o = t.userAttributes) == null ? void 0 : o.urlPath), n = {
|
|
645
|
+
...t,
|
|
646
|
+
apiKey: t.apiKey,
|
|
647
|
+
model: t.model || "page",
|
|
648
|
+
userAttributes: {
|
|
649
|
+
...t.userAttributes,
|
|
650
|
+
...e ? {
|
|
651
|
+
urlPath: e
|
|
652
|
+
} : {}
|
|
653
|
+
},
|
|
654
|
+
options: U(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
|
|
655
|
+
};
|
|
656
|
+
return {
|
|
657
|
+
apiKey: n.apiKey,
|
|
658
|
+
model: n.model,
|
|
659
|
+
content: await jt(n)
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
export {
|
|
663
|
+
b as MSG_PREFIX,
|
|
664
|
+
v as TARGET,
|
|
665
|
+
Kt as _processContentResult,
|
|
666
|
+
It as _track,
|
|
667
|
+
m as checkIsDefined,
|
|
668
|
+
Ot as createEditorListener,
|
|
669
|
+
$t as createRegisterComponentMessage,
|
|
670
|
+
Mt as fetch,
|
|
671
|
+
qt as fetchBuilderProps,
|
|
672
|
+
Wt as fetchEntries,
|
|
673
|
+
jt as fetchOneEntry,
|
|
674
|
+
U as getBuilderSearchParams,
|
|
675
|
+
Lt as getDefaultCanTrack,
|
|
676
|
+
St as getUserAttributes,
|
|
677
|
+
Xt as handleABTestingSync,
|
|
678
|
+
c as isBrowser,
|
|
679
|
+
Y as isEditing,
|
|
680
|
+
_t as isPreviewing,
|
|
681
|
+
f as logger,
|
|
682
|
+
et as register,
|
|
683
|
+
zt as registerInsertMenu,
|
|
684
|
+
tt as serializeComponentInfo,
|
|
685
|
+
Gt as setEditorSettings,
|
|
686
|
+
Pt as setupBrowserForEditing,
|
|
687
|
+
Ht as subscribeToEditor,
|
|
688
|
+
Jt as track
|
|
689
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-4133a544.cjs");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-feff6177.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
s as createRegisterComponentMessage,
|