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