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