@builder.io/sdk-react 2.0.29 → 2.0.31
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 +18 -18
- package/lib/browser/blocks-exports.mjs +584 -587
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/{edge/server-entry-05dd3f4b.js → browser/server-entry-77f4513c.js} +245 -228
- package/lib/browser/server-entry-d7a13b14.cjs +2 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-200ac141.cjs → accordion-696fad97.cjs} +1 -1
- package/lib/edge/{accordion-1fae9bd5.js → accordion-d1213549.js} +1 -1
- package/lib/edge/{blocks-b47cd3fc.js → blocks-9ef79098.js} +3 -3
- package/lib/edge/{blocks-fd9e445c.cjs → blocks-aa67fee8.cjs} +1 -1
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-ffe70d17.cjs → button-2ed05d22.cjs} +1 -1
- package/lib/edge/{button-5cc9a94f.js → button-b41f1129.js} +2 -2
- package/lib/edge/{columns-9ad996bb.js → columns-5f8497fb.js} +4 -4
- package/lib/edge/{columns-7651ba21.cjs → columns-ca9ac444.cjs} +1 -1
- package/lib/edge/{content-variants-a9017964.cjs → content-variants-2f5a6ccd.cjs} +4 -4
- package/lib/edge/{content-variants-0ece6057.js → content-variants-9c4db669.js} +118 -118
- package/lib/edge/{evaluate-73e0df40.cjs → evaluate-8453ffc0.cjs} +1 -1
- package/lib/edge/{evaluate-5cfe10b0.js → evaluate-f626f584.js} +1 -1
- package/lib/edge/{form-186bf59f.js → form-a5407307.js} +30 -33
- package/lib/edge/form-b0c5418b.cjs +1 -0
- package/lib/edge/{get-class-prop-name-7d6a77a4.js → get-class-prop-name-40d6defb.js} +1 -1
- package/lib/edge/{get-class-prop-name-11734dbc.cjs → get-class-prop-name-86f0330a.cjs} +1 -1
- package/lib/edge/{img-ef160d2b.cjs → img-83ed868e.cjs} +1 -1
- package/lib/edge/{img-6c1f4ea4.js → img-fa36f926.js} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-97dc199a.cjs → input-3106b577.cjs} +1 -1
- package/lib/edge/{input-b4ee4339.js → input-93e42e28.js} +1 -1
- package/lib/edge/{select-2cdf2c8f.cjs → select-29495824.cjs} +1 -1
- package/lib/edge/{select-e79d6e1b.js → select-4cf4356a.js} +1 -1
- package/lib/edge/server-entry-4cd5389e.cjs +2 -0
- package/lib/{node/server-entry-00c52924.js → edge/server-entry-ea35faa6.js} +243 -231
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-680234a8.js → slot-6ad4152e.js} +4 -4
- package/lib/edge/{slot-66ba436b.cjs → slot-c8ab71b6.cjs} +1 -1
- package/lib/edge/{symbol-4d0b1228.cjs → symbol-74313a4b.cjs} +1 -1
- package/lib/edge/{symbol-e920f028.js → symbol-d2b48e54.js} +2 -2
- package/lib/edge/{tabs-1bea88d1.js → tabs-6d924c90.js} +4 -4
- package/lib/edge/{tabs-1f3f45cf.cjs → tabs-f699b318.cjs} +1 -1
- package/lib/edge/{text-9533b278.cjs → text-7120ee0c.cjs} +1 -1
- package/lib/edge/{text-fd78274f.js → text-7137a306.js} +2 -2
- package/lib/node/blocks-exports.cjs +20 -20
- package/lib/node/blocks-exports.mjs +576 -579
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +3 -3
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/{browser/server-entry-712b1faa.js → node/server-entry-32ef60c0.js} +213 -197
- package/lib/node/server-entry-9c026e49.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-156def75.js → setIvm-26e65816.js} +1 -1
- package/lib/node/{setIvm-ca4d1590.cjs → setIvm-bf1ad328.cjs} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-bc24fcdd.cjs → should-force-browser-runtime-in-node-000957e3.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-eb3eac6a.js → should-force-browser-runtime-in-node-343fd6c7.js} +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/log-fetch.d.ts +1 -0
- package/lib/browser/server-entry-3e3279b7.cjs +0 -2
- package/lib/edge/form-c98c7fc1.cjs +0 -1
- package/lib/edge/server-entry-0224e0bb.cjs +0 -2
- package/lib/node/server-entry-0b1fe826.cjs +0 -2
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const b = "react",
|
|
2
|
-
log: (...e) => console.log(
|
|
3
|
-
error: (...e) => console.error(
|
|
4
|
-
warn: (...e) => console.warn(
|
|
5
|
-
debug: (...e) => console.debug(
|
|
1
|
+
const b = "react", I = "[Builder.io]: ", l = {
|
|
2
|
+
log: (...e) => console.log(I, ...e),
|
|
3
|
+
error: (...e) => console.error(I, ...e),
|
|
4
|
+
warn: (...e) => console.warn(I, ...e),
|
|
5
|
+
debug: (...e) => console.debug(I, ...e)
|
|
6
6
|
};
|
|
7
7
|
function c() {
|
|
8
8
|
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const re = (e) => {
|
|
11
11
|
const t = {};
|
|
12
12
|
return e.forEach((n, r) => {
|
|
13
13
|
t[r] = n;
|
|
14
14
|
}), t;
|
|
15
|
-
},
|
|
16
|
-
function
|
|
15
|
+
}, V = (e) => e instanceof URLSearchParams ? re(e) : e, F = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
|
|
16
|
+
function oe() {
|
|
17
17
|
return c() && window.self !== window.top;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
21
|
-
|
|
19
|
+
function se(e) {
|
|
20
|
+
return oe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
21
|
+
F(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const ie = () => {
|
|
24
24
|
if (c()) {
|
|
25
25
|
const e = new URL(location.href);
|
|
26
26
|
return e.pathname === "" && (e.pathname = "/"), e;
|
|
27
27
|
} else
|
|
28
28
|
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
29
|
-
},
|
|
30
|
-
const e =
|
|
29
|
+
}, ae = () => typeof navigator == "object" && navigator.userAgent || "", ce = () => {
|
|
30
|
+
const e = ae(), t = {
|
|
31
31
|
Android() {
|
|
32
32
|
return e.match(/Android/i);
|
|
33
33
|
},
|
|
@@ -46,32 +46,32 @@ const oe = () => {
|
|
|
46
46
|
any() {
|
|
47
47
|
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
|
|
48
48
|
}
|
|
49
|
-
}, n = e.match(/Tablet|iPad/i), r =
|
|
49
|
+
}, n = e.match(/Tablet|iPad/i), r = ie();
|
|
50
50
|
return {
|
|
51
51
|
urlPath: r == null ? void 0 : r.pathname,
|
|
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
55
|
}, m = (e) => e != null;
|
|
56
|
-
function
|
|
56
|
+
function Je(e) {
|
|
57
57
|
const t = e || (c() ? window.location.search : void 0);
|
|
58
|
-
return t ?
|
|
58
|
+
return t ? F(t).indexOf("builder.preview=") !== -1 : !1;
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const qe = (e) => ({
|
|
61
61
|
type: "builder.registerComponent",
|
|
62
|
-
data:
|
|
63
|
-
}),
|
|
64
|
-
const t = e.toString().trim();
|
|
65
|
-
return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
|
|
62
|
+
data: M(e)
|
|
63
|
+
}), ue = (e) => {
|
|
64
|
+
const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t);
|
|
65
|
+
return `return (${!t.startsWith("function") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`;
|
|
66
66
|
};
|
|
67
|
-
function
|
|
68
|
-
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ?
|
|
67
|
+
function M(e) {
|
|
68
|
+
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ue(n) : n));
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
function
|
|
72
|
-
e === "plugin" && (t =
|
|
73
|
-
let n =
|
|
74
|
-
if (n || (n =
|
|
70
|
+
const T = {};
|
|
71
|
+
function de(e, t) {
|
|
72
|
+
e === "plugin" && (t = M(t));
|
|
73
|
+
let n = T[e];
|
|
74
|
+
if (n || (n = T[e] = []), n.push(t), c()) {
|
|
75
75
|
const r = {
|
|
76
76
|
type: "builder.register",
|
|
77
77
|
data: {
|
|
@@ -86,42 +86,42 @@ function ce(e, t) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
89
|
+
const B = {};
|
|
90
|
+
function Qe(e) {
|
|
91
91
|
if (c()) {
|
|
92
|
-
Object.assign(
|
|
92
|
+
Object.assign(B, e);
|
|
93
93
|
const t = {
|
|
94
94
|
type: "builder.settingsChange",
|
|
95
|
-
data:
|
|
95
|
+
data: B
|
|
96
96
|
};
|
|
97
97
|
parent.postMessage(t, "*");
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const R = "builder.", le = "options.", N = (e) => {
|
|
101
101
|
if (!e)
|
|
102
102
|
return {};
|
|
103
|
-
const t =
|
|
103
|
+
const t = V(e), n = {};
|
|
104
104
|
return Object.keys(t).forEach((r) => {
|
|
105
|
-
if (r.startsWith(
|
|
106
|
-
const o = r.replace(
|
|
105
|
+
if (r.startsWith(R)) {
|
|
106
|
+
const o = r.replace(R, "").replace(le, "");
|
|
107
107
|
n[o] = t[r];
|
|
108
108
|
}
|
|
109
109
|
}), n;
|
|
110
|
-
},
|
|
110
|
+
}, fe = () => {
|
|
111
111
|
if (!c())
|
|
112
112
|
return {};
|
|
113
113
|
const e = new URLSearchParams(window.location.search);
|
|
114
|
-
return
|
|
115
|
-
},
|
|
114
|
+
return N(e);
|
|
115
|
+
}, D = "2.0.31", K = () => ({
|
|
116
116
|
"X-Builder-SDK": b,
|
|
117
117
|
"X-Builder-SDK-GEN": "2",
|
|
118
|
-
"X-Builder-SDK-Version":
|
|
119
|
-
}),
|
|
118
|
+
"X-Builder-SDK-Version": D
|
|
119
|
+
}), he = (e) => {
|
|
120
120
|
if (e === "localhost" || e === "127.0.0.1")
|
|
121
121
|
return e;
|
|
122
122
|
const t = e.split(".");
|
|
123
123
|
return t.length > 2 ? t.slice(1).join(".") : e;
|
|
124
|
-
},
|
|
124
|
+
}, j = ({
|
|
125
125
|
name: e,
|
|
126
126
|
canTrack: t
|
|
127
127
|
}) => {
|
|
@@ -129,17 +129,17 @@ const T = "builder.", ue = "options.", M = (e) => {
|
|
|
129
129
|
try {
|
|
130
130
|
return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
|
|
131
131
|
} catch (r) {
|
|
132
|
-
|
|
132
|
+
l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
-
},
|
|
135
|
+
}, W = async (e) => j(e), ge = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), pe = [["secure", ""], ["SameSite", "None"]], me = ({
|
|
136
136
|
name: e,
|
|
137
137
|
value: t,
|
|
138
138
|
expires: n
|
|
139
139
|
}) => {
|
|
140
|
-
const o = (c() ? location.protocol === "https:" : !0) ?
|
|
141
|
-
return
|
|
142
|
-
},
|
|
140
|
+
const o = (c() ? location.protocol === "https:" : !0) ? pe : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", he(window.location.hostname)], ...o];
|
|
141
|
+
return ge(i);
|
|
142
|
+
}, $ = async ({
|
|
143
143
|
name: e,
|
|
144
144
|
value: t,
|
|
145
145
|
expires: n,
|
|
@@ -148,98 +148,103 @@ const T = "builder.", ue = "options.", M = (e) => {
|
|
|
148
148
|
try {
|
|
149
149
|
if (!r)
|
|
150
150
|
return;
|
|
151
|
-
const o =
|
|
151
|
+
const o = me({
|
|
152
152
|
name: e,
|
|
153
153
|
value: t,
|
|
154
154
|
expires: n
|
|
155
155
|
});
|
|
156
156
|
document.cookie = o;
|
|
157
157
|
} catch (o) {
|
|
158
|
-
|
|
158
|
+
l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
function
|
|
161
|
+
function ye() {
|
|
162
162
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
163
163
|
const t = Math.random() * 16 | 0;
|
|
164
164
|
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return
|
|
167
|
+
function G() {
|
|
168
|
+
return ye().replace(/-/g, "");
|
|
169
169
|
}
|
|
170
|
-
const
|
|
170
|
+
const _ = "builderSessionId", Se = async ({
|
|
171
171
|
canTrack: e
|
|
172
172
|
}) => {
|
|
173
173
|
if (!e)
|
|
174
174
|
return;
|
|
175
|
-
const t = await
|
|
176
|
-
name:
|
|
175
|
+
const t = await W({
|
|
176
|
+
name: _,
|
|
177
177
|
canTrack: e
|
|
178
178
|
});
|
|
179
179
|
if (m(t))
|
|
180
180
|
return t;
|
|
181
181
|
{
|
|
182
|
-
const n =
|
|
183
|
-
return
|
|
182
|
+
const n = we();
|
|
183
|
+
return be({
|
|
184
184
|
id: n,
|
|
185
185
|
canTrack: e
|
|
186
186
|
}), n;
|
|
187
187
|
}
|
|
188
|
-
},
|
|
188
|
+
}, we = () => G(), be = ({
|
|
189
189
|
id: e,
|
|
190
190
|
canTrack: t
|
|
191
|
-
}) =>
|
|
192
|
-
name:
|
|
191
|
+
}) => $({
|
|
192
|
+
name: _,
|
|
193
193
|
value: e,
|
|
194
194
|
canTrack: t
|
|
195
|
-
}),
|
|
195
|
+
}), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ve = ({
|
|
196
196
|
key: e,
|
|
197
197
|
canTrack: t
|
|
198
198
|
}) => {
|
|
199
199
|
var n;
|
|
200
200
|
try {
|
|
201
|
-
return t ? (n =
|
|
201
|
+
return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
|
|
202
202
|
} catch (r) {
|
|
203
203
|
console.debug("[LocalStorage] GET error: ", r);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
},
|
|
206
|
+
}, Ie = ({
|
|
207
207
|
key: e,
|
|
208
208
|
canTrack: t,
|
|
209
209
|
value: n
|
|
210
210
|
}) => {
|
|
211
211
|
var r;
|
|
212
212
|
try {
|
|
213
|
-
t && ((r =
|
|
213
|
+
t && ((r = H()) == null || r.setItem(e, n));
|
|
214
214
|
} catch (o) {
|
|
215
215
|
console.debug("[LocalStorage] SET error: ", o);
|
|
216
216
|
}
|
|
217
|
-
},
|
|
217
|
+
}, X = "builderVisitorId", ke = ({
|
|
218
218
|
canTrack: e
|
|
219
219
|
}) => {
|
|
220
220
|
if (!e)
|
|
221
221
|
return;
|
|
222
|
-
const t =
|
|
223
|
-
key:
|
|
222
|
+
const t = ve({
|
|
223
|
+
key: X,
|
|
224
224
|
canTrack: e
|
|
225
225
|
});
|
|
226
226
|
if (m(t))
|
|
227
227
|
return t;
|
|
228
228
|
{
|
|
229
|
-
const n =
|
|
230
|
-
return
|
|
229
|
+
const n = Ee();
|
|
230
|
+
return Oe({
|
|
231
231
|
id: n,
|
|
232
232
|
canTrack: e
|
|
233
233
|
}), n;
|
|
234
234
|
}
|
|
235
|
-
},
|
|
235
|
+
}, Ee = () => G(), Oe = ({
|
|
236
236
|
id: e,
|
|
237
237
|
canTrack: t
|
|
238
|
-
}) =>
|
|
239
|
-
key:
|
|
238
|
+
}) => Ie({
|
|
239
|
+
key: X,
|
|
240
240
|
value: e,
|
|
241
241
|
canTrack: t
|
|
242
|
-
})
|
|
242
|
+
});
|
|
243
|
+
function Pe(e) {
|
|
244
|
+
var t;
|
|
245
|
+
typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && l.log(e);
|
|
246
|
+
}
|
|
247
|
+
const Ce = async ({
|
|
243
248
|
canTrack: e
|
|
244
249
|
}) => {
|
|
245
250
|
if (!e)
|
|
@@ -247,16 +252,16 @@ const $ = "builderSessionId", me = async ({
|
|
|
247
252
|
visitorId: void 0,
|
|
248
253
|
sessionId: void 0
|
|
249
254
|
};
|
|
250
|
-
const t = await
|
|
255
|
+
const t = await Se({
|
|
251
256
|
canTrack: e
|
|
252
|
-
}), n =
|
|
257
|
+
}), n = ke({
|
|
253
258
|
canTrack: e
|
|
254
259
|
});
|
|
255
260
|
return {
|
|
256
261
|
sessionId: t,
|
|
257
262
|
visitorId: n
|
|
258
263
|
};
|
|
259
|
-
},
|
|
264
|
+
}, xe = async ({
|
|
260
265
|
type: e,
|
|
261
266
|
canTrack: t,
|
|
262
267
|
apiKey: n,
|
|
@@ -270,47 +275,50 @@ const $ = "builderSessionId", me = async ({
|
|
|
270
275
|
url: location.href,
|
|
271
276
|
...r
|
|
272
277
|
},
|
|
273
|
-
...await
|
|
278
|
+
...await Ce({
|
|
274
279
|
canTrack: t
|
|
275
280
|
}),
|
|
276
|
-
userAttributes:
|
|
281
|
+
userAttributes: ce(),
|
|
277
282
|
ownerId: n
|
|
278
283
|
}
|
|
279
284
|
});
|
|
280
|
-
async function
|
|
285
|
+
async function Ae({
|
|
281
286
|
apiHost: e,
|
|
282
287
|
...t
|
|
283
288
|
}) {
|
|
284
289
|
if (!t.apiKey) {
|
|
285
|
-
|
|
290
|
+
l.error("Missing API key for track call. Please provide your API key.");
|
|
286
291
|
return;
|
|
287
292
|
}
|
|
288
|
-
|
|
293
|
+
if (!t.canTrack || se() || !(c() || b === "reactNative"))
|
|
294
|
+
return;
|
|
295
|
+
const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
|
|
296
|
+
return Pe(r), fetch(r, {
|
|
289
297
|
method: "POST",
|
|
290
298
|
body: JSON.stringify({
|
|
291
|
-
events: [await
|
|
299
|
+
events: [await xe(t)]
|
|
292
300
|
}),
|
|
293
301
|
headers: {
|
|
294
302
|
"content-type": "application/json",
|
|
295
|
-
...
|
|
303
|
+
...K()
|
|
296
304
|
},
|
|
297
305
|
mode: "cors"
|
|
298
|
-
}).catch((
|
|
299
|
-
console.error("Failed to track: ",
|
|
306
|
+
}).catch((o) => {
|
|
307
|
+
console.error("Failed to track: ", o);
|
|
300
308
|
});
|
|
301
309
|
}
|
|
302
|
-
const
|
|
310
|
+
const Ye = (e) => Ae({
|
|
303
311
|
...e,
|
|
304
312
|
canTrack: !0
|
|
305
|
-
}),
|
|
306
|
-
function
|
|
313
|
+
}), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
314
|
+
function z(e, t) {
|
|
307
315
|
if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
|
|
308
316
|
return !1;
|
|
309
317
|
const n = new URL(t.origin), r = n.hostname;
|
|
310
|
-
return (e ||
|
|
318
|
+
return (e || Te).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
311
319
|
}
|
|
312
|
-
const
|
|
313
|
-
|
|
320
|
+
const Ze = () => {
|
|
321
|
+
de("insertMenu", {
|
|
314
322
|
name: "_default",
|
|
315
323
|
default: !0,
|
|
316
324
|
items: [{
|
|
@@ -332,14 +340,14 @@ const qe = () => {
|
|
|
332
340
|
}]
|
|
333
341
|
});
|
|
334
342
|
};
|
|
335
|
-
let
|
|
336
|
-
const
|
|
343
|
+
let U = !1;
|
|
344
|
+
const Be = (e = {}) => {
|
|
337
345
|
var t, n;
|
|
338
|
-
|
|
346
|
+
U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
339
347
|
type: "builder.sdkInfo",
|
|
340
348
|
data: {
|
|
341
349
|
target: b,
|
|
342
|
-
version:
|
|
350
|
+
version: D,
|
|
343
351
|
supportsPatchUpdates: !1,
|
|
344
352
|
// Supports builder-model="..." attribute which is needed to
|
|
345
353
|
// scope our '+ add block' button styling
|
|
@@ -353,7 +361,7 @@ const xe = (e = {}) => {
|
|
|
353
361
|
}
|
|
354
362
|
}, "*"), window.addEventListener("message", (r) => {
|
|
355
363
|
var s, i;
|
|
356
|
-
if (!
|
|
364
|
+
if (!z(e.trustedHosts, r))
|
|
357
365
|
return;
|
|
358
366
|
const {
|
|
359
367
|
data: o
|
|
@@ -361,10 +369,10 @@ const xe = (e = {}) => {
|
|
|
361
369
|
if (o != null && o.type)
|
|
362
370
|
switch (o.type) {
|
|
363
371
|
case "builder.evaluate": {
|
|
364
|
-
const u = o.data.text, y = o.data.arguments || [], p = o.data.id,
|
|
372
|
+
const u = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(u);
|
|
365
373
|
let d, h = null;
|
|
366
374
|
try {
|
|
367
|
-
d =
|
|
375
|
+
d = k.apply(null, y);
|
|
368
376
|
} catch (g) {
|
|
369
377
|
h = g;
|
|
370
378
|
}
|
|
@@ -394,12 +402,12 @@ const xe = (e = {}) => {
|
|
|
394
402
|
}
|
|
395
403
|
}
|
|
396
404
|
})));
|
|
397
|
-
},
|
|
405
|
+
}, Re = ({
|
|
398
406
|
model: e,
|
|
399
407
|
trustedHosts: t,
|
|
400
408
|
callbacks: n
|
|
401
409
|
}) => (r) => {
|
|
402
|
-
if (!
|
|
410
|
+
if (!z(t, r))
|
|
403
411
|
return;
|
|
404
412
|
const {
|
|
405
413
|
data: o
|
|
@@ -420,12 +428,12 @@ const xe = (e = {}) => {
|
|
|
420
428
|
break;
|
|
421
429
|
}
|
|
422
430
|
}
|
|
423
|
-
},
|
|
431
|
+
}, et = (e, t, n) => {
|
|
424
432
|
if (!c)
|
|
425
|
-
return
|
|
433
|
+
return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
426
434
|
};
|
|
427
|
-
|
|
428
|
-
const r =
|
|
435
|
+
Be();
|
|
436
|
+
const r = Re({
|
|
429
437
|
callbacks: {
|
|
430
438
|
contentUpdate: t,
|
|
431
439
|
animation: () => {
|
|
@@ -439,24 +447,24 @@ const xe = (e = {}) => {
|
|
|
439
447
|
return window.addEventListener("message", r), () => {
|
|
440
448
|
window.removeEventListener("message", r);
|
|
441
449
|
};
|
|
442
|
-
},
|
|
450
|
+
}, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
|
|
443
451
|
contentId: e
|
|
444
|
-
}) =>
|
|
445
|
-
name:
|
|
452
|
+
}) => W({
|
|
453
|
+
name: P(e),
|
|
446
454
|
canTrack: !0
|
|
447
|
-
}),
|
|
455
|
+
}), Ve = ({
|
|
448
456
|
contentId: e
|
|
449
|
-
}) =>
|
|
450
|
-
name:
|
|
457
|
+
}) => j({
|
|
458
|
+
name: P(e),
|
|
451
459
|
canTrack: !0
|
|
452
|
-
}),
|
|
460
|
+
}), Fe = ({
|
|
453
461
|
contentId: e,
|
|
454
462
|
value: t
|
|
455
|
-
}) =>
|
|
456
|
-
name:
|
|
463
|
+
}) => $({
|
|
464
|
+
name: P(e),
|
|
457
465
|
value: t,
|
|
458
466
|
canTrack: !0
|
|
459
|
-
}),
|
|
467
|
+
}), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
|
|
460
468
|
id: e,
|
|
461
469
|
variations: t
|
|
462
470
|
}) => {
|
|
@@ -469,15 +477,15 @@ const xe = (e = {}) => {
|
|
|
469
477
|
return s;
|
|
470
478
|
}
|
|
471
479
|
return e;
|
|
472
|
-
},
|
|
473
|
-
const t =
|
|
474
|
-
return
|
|
480
|
+
}, q = (e) => {
|
|
481
|
+
const t = Me(e);
|
|
482
|
+
return Fe({
|
|
475
483
|
contentId: e.id,
|
|
476
484
|
value: t
|
|
477
485
|
}).catch((n) => {
|
|
478
|
-
|
|
486
|
+
l.error("could not store A/B test variation: ", n);
|
|
479
487
|
}), t;
|
|
480
|
-
},
|
|
488
|
+
}, Q = ({
|
|
481
489
|
item: e,
|
|
482
490
|
testGroupId: t
|
|
483
491
|
}) => {
|
|
@@ -491,7 +499,7 @@ const xe = (e = {}) => {
|
|
|
491
499
|
testVariationId: n.id,
|
|
492
500
|
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
493
501
|
};
|
|
494
|
-
},
|
|
502
|
+
}, tt = ({
|
|
495
503
|
item: e,
|
|
496
504
|
canTrack: t
|
|
497
505
|
}) => {
|
|
@@ -499,14 +507,14 @@ const xe = (e = {}) => {
|
|
|
499
507
|
return e;
|
|
500
508
|
if (!e)
|
|
501
509
|
return;
|
|
502
|
-
if (!
|
|
510
|
+
if (!J(e))
|
|
503
511
|
return e;
|
|
504
|
-
const n =
|
|
512
|
+
const n = Ve({
|
|
505
513
|
contentId: e.id
|
|
506
|
-
}) ||
|
|
514
|
+
}) || q({
|
|
507
515
|
variations: e.variations,
|
|
508
516
|
id: e.id
|
|
509
|
-
}), r =
|
|
517
|
+
}), r = Q({
|
|
510
518
|
item: e,
|
|
511
519
|
testGroupId: n
|
|
512
520
|
});
|
|
@@ -514,18 +522,18 @@ const xe = (e = {}) => {
|
|
|
514
522
|
...e,
|
|
515
523
|
...r
|
|
516
524
|
};
|
|
517
|
-
},
|
|
525
|
+
}, Ne = async ({
|
|
518
526
|
item: e,
|
|
519
527
|
canTrack: t
|
|
520
528
|
}) => {
|
|
521
|
-
if (!t || !
|
|
529
|
+
if (!t || !J(e))
|
|
522
530
|
return e;
|
|
523
|
-
const r = await
|
|
531
|
+
const r = await Le({
|
|
524
532
|
contentId: e.id
|
|
525
|
-
}) ||
|
|
533
|
+
}) || q({
|
|
526
534
|
variations: e.variations,
|
|
527
535
|
id: e.id
|
|
528
|
-
}), o =
|
|
536
|
+
}), o = Q({
|
|
529
537
|
item: e,
|
|
530
538
|
testGroupId: r
|
|
531
539
|
});
|
|
@@ -533,38 +541,38 @@ const xe = (e = {}) => {
|
|
|
533
541
|
...e,
|
|
534
542
|
...o
|
|
535
543
|
};
|
|
536
|
-
},
|
|
537
|
-
function
|
|
544
|
+
}, De = (e) => m(e) ? e : !0;
|
|
545
|
+
function Ke() {
|
|
538
546
|
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
539
547
|
}
|
|
540
|
-
function
|
|
541
|
-
const e =
|
|
548
|
+
function je() {
|
|
549
|
+
const e = Ke().fetch;
|
|
542
550
|
if (typeof e == "undefined")
|
|
543
551
|
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
544
552
|
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
545
553
|
return e;
|
|
546
554
|
}
|
|
547
|
-
const
|
|
548
|
-
function
|
|
555
|
+
const We = je();
|
|
556
|
+
function O(e, t = null, n = ".") {
|
|
549
557
|
return Object.keys(e).reduce((r, o) => {
|
|
550
558
|
const s = e[o], i = [t, o].filter(Boolean).join(n);
|
|
551
559
|
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
552
560
|
...r,
|
|
553
|
-
...
|
|
561
|
+
...O(s, i, n)
|
|
554
562
|
} : {
|
|
555
563
|
...r,
|
|
556
564
|
[i]: s
|
|
557
565
|
};
|
|
558
566
|
}, {});
|
|
559
567
|
}
|
|
560
|
-
function
|
|
568
|
+
function Y(e, t, n = {}) {
|
|
561
569
|
for (const r in e) {
|
|
562
570
|
const o = e[r], s = t ? t + "." + r : r;
|
|
563
|
-
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ?
|
|
571
|
+
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? Y(o, s, n) : n[s] = o;
|
|
564
572
|
}
|
|
565
573
|
return n;
|
|
566
574
|
}
|
|
567
|
-
const
|
|
575
|
+
const $e = "v3", L = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
|
|
568
576
|
const {
|
|
569
577
|
limit: t = 30,
|
|
570
578
|
userAttributes: n,
|
|
@@ -573,90 +581,96 @@ const Ke = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
|
|
|
573
581
|
apiKey: s,
|
|
574
582
|
enrich: i,
|
|
575
583
|
locale: u,
|
|
576
|
-
apiVersion: y =
|
|
584
|
+
apiVersion: y = $e,
|
|
577
585
|
fields: p,
|
|
578
|
-
omit:
|
|
586
|
+
omit: k,
|
|
579
587
|
offset: d,
|
|
580
588
|
cacheSeconds: h,
|
|
581
589
|
staleCacheSeconds: g,
|
|
582
590
|
sort: S,
|
|
583
|
-
includeUnpublished:
|
|
584
|
-
apiHost:
|
|
591
|
+
includeUnpublished: x,
|
|
592
|
+
apiHost: Z
|
|
585
593
|
} = e;
|
|
586
594
|
if (!s)
|
|
587
595
|
throw new Error("Missing API key");
|
|
588
596
|
if (!["v3"].includes(y))
|
|
589
597
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
598
|
+
const ee = t !== 1, te = Z || "https://cdn.builder.io", a = new URL(`${te}/api/${y}/content/${o}`);
|
|
599
|
+
a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(ee)), a.searchParams.set("includeRefs", String(!0));
|
|
600
|
+
const E = u || (n == null ? void 0 : n.locale);
|
|
601
|
+
let v = n;
|
|
602
|
+
if (E && (a.searchParams.set("locale", E), v = {
|
|
603
|
+
locale: E,
|
|
604
|
+
...v
|
|
605
|
+
}), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof x == "boolean" && a.searchParams.set("includeUnpublished", String(x)), h && L(h) && a.searchParams.set("cacheSeconds", String(h)), g && L(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
|
|
606
|
+
const f = O({
|
|
593
607
|
sort: S
|
|
594
608
|
});
|
|
595
|
-
for (const w in
|
|
596
|
-
a.searchParams.set(w, JSON.stringify(
|
|
609
|
+
for (const w in f)
|
|
610
|
+
a.searchParams.set(w, JSON.stringify(f[w]));
|
|
597
611
|
}
|
|
598
|
-
const
|
|
599
|
-
...
|
|
600
|
-
...
|
|
601
|
-
},
|
|
602
|
-
for (const
|
|
603
|
-
a.searchParams.set(
|
|
604
|
-
if (
|
|
605
|
-
const
|
|
612
|
+
const ne = {
|
|
613
|
+
...fe(),
|
|
614
|
+
...V(e.options || {})
|
|
615
|
+
}, A = O(ne);
|
|
616
|
+
for (const f in A)
|
|
617
|
+
a.searchParams.set(f, String(A[f]));
|
|
618
|
+
if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
|
|
619
|
+
const f = Y({
|
|
606
620
|
query: r
|
|
607
621
|
});
|
|
608
|
-
for (const w in
|
|
609
|
-
a.searchParams.set(w, JSON.stringify(
|
|
622
|
+
for (const w in f)
|
|
623
|
+
a.searchParams.set(w, JSON.stringify(f[w]));
|
|
610
624
|
}
|
|
611
625
|
return a;
|
|
612
|
-
},
|
|
613
|
-
async function
|
|
614
|
-
const t = await
|
|
626
|
+
}, Ge = (e) => "results" in e;
|
|
627
|
+
async function _e(e) {
|
|
628
|
+
const t = await ze({
|
|
615
629
|
...e,
|
|
616
630
|
limit: 1
|
|
617
631
|
});
|
|
618
632
|
return t && t[0] || null;
|
|
619
633
|
}
|
|
620
|
-
const
|
|
634
|
+
const He = async (e) => {
|
|
621
635
|
var i, u;
|
|
622
|
-
const t =
|
|
636
|
+
const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
|
|
623
637
|
...e.fetchOptions,
|
|
624
638
|
headers: {
|
|
625
639
|
...(u = e.fetchOptions) == null ? void 0 : u.headers,
|
|
626
|
-
...
|
|
640
|
+
...K()
|
|
627
641
|
}
|
|
628
642
|
};
|
|
629
643
|
return await (await n(t.href, r)).json();
|
|
630
|
-
},
|
|
631
|
-
const r =
|
|
644
|
+
}, Xe = async (e, t, n = C(e)) => {
|
|
645
|
+
const r = De(e.canTrack);
|
|
632
646
|
if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
|
|
633
647
|
return t.results;
|
|
634
648
|
try {
|
|
635
649
|
const o = [];
|
|
636
650
|
for (const s of t.results)
|
|
637
|
-
o.push(await
|
|
651
|
+
o.push(await Ne({
|
|
638
652
|
item: s,
|
|
639
653
|
canTrack: r
|
|
640
654
|
}));
|
|
641
655
|
t.results = o;
|
|
642
656
|
} catch (o) {
|
|
643
|
-
|
|
657
|
+
l.error("Could not process A/B tests. ", o);
|
|
644
658
|
}
|
|
645
659
|
return t.results;
|
|
646
660
|
};
|
|
647
|
-
async function
|
|
661
|
+
async function ze(e) {
|
|
648
662
|
try {
|
|
649
|
-
const t =
|
|
650
|
-
return
|
|
663
|
+
const t = C(e), n = await He(e);
|
|
664
|
+
return Ge(n) ? Xe(e, n) : (l.error("Error fetching data. ", {
|
|
651
665
|
url: t,
|
|
652
666
|
content: n,
|
|
653
667
|
options: e
|
|
654
668
|
}), null);
|
|
655
669
|
} catch (t) {
|
|
656
|
-
return
|
|
670
|
+
return l.error("Error fetching data. ", t), null;
|
|
657
671
|
}
|
|
658
672
|
}
|
|
659
|
-
const
|
|
673
|
+
const nt = async (e) => {
|
|
660
674
|
var r, o, s;
|
|
661
675
|
const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
|
|
662
676
|
...e,
|
|
@@ -668,37 +682,39 @@ const Ze = async (e) => {
|
|
|
668
682
|
urlPath: t
|
|
669
683
|
} : {}
|
|
670
684
|
},
|
|
671
|
-
options:
|
|
685
|
+
options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
|
|
672
686
|
};
|
|
673
687
|
return {
|
|
674
688
|
apiKey: n.apiKey,
|
|
675
689
|
model: n.model,
|
|
676
|
-
content: await
|
|
690
|
+
content: await _e(n)
|
|
677
691
|
};
|
|
678
692
|
};
|
|
679
693
|
export {
|
|
694
|
+
I as MSG_PREFIX,
|
|
680
695
|
b as TARGET,
|
|
681
|
-
|
|
682
|
-
|
|
696
|
+
Xe as _processContentResult,
|
|
697
|
+
Ae as _track,
|
|
683
698
|
m as checkIsDefined,
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
699
|
+
Re as createEditorListener,
|
|
700
|
+
qe as createRegisterComponentMessage,
|
|
701
|
+
nt as fetchBuilderProps,
|
|
702
|
+
ze as fetchEntries,
|
|
703
|
+
_e as fetchOneEntry,
|
|
704
|
+
N as getBuilderSearchParams,
|
|
705
|
+
De as getDefaultCanTrack,
|
|
706
|
+
ce as getUserAttributes,
|
|
707
|
+
tt as handleABTestingSync,
|
|
693
708
|
c as isBrowser,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
709
|
+
se as isEditing,
|
|
710
|
+
Je as isPreviewing,
|
|
711
|
+
Pe as logFetch,
|
|
712
|
+
l as logger,
|
|
713
|
+
de as register,
|
|
714
|
+
Ze as registerInsertMenu,
|
|
715
|
+
M as serializeIncludingFunctions,
|
|
716
|
+
Qe as setEditorSettings,
|
|
717
|
+
Be as setupBrowserForEditing,
|
|
718
|
+
et as subscribeToEditor,
|
|
719
|
+
Ye as track
|
|
704
720
|
};
|