@builder.io/sdk-react 2.0.30 → 3.0.0
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 +1 -1
- package/lib/browser/blocks-exports.mjs +1 -1
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/{edge/server-entry-e26008c1.js → browser/server-entry-52c69986.js} +240 -234
- package/lib/browser/server-entry-f3c2ac77.cjs +2 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-359367e6.js → accordion-19141399.js} +1 -1
- package/lib/edge/{accordion-93512a19.cjs → accordion-98d9699d.cjs} +1 -1
- package/lib/edge/{blocks-44a0617b.cjs → blocks-672d29ca.cjs} +1 -1
- package/lib/edge/{blocks-d7ba8f6a.js → blocks-7299cf1f.js} +3 -3
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-0ae65c1d.cjs → button-90d3b8fd.cjs} +1 -1
- package/lib/edge/{button-ae26a553.js → button-a335b33d.js} +2 -2
- package/lib/edge/{columns-957c0468.js → columns-34eb4f77.js} +4 -4
- package/lib/edge/{columns-f7da8908.cjs → columns-96859531.cjs} +1 -1
- package/lib/edge/{content-variants-9bb0b7e9.cjs → content-variants-30e475b2.cjs} +1 -1
- package/lib/edge/{content-variants-d8a859a2.js → content-variants-eb0b71da.js} +11 -11
- package/lib/edge/{evaluate-8e8c9fec.js → evaluate-0793c18a.js} +1 -1
- package/lib/edge/{evaluate-21c48a1d.cjs → evaluate-84062c52.cjs} +1 -1
- package/lib/edge/{form-0b09120c.cjs → form-99fe0879.cjs} +1 -1
- package/lib/edge/{form-68fc4d5a.js → form-f468b835.js} +4 -4
- package/lib/edge/{get-class-prop-name-a6f0f92d.js → get-class-prop-name-79a17608.js} +1 -1
- package/lib/edge/{get-class-prop-name-ffeda28e.cjs → get-class-prop-name-f431302d.cjs} +1 -1
- package/lib/edge/{img-912b190b.js → img-0d66e9e1.js} +1 -1
- package/lib/edge/{img-89e32a84.cjs → img-da07f7ae.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-96ba83eb.js → input-5962ba3b.js} +1 -1
- package/lib/edge/{input-5ff8ae2e.cjs → input-f7f73607.cjs} +1 -1
- package/lib/edge/{select-5f5fed1c.cjs → select-1f1bb9a6.cjs} +1 -1
- package/lib/edge/{select-f66026e1.js → select-74305b69.js} +1 -1
- package/lib/edge/server-entry-4f813956.cjs +2 -0
- package/lib/{node/server-entry-c7147616.js → edge/server-entry-c793e7d2.js} +238 -237
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-d3473421.cjs → slot-0add1d03.cjs} +1 -1
- package/lib/edge/{slot-d09faa0a.js → slot-ad2d5248.js} +4 -4
- package/lib/edge/{symbol-ebccca9b.cjs → symbol-5baac842.cjs} +1 -1
- package/lib/edge/{symbol-285d196c.js → symbol-70bb59b7.js} +2 -2
- package/lib/edge/{tabs-39d86f86.js → tabs-0244ee23.js} +4 -4
- package/lib/edge/{tabs-61c59e0f.cjs → tabs-a4146223.cjs} +1 -1
- package/lib/edge/{text-40a616f5.cjs → text-214ed248.cjs} +1 -1
- package/lib/edge/{text-dce27428.js → text-2e3cf22b.js} +2 -2
- package/lib/node/blocks-exports.cjs +1 -1
- package/lib/node/blocks-exports.mjs +3 -3
- 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-d133a206.js → node/server-entry-60acf7c6.js} +208 -203
- package/lib/node/server-entry-e3ec26c9.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-a85e255e.cjs → setIvm-97b6edac.cjs} +1 -1
- package/lib/node/{setIvm-5ab140ad.js → setIvm-bcada801.js} +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-16ceec99.cjs → should-force-browser-runtime-in-node-16d6b365.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-1d3a044a.js → should-force-browser-runtime-in-node-f1c78223.js} +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/lib/browser/server-entry-d4ea1a12.cjs +0 -2
- package/lib/edge/server-entry-f09ee4f4.cjs +0 -2
- package/lib/node/server-entry-8e901e75.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 Xe(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]: ", f = {
|
|
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 = "3.0.0", 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.", F = (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
|
+
f.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,103 +114,135 @@ const T = "builder.", ue = "options.", F = (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
|
+
f.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
|
});
|
|
243
|
-
function
|
|
209
|
+
function ke(e) {
|
|
244
210
|
var t;
|
|
245
|
-
typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" &&
|
|
211
|
+
typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && f.log(e);
|
|
246
212
|
}
|
|
247
|
-
const
|
|
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 ({
|
|
248
246
|
canTrack: e
|
|
249
247
|
}) => {
|
|
250
248
|
if (!e)
|
|
@@ -252,16 +250,16 @@ const Oe = async ({
|
|
|
252
250
|
visitorId: void 0,
|
|
253
251
|
sessionId: void 0
|
|
254
252
|
};
|
|
255
|
-
const t = await
|
|
253
|
+
const t = await pe({
|
|
256
254
|
canTrack: e
|
|
257
|
-
}), n =
|
|
255
|
+
}), n = be({
|
|
258
256
|
canTrack: e
|
|
259
257
|
});
|
|
260
258
|
return {
|
|
261
259
|
sessionId: t,
|
|
262
260
|
visitorId: n
|
|
263
261
|
};
|
|
264
|
-
},
|
|
262
|
+
}, xe = async ({
|
|
265
263
|
type: e,
|
|
266
264
|
canTrack: t,
|
|
267
265
|
apiKey: n,
|
|
@@ -275,50 +273,50 @@ const Oe = async ({
|
|
|
275
273
|
url: location.href,
|
|
276
274
|
...r
|
|
277
275
|
},
|
|
278
|
-
...await
|
|
276
|
+
...await Ce({
|
|
279
277
|
canTrack: t
|
|
280
278
|
}),
|
|
281
|
-
userAttributes:
|
|
279
|
+
userAttributes: Pe(),
|
|
282
280
|
ownerId: n
|
|
283
281
|
}
|
|
284
282
|
});
|
|
285
|
-
async function
|
|
283
|
+
async function Ae({
|
|
286
284
|
apiHost: e,
|
|
287
285
|
...t
|
|
288
286
|
}) {
|
|
289
287
|
if (!t.apiKey) {
|
|
290
|
-
|
|
288
|
+
f.error("Missing API key for track call. Please provide your API key.");
|
|
291
289
|
return;
|
|
292
290
|
}
|
|
293
|
-
if (!t.canTrack ||
|
|
291
|
+
if (!t.canTrack || se() || !(c() || b === "reactNative"))
|
|
294
292
|
return;
|
|
295
293
|
const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
|
|
296
|
-
return
|
|
294
|
+
return ke(r), fetch(r, {
|
|
297
295
|
method: "POST",
|
|
298
296
|
body: JSON.stringify({
|
|
299
|
-
events: [await
|
|
297
|
+
events: [await xe(t)]
|
|
300
298
|
}),
|
|
301
299
|
headers: {
|
|
302
300
|
"content-type": "application/json",
|
|
303
|
-
...
|
|
301
|
+
...K()
|
|
304
302
|
},
|
|
305
303
|
mode: "cors"
|
|
306
304
|
}).catch((o) => {
|
|
307
305
|
console.error("Failed to track: ", o);
|
|
308
306
|
});
|
|
309
307
|
}
|
|
310
|
-
const
|
|
308
|
+
const Ye = (e) => Ae({
|
|
311
309
|
...e,
|
|
312
310
|
canTrack: !0
|
|
313
|
-
}),
|
|
314
|
-
function
|
|
311
|
+
}), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
312
|
+
function z(e, t) {
|
|
315
313
|
if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
|
|
316
314
|
return !1;
|
|
317
315
|
const n = new URL(t.origin), r = n.hostname;
|
|
318
|
-
return (e ||
|
|
316
|
+
return (e || Te).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
319
317
|
}
|
|
320
|
-
const
|
|
321
|
-
|
|
318
|
+
const Ze = () => {
|
|
319
|
+
ae("insertMenu", {
|
|
322
320
|
name: "_default",
|
|
323
321
|
default: !0,
|
|
324
322
|
items: [{
|
|
@@ -340,14 +338,14 @@ const Qe = () => {
|
|
|
340
338
|
}]
|
|
341
339
|
});
|
|
342
340
|
};
|
|
343
|
-
let
|
|
344
|
-
const
|
|
341
|
+
let U = !1;
|
|
342
|
+
const Be = (e = {}) => {
|
|
345
343
|
var t, n;
|
|
346
|
-
|
|
344
|
+
U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
347
345
|
type: "builder.sdkInfo",
|
|
348
346
|
data: {
|
|
349
347
|
target: b,
|
|
350
|
-
version:
|
|
348
|
+
version: D,
|
|
351
349
|
supportsPatchUpdates: !1,
|
|
352
350
|
// Supports builder-model="..." attribute which is needed to
|
|
353
351
|
// scope our '+ add block' button styling
|
|
@@ -361,7 +359,7 @@ const Ae = (e = {}) => {
|
|
|
361
359
|
}
|
|
362
360
|
}, "*"), window.addEventListener("message", (r) => {
|
|
363
361
|
var s, i;
|
|
364
|
-
if (!
|
|
362
|
+
if (!z(e.trustedHosts, r))
|
|
365
363
|
return;
|
|
366
364
|
const {
|
|
367
365
|
data: o
|
|
@@ -369,10 +367,10 @@ const Ae = (e = {}) => {
|
|
|
369
367
|
if (o != null && o.type)
|
|
370
368
|
switch (o.type) {
|
|
371
369
|
case "builder.evaluate": {
|
|
372
|
-
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);
|
|
373
371
|
let d, h = null;
|
|
374
372
|
try {
|
|
375
|
-
d =
|
|
373
|
+
d = k.apply(null, y);
|
|
376
374
|
} catch (g) {
|
|
377
375
|
h = g;
|
|
378
376
|
}
|
|
@@ -402,12 +400,12 @@ const Ae = (e = {}) => {
|
|
|
402
400
|
}
|
|
403
401
|
}
|
|
404
402
|
})));
|
|
405
|
-
},
|
|
403
|
+
}, Re = ({
|
|
406
404
|
model: e,
|
|
407
405
|
trustedHosts: t,
|
|
408
406
|
callbacks: n
|
|
409
407
|
}) => (r) => {
|
|
410
|
-
if (!
|
|
408
|
+
if (!z(t, r))
|
|
411
409
|
return;
|
|
412
410
|
const {
|
|
413
411
|
data: o
|
|
@@ -428,12 +426,12 @@ const Ae = (e = {}) => {
|
|
|
428
426
|
break;
|
|
429
427
|
}
|
|
430
428
|
}
|
|
431
|
-
},
|
|
429
|
+
}, et = (e, t, n) => {
|
|
432
430
|
if (!c)
|
|
433
|
-
return
|
|
431
|
+
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
434
432
|
};
|
|
435
|
-
|
|
436
|
-
const r =
|
|
433
|
+
Be();
|
|
434
|
+
const r = Re({
|
|
437
435
|
callbacks: {
|
|
438
436
|
contentUpdate: t,
|
|
439
437
|
animation: () => {
|
|
@@ -447,24 +445,24 @@ const Ae = (e = {}) => {
|
|
|
447
445
|
return window.addEventListener("message", r), () => {
|
|
448
446
|
window.removeEventListener("message", r);
|
|
449
447
|
};
|
|
450
|
-
},
|
|
448
|
+
}, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
|
|
451
449
|
contentId: e
|
|
452
|
-
}) =>
|
|
453
|
-
name:
|
|
450
|
+
}) => W({
|
|
451
|
+
name: P(e),
|
|
454
452
|
canTrack: !0
|
|
455
|
-
}),
|
|
453
|
+
}), Ve = ({
|
|
456
454
|
contentId: e
|
|
457
|
-
}) =>
|
|
458
|
-
name:
|
|
455
|
+
}) => j({
|
|
456
|
+
name: P(e),
|
|
459
457
|
canTrack: !0
|
|
460
|
-
}),
|
|
458
|
+
}), Fe = ({
|
|
461
459
|
contentId: e,
|
|
462
460
|
value: t
|
|
463
|
-
}) =>
|
|
464
|
-
name:
|
|
461
|
+
}) => $({
|
|
462
|
+
name: P(e),
|
|
465
463
|
value: t,
|
|
466
464
|
canTrack: !0
|
|
467
|
-
}),
|
|
465
|
+
}), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
|
|
468
466
|
id: e,
|
|
469
467
|
variations: t
|
|
470
468
|
}) => {
|
|
@@ -477,15 +475,15 @@ const Ae = (e = {}) => {
|
|
|
477
475
|
return s;
|
|
478
476
|
}
|
|
479
477
|
return e;
|
|
480
|
-
},
|
|
481
|
-
const t =
|
|
482
|
-
return
|
|
478
|
+
}, q = (e) => {
|
|
479
|
+
const t = Me(e);
|
|
480
|
+
return Fe({
|
|
483
481
|
contentId: e.id,
|
|
484
482
|
value: t
|
|
485
483
|
}).catch((n) => {
|
|
486
|
-
|
|
484
|
+
f.error("could not store A/B test variation: ", n);
|
|
487
485
|
}), t;
|
|
488
|
-
},
|
|
486
|
+
}, Q = ({
|
|
489
487
|
item: e,
|
|
490
488
|
testGroupId: t
|
|
491
489
|
}) => {
|
|
@@ -499,7 +497,7 @@ const Ae = (e = {}) => {
|
|
|
499
497
|
testVariationId: n.id,
|
|
500
498
|
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
501
499
|
};
|
|
502
|
-
},
|
|
500
|
+
}, tt = ({
|
|
503
501
|
item: e,
|
|
504
502
|
canTrack: t
|
|
505
503
|
}) => {
|
|
@@ -507,14 +505,14 @@ const Ae = (e = {}) => {
|
|
|
507
505
|
return e;
|
|
508
506
|
if (!e)
|
|
509
507
|
return;
|
|
510
|
-
if (!
|
|
508
|
+
if (!J(e))
|
|
511
509
|
return e;
|
|
512
|
-
const n =
|
|
510
|
+
const n = Ve({
|
|
513
511
|
contentId: e.id
|
|
514
|
-
}) ||
|
|
512
|
+
}) || q({
|
|
515
513
|
variations: e.variations,
|
|
516
514
|
id: e.id
|
|
517
|
-
}), r =
|
|
515
|
+
}), r = Q({
|
|
518
516
|
item: e,
|
|
519
517
|
testGroupId: n
|
|
520
518
|
});
|
|
@@ -522,18 +520,18 @@ const Ae = (e = {}) => {
|
|
|
522
520
|
...e,
|
|
523
521
|
...r
|
|
524
522
|
};
|
|
525
|
-
},
|
|
523
|
+
}, Ne = async ({
|
|
526
524
|
item: e,
|
|
527
525
|
canTrack: t
|
|
528
526
|
}) => {
|
|
529
|
-
if (!t || !
|
|
527
|
+
if (!t || !J(e))
|
|
530
528
|
return e;
|
|
531
|
-
const r = await
|
|
529
|
+
const r = await Le({
|
|
532
530
|
contentId: e.id
|
|
533
|
-
}) ||
|
|
531
|
+
}) || q({
|
|
534
532
|
variations: e.variations,
|
|
535
533
|
id: e.id
|
|
536
|
-
}), o =
|
|
534
|
+
}), o = Q({
|
|
537
535
|
item: e,
|
|
538
536
|
testGroupId: r
|
|
539
537
|
});
|
|
@@ -541,38 +539,38 @@ const Ae = (e = {}) => {
|
|
|
541
539
|
...e,
|
|
542
540
|
...o
|
|
543
541
|
};
|
|
544
|
-
},
|
|
545
|
-
function
|
|
542
|
+
}, De = (e) => m(e) ? e : !0;
|
|
543
|
+
function Ke() {
|
|
546
544
|
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
547
545
|
}
|
|
548
|
-
function
|
|
549
|
-
const e =
|
|
546
|
+
function je() {
|
|
547
|
+
const e = Ke().fetch;
|
|
550
548
|
if (typeof e == "undefined")
|
|
551
549
|
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
552
550
|
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
553
551
|
return e;
|
|
554
552
|
}
|
|
555
|
-
const
|
|
556
|
-
function
|
|
553
|
+
const We = je();
|
|
554
|
+
function O(e, t = null, n = ".") {
|
|
557
555
|
return Object.keys(e).reduce((r, o) => {
|
|
558
556
|
const s = e[o], i = [t, o].filter(Boolean).join(n);
|
|
559
557
|
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
560
558
|
...r,
|
|
561
|
-
...
|
|
559
|
+
...O(s, i, n)
|
|
562
560
|
} : {
|
|
563
561
|
...r,
|
|
564
562
|
[i]: s
|
|
565
563
|
};
|
|
566
564
|
}, {});
|
|
567
565
|
}
|
|
568
|
-
function
|
|
566
|
+
function Y(e, t, n = {}) {
|
|
569
567
|
for (const r in e) {
|
|
570
568
|
const o = e[r], s = t ? t + "." + r : r;
|
|
571
|
-
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;
|
|
572
570
|
}
|
|
573
571
|
return n;
|
|
574
572
|
}
|
|
575
|
-
const
|
|
573
|
+
const $e = "v3", L = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
|
|
576
574
|
const {
|
|
577
575
|
limit: t = 30,
|
|
578
576
|
userAttributes: n,
|
|
@@ -581,90 +579,94 @@ const je = "v3", R = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
|
|
|
581
579
|
apiKey: s,
|
|
582
580
|
enrich: i,
|
|
583
581
|
locale: u,
|
|
584
|
-
apiVersion: y =
|
|
582
|
+
apiVersion: y = $e,
|
|
585
583
|
fields: p,
|
|
586
|
-
omit:
|
|
584
|
+
omit: k,
|
|
587
585
|
offset: d,
|
|
588
586
|
cacheSeconds: h,
|
|
589
587
|
staleCacheSeconds: g,
|
|
590
588
|
sort: S,
|
|
591
|
-
includeUnpublished:
|
|
592
|
-
apiHost:
|
|
589
|
+
includeUnpublished: x,
|
|
590
|
+
apiHost: Z
|
|
593
591
|
} = e;
|
|
594
592
|
if (!s)
|
|
595
593
|
throw new Error("Missing API key");
|
|
596
594
|
if (!["v3"].includes(y))
|
|
597
595
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
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 l = O({
|
|
601
605
|
sort: S
|
|
602
606
|
});
|
|
603
|
-
for (const w in
|
|
604
|
-
a.searchParams.set(w, JSON.stringify(
|
|
607
|
+
for (const w in l)
|
|
608
|
+
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
605
609
|
}
|
|
606
|
-
const
|
|
607
|
-
...
|
|
608
|
-
...
|
|
609
|
-
},
|
|
610
|
-
for (const
|
|
611
|
-
a.searchParams.set(
|
|
612
|
-
if (
|
|
613
|
-
const
|
|
610
|
+
const ne = {
|
|
611
|
+
...ue(),
|
|
612
|
+
...V(e.options || {})
|
|
613
|
+
}, A = O(ne);
|
|
614
|
+
for (const l in A)
|
|
615
|
+
a.searchParams.set(l, String(A[l]));
|
|
616
|
+
if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
|
|
617
|
+
const l = Y({
|
|
614
618
|
query: r
|
|
615
619
|
});
|
|
616
|
-
for (const w in
|
|
617
|
-
a.searchParams.set(w, JSON.stringify(
|
|
620
|
+
for (const w in l)
|
|
621
|
+
a.searchParams.set(w, JSON.stringify(l[w]));
|
|
618
622
|
}
|
|
619
623
|
return a;
|
|
620
|
-
},
|
|
621
|
-
async function
|
|
622
|
-
const t = await
|
|
624
|
+
}, Ge = (e) => "results" in e;
|
|
625
|
+
async function _e(e) {
|
|
626
|
+
const t = await ze({
|
|
623
627
|
...e,
|
|
624
628
|
limit: 1
|
|
625
629
|
});
|
|
626
630
|
return t && t[0] || null;
|
|
627
631
|
}
|
|
628
|
-
const
|
|
632
|
+
const He = async (e) => {
|
|
629
633
|
var i, u;
|
|
630
|
-
const t =
|
|
634
|
+
const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
|
|
631
635
|
...e.fetchOptions,
|
|
632
636
|
headers: {
|
|
633
637
|
...(u = e.fetchOptions) == null ? void 0 : u.headers,
|
|
634
|
-
...
|
|
638
|
+
...K()
|
|
635
639
|
}
|
|
636
640
|
};
|
|
637
641
|
return await (await n(t.href, r)).json();
|
|
638
|
-
},
|
|
639
|
-
const r =
|
|
642
|
+
}, Xe = async (e, t, n = C(e)) => {
|
|
643
|
+
const r = De(e.canTrack);
|
|
640
644
|
if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
|
|
641
645
|
return t.results;
|
|
642
646
|
try {
|
|
643
647
|
const o = [];
|
|
644
648
|
for (const s of t.results)
|
|
645
|
-
o.push(await
|
|
649
|
+
o.push(await Ne({
|
|
646
650
|
item: s,
|
|
647
651
|
canTrack: r
|
|
648
652
|
}));
|
|
649
653
|
t.results = o;
|
|
650
654
|
} catch (o) {
|
|
651
|
-
|
|
655
|
+
f.error("Could not process A/B tests. ", o);
|
|
652
656
|
}
|
|
653
657
|
return t.results;
|
|
654
658
|
};
|
|
655
|
-
async function
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
+
async function ze(e) {
|
|
660
|
+
const t = C(e), n = await He(e);
|
|
661
|
+
if (!Ge(n))
|
|
662
|
+
throw f.error("Error fetching data. ", {
|
|
659
663
|
url: t,
|
|
660
664
|
content: n,
|
|
661
665
|
options: e
|
|
662
|
-
}),
|
|
663
|
-
|
|
664
|
-
return l.error("Error fetching data. ", t), null;
|
|
665
|
-
}
|
|
666
|
+
}), n;
|
|
667
|
+
return Xe(e, n);
|
|
666
668
|
}
|
|
667
|
-
const
|
|
669
|
+
const nt = async (e) => {
|
|
668
670
|
var r, o, s;
|
|
669
671
|
const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
|
|
670
672
|
...e,
|
|
@@ -676,39 +678,38 @@ const et = async (e) => {
|
|
|
676
678
|
urlPath: t
|
|
677
679
|
} : {}
|
|
678
680
|
},
|
|
679
|
-
options:
|
|
681
|
+
options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
|
|
680
682
|
};
|
|
681
683
|
return {
|
|
682
684
|
apiKey: n.apiKey,
|
|
683
685
|
model: n.model,
|
|
684
|
-
content: await
|
|
686
|
+
content: await _e(n)
|
|
685
687
|
};
|
|
686
688
|
};
|
|
687
689
|
export {
|
|
688
|
-
v as MSG_PREFIX,
|
|
689
690
|
b as TARGET,
|
|
690
|
-
|
|
691
|
-
|
|
691
|
+
Xe as _processContentResult,
|
|
692
|
+
Ae as _track,
|
|
692
693
|
m as checkIsDefined,
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
694
|
+
Re as createEditorListener,
|
|
695
|
+
qe as createRegisterComponentMessage,
|
|
696
|
+
nt as fetchBuilderProps,
|
|
697
|
+
ze as fetchEntries,
|
|
698
|
+
_e as fetchOneEntry,
|
|
699
|
+
N as getBuilderSearchParams,
|
|
700
|
+
De as getDefaultCanTrack,
|
|
701
|
+
Pe as getUserAttributes,
|
|
702
|
+
tt as handleABTestingSync,
|
|
702
703
|
c as isBrowser,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
704
|
+
se as isEditing,
|
|
705
|
+
Je as isPreviewing,
|
|
706
|
+
ke as logFetch,
|
|
707
|
+
f as logger,
|
|
708
|
+
ae as register,
|
|
709
|
+
Ze as registerInsertMenu,
|
|
710
|
+
M as serializeIncludingFunctions,
|
|
711
|
+
Qe as setEditorSettings,
|
|
712
|
+
Be as setupBrowserForEditing,
|
|
713
|
+
et as subscribeToEditor,
|
|
714
|
+
Ye as track
|
|
714
715
|
};
|