@builder.io/sdk-solid 5.1.0 → 5.1.1
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/dev.js +409 -377
- package/lib/browser/dev.jsx +1097 -1065
- package/lib/browser/index.js +772 -740
- package/lib/browser/index.jsx +773 -741
- package/lib/edge/dev.js +409 -377
- package/lib/edge/dev.jsx +895 -863
- package/lib/edge/index.js +1170 -1138
- package/lib/edge/index.jsx +1172 -1140
- package/lib/node/dev.js +409 -377
- package/lib/node/dev.jsx +974 -942
- package/lib/node/index.js +775 -743
- package/lib/node/index.jsx +776 -744
- package/package.json +1 -1
package/lib/node/index.jsx
CHANGED
|
@@ -207,145 +207,433 @@ var getUserAttributes = () => {
|
|
|
207
207
|
};
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
// src/
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
// src/constants/sdk-version.ts
|
|
211
|
+
var SDK_VERSION = "5.1.1";
|
|
212
|
+
|
|
213
|
+
// src/helpers/sdk-headers.ts
|
|
214
|
+
var getSdkHeaders = () => ({
|
|
215
|
+
"X-Builder-SDK": TARGET,
|
|
216
|
+
"X-Builder-SDK-GEN": "2",
|
|
217
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// src/helpers/nullable.ts
|
|
221
|
+
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
222
|
+
|
|
223
|
+
// src/helpers/url.ts
|
|
224
|
+
var getTopLevelDomain = (host) => {
|
|
225
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
226
|
+
return host;
|
|
227
|
+
}
|
|
228
|
+
const parts = host.split(".");
|
|
229
|
+
if (parts.length > 2) {
|
|
230
|
+
return parts.slice(1).join(".");
|
|
231
|
+
}
|
|
232
|
+
return host;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/helpers/cookie.ts
|
|
236
|
+
var getCookieSync = ({
|
|
237
|
+
name,
|
|
238
|
+
canTrack
|
|
216
239
|
}) => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
240
|
+
try {
|
|
241
|
+
if (!canTrack) {
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
245
|
+
} catch (err) {
|
|
246
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
225
249
|
};
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
isExpression = true
|
|
250
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
251
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
252
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
253
|
+
var createCookieString = ({
|
|
254
|
+
name,
|
|
255
|
+
value,
|
|
256
|
+
expires
|
|
234
257
|
}) => {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
);
|
|
239
|
-
const
|
|
240
|
-
return
|
|
258
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
259
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
260
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
261
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
262
|
+
const cookie = stringifyCookie(cookieValue);
|
|
263
|
+
return cookie;
|
|
241
264
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
const val = target[prop];
|
|
253
|
-
if (typeof val === "object" && val !== null) {
|
|
254
|
-
return flattenState({
|
|
255
|
-
rootState: val,
|
|
256
|
-
localState: void 0,
|
|
257
|
-
rootSetState: rootSetState ? (subState) => {
|
|
258
|
-
target[prop] = subState;
|
|
259
|
-
rootSetState(target);
|
|
260
|
-
} : void 0
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
return val;
|
|
264
|
-
},
|
|
265
|
-
set: (target, prop, value) => {
|
|
266
|
-
if (localState && prop in localState) {
|
|
267
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
268
|
-
}
|
|
269
|
-
target[prop] = value;
|
|
270
|
-
rootSetState?.(target);
|
|
271
|
-
return true;
|
|
265
|
+
var setCookie = async ({
|
|
266
|
+
name,
|
|
267
|
+
value,
|
|
268
|
+
expires,
|
|
269
|
+
canTrack
|
|
270
|
+
}) => {
|
|
271
|
+
try {
|
|
272
|
+
if (!canTrack) {
|
|
273
|
+
return;
|
|
272
274
|
}
|
|
275
|
+
const cookie = createCookieString({
|
|
276
|
+
name,
|
|
277
|
+
value,
|
|
278
|
+
expires
|
|
279
|
+
});
|
|
280
|
+
document.cookie = cookie;
|
|
281
|
+
} catch (err) {
|
|
282
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/helpers/uuid.ts
|
|
287
|
+
function uuidv4() {
|
|
288
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
289
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
290
|
+
return v.toString(16);
|
|
273
291
|
});
|
|
274
292
|
}
|
|
293
|
+
function uuid() {
|
|
294
|
+
return uuidv4().replace(/-/g, "");
|
|
295
|
+
}
|
|
275
296
|
|
|
276
|
-
// src/
|
|
277
|
-
var
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
context,
|
|
281
|
-
event,
|
|
282
|
-
localState,
|
|
283
|
-
rootSetState,
|
|
284
|
-
rootState
|
|
297
|
+
// src/helpers/sessionId.ts
|
|
298
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
299
|
+
var getSessionId = async ({
|
|
300
|
+
canTrack
|
|
285
301
|
}) => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
context,
|
|
289
|
-
event,
|
|
290
|
-
state: flattenState({
|
|
291
|
-
rootState,
|
|
292
|
-
localState,
|
|
293
|
-
rootSetState
|
|
294
|
-
})
|
|
295
|
-
});
|
|
296
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// src/constants/sdk-name.ts
|
|
300
|
-
var SDK_NAME_FOR_TARGET = (() => {
|
|
301
|
-
switch (TARGET) {
|
|
302
|
-
case "rsc":
|
|
303
|
-
return "react-nextjs";
|
|
304
|
-
case "reactNative":
|
|
305
|
-
return "react-native";
|
|
306
|
-
default:
|
|
307
|
-
return TARGET;
|
|
302
|
+
if (!canTrack) {
|
|
303
|
+
return void 0;
|
|
308
304
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
305
|
+
const sessionId = await getCookie({
|
|
306
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
307
|
+
canTrack
|
|
308
|
+
});
|
|
309
|
+
if (checkIsDefined(sessionId)) {
|
|
310
|
+
return sessionId;
|
|
311
|
+
} else {
|
|
312
|
+
const newSessionId = createSessionId();
|
|
313
|
+
setSessionId({
|
|
314
|
+
id: newSessionId,
|
|
315
|
+
canTrack
|
|
316
|
+
});
|
|
317
|
+
return newSessionId;
|
|
319
318
|
}
|
|
320
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
321
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
322
|
-
return obj;
|
|
323
319
|
};
|
|
320
|
+
var createSessionId = () => uuid();
|
|
321
|
+
var setSessionId = ({
|
|
322
|
+
id,
|
|
323
|
+
canTrack
|
|
324
|
+
}) => setCookie({
|
|
325
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
326
|
+
value: id,
|
|
327
|
+
canTrack
|
|
328
|
+
});
|
|
324
329
|
|
|
325
|
-
// src/
|
|
326
|
-
|
|
327
|
-
var
|
|
330
|
+
// src/helpers/localStorage.ts
|
|
331
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
332
|
+
var getLocalStorageItem = ({
|
|
333
|
+
key,
|
|
334
|
+
canTrack
|
|
335
|
+
}) => {
|
|
336
|
+
try {
|
|
337
|
+
if (canTrack) {
|
|
338
|
+
return getLocalStorage()?.getItem(key);
|
|
339
|
+
}
|
|
340
|
+
return void 0;
|
|
341
|
+
} catch (err) {
|
|
342
|
+
return void 0;
|
|
343
|
+
}
|
|
328
344
|
};
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
345
|
+
var setLocalStorageItem = ({
|
|
346
|
+
key,
|
|
347
|
+
canTrack,
|
|
348
|
+
value
|
|
349
|
+
}) => {
|
|
333
350
|
try {
|
|
334
|
-
|
|
335
|
-
|
|
351
|
+
if (canTrack) {
|
|
352
|
+
getLocalStorage()?.setItem(key, value);
|
|
353
|
+
}
|
|
354
|
+
} catch (err) {
|
|
336
355
|
}
|
|
337
|
-
}
|
|
356
|
+
};
|
|
338
357
|
|
|
339
|
-
// src/
|
|
340
|
-
var
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return obj;
|
|
358
|
+
// src/helpers/visitorId.ts
|
|
359
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
360
|
+
var getVisitorId = ({
|
|
361
|
+
canTrack
|
|
362
|
+
}) => {
|
|
363
|
+
if (!canTrack) {
|
|
364
|
+
return void 0;
|
|
347
365
|
}
|
|
348
|
-
|
|
366
|
+
const visitorId = getLocalStorageItem({
|
|
367
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
368
|
+
canTrack
|
|
369
|
+
});
|
|
370
|
+
if (checkIsDefined(visitorId)) {
|
|
371
|
+
return visitorId;
|
|
372
|
+
} else {
|
|
373
|
+
const newVisitorId = createVisitorId();
|
|
374
|
+
setVisitorId({
|
|
375
|
+
id: newVisitorId,
|
|
376
|
+
canTrack
|
|
377
|
+
});
|
|
378
|
+
return newVisitorId;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var createVisitorId = () => uuid();
|
|
382
|
+
var setVisitorId = ({
|
|
383
|
+
id,
|
|
384
|
+
canTrack
|
|
385
|
+
}) => setLocalStorageItem({
|
|
386
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
387
|
+
value: id,
|
|
388
|
+
canTrack
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// src/functions/log-fetch.ts
|
|
392
|
+
function logFetch(url) {
|
|
393
|
+
if (typeof process !== "undefined" && process.env?.DEBUG) {
|
|
394
|
+
if (String(process.env.DEBUG) == "true") {
|
|
395
|
+
logger.log(url);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// src/functions/track/index.ts
|
|
401
|
+
var getTrackingEventData = async ({
|
|
402
|
+
canTrack
|
|
403
|
+
}) => {
|
|
404
|
+
if (!canTrack) {
|
|
405
|
+
return {
|
|
406
|
+
visitorId: void 0,
|
|
407
|
+
sessionId: void 0
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
const sessionId = await getSessionId({
|
|
411
|
+
canTrack
|
|
412
|
+
});
|
|
413
|
+
const visitorId = getVisitorId({
|
|
414
|
+
canTrack
|
|
415
|
+
});
|
|
416
|
+
return {
|
|
417
|
+
sessionId,
|
|
418
|
+
visitorId
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
var createEvent = async ({
|
|
422
|
+
type: eventType,
|
|
423
|
+
canTrack,
|
|
424
|
+
apiKey,
|
|
425
|
+
metadata,
|
|
426
|
+
...properties
|
|
427
|
+
}) => ({
|
|
428
|
+
type: eventType,
|
|
429
|
+
data: {
|
|
430
|
+
...properties,
|
|
431
|
+
metadata: {
|
|
432
|
+
url: location.href,
|
|
433
|
+
...metadata
|
|
434
|
+
},
|
|
435
|
+
...await getTrackingEventData({
|
|
436
|
+
canTrack
|
|
437
|
+
}),
|
|
438
|
+
userAttributes: getUserAttributes(),
|
|
439
|
+
ownerId: apiKey
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
async function _track({
|
|
443
|
+
apiHost,
|
|
444
|
+
...eventProps
|
|
445
|
+
}) {
|
|
446
|
+
if (!eventProps.apiKey) {
|
|
447
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (!eventProps.canTrack) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (isEditing()) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
460
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
461
|
+
logFetch(url);
|
|
462
|
+
return fetch(url, {
|
|
463
|
+
method: "POST",
|
|
464
|
+
body: JSON.stringify({
|
|
465
|
+
events: [await createEvent(eventProps)]
|
|
466
|
+
}),
|
|
467
|
+
headers: {
|
|
468
|
+
"content-type": "application/json",
|
|
469
|
+
...getSdkHeaders()
|
|
470
|
+
},
|
|
471
|
+
mode: "cors"
|
|
472
|
+
}).catch((err) => {
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
var track = (args) => _track({
|
|
476
|
+
...args,
|
|
477
|
+
canTrack: true
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// src/functions/evaluate/helpers.ts
|
|
481
|
+
var getFunctionArguments = ({
|
|
482
|
+
builder,
|
|
483
|
+
context,
|
|
484
|
+
event,
|
|
485
|
+
state
|
|
486
|
+
}) => {
|
|
487
|
+
return Object.entries({
|
|
488
|
+
state,
|
|
489
|
+
Builder: builder,
|
|
490
|
+
// legacy
|
|
491
|
+
builder,
|
|
492
|
+
context,
|
|
493
|
+
event
|
|
494
|
+
});
|
|
495
|
+
};
|
|
496
|
+
var getBuilderGlobals = (trackingContext) => ({
|
|
497
|
+
isEditing: isEditing(),
|
|
498
|
+
isBrowser: isBrowser(),
|
|
499
|
+
isServer: !isBrowser(),
|
|
500
|
+
getUserAttributes: () => getUserAttributes(),
|
|
501
|
+
trackConversion: (amount, customProperties) => {
|
|
502
|
+
if (!trackingContext?.apiKey || trackingContext?.canTrack === false) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
_track({
|
|
506
|
+
type: "conversion",
|
|
507
|
+
apiKey: trackingContext.apiKey,
|
|
508
|
+
canTrack: trackingContext.canTrack ?? true,
|
|
509
|
+
contentId: trackingContext.contentId,
|
|
510
|
+
variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
|
|
511
|
+
metadata: {
|
|
512
|
+
...customProperties || {},
|
|
513
|
+
...amount !== void 0 ? {
|
|
514
|
+
amount
|
|
515
|
+
} : {}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
var parseCode = (code, {
|
|
521
|
+
isExpression = true
|
|
522
|
+
}) => {
|
|
523
|
+
const useReturn = (
|
|
524
|
+
// we disable this for cases where we definitely don't want a return
|
|
525
|
+
isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
|
|
526
|
+
);
|
|
527
|
+
const useCode = useReturn ? `return (${code});` : code;
|
|
528
|
+
return useCode;
|
|
529
|
+
};
|
|
530
|
+
function flattenState({
|
|
531
|
+
rootState,
|
|
532
|
+
localState,
|
|
533
|
+
rootSetState
|
|
534
|
+
}) {
|
|
535
|
+
return new Proxy(rootState, {
|
|
536
|
+
get: (target, prop) => {
|
|
537
|
+
if (localState && prop in localState) {
|
|
538
|
+
return localState[prop];
|
|
539
|
+
}
|
|
540
|
+
const val = target[prop];
|
|
541
|
+
if (typeof val === "object" && val !== null) {
|
|
542
|
+
return flattenState({
|
|
543
|
+
rootState: val,
|
|
544
|
+
localState: void 0,
|
|
545
|
+
rootSetState: rootSetState ? (subState) => {
|
|
546
|
+
target[prop] = subState;
|
|
547
|
+
rootSetState(target);
|
|
548
|
+
} : void 0
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
return val;
|
|
552
|
+
},
|
|
553
|
+
set: (target, prop, value) => {
|
|
554
|
+
if (localState && prop in localState) {
|
|
555
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
556
|
+
}
|
|
557
|
+
target[prop] = value;
|
|
558
|
+
rootSetState?.(target);
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
565
|
+
var runInBrowser = ({
|
|
566
|
+
code,
|
|
567
|
+
builder,
|
|
568
|
+
context,
|
|
569
|
+
event,
|
|
570
|
+
localState,
|
|
571
|
+
rootSetState,
|
|
572
|
+
rootState
|
|
573
|
+
}) => {
|
|
574
|
+
const functionArgs = getFunctionArguments({
|
|
575
|
+
builder,
|
|
576
|
+
context,
|
|
577
|
+
event,
|
|
578
|
+
state: flattenState({
|
|
579
|
+
rootState,
|
|
580
|
+
localState,
|
|
581
|
+
rootSetState
|
|
582
|
+
})
|
|
583
|
+
});
|
|
584
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
// src/constants/sdk-name.ts
|
|
588
|
+
var SDK_NAME_FOR_TARGET = (() => {
|
|
589
|
+
switch (TARGET) {
|
|
590
|
+
case "rsc":
|
|
591
|
+
return "react-nextjs";
|
|
592
|
+
case "reactNative":
|
|
593
|
+
return "react-native";
|
|
594
|
+
default:
|
|
595
|
+
return TARGET;
|
|
596
|
+
}
|
|
597
|
+
})();
|
|
598
|
+
var SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`;
|
|
599
|
+
|
|
600
|
+
// src/functions/fast-clone.ts
|
|
601
|
+
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
602
|
+
|
|
603
|
+
// src/functions/set.ts
|
|
604
|
+
var set = (obj, _path, value) => {
|
|
605
|
+
if (Object(obj) !== obj) {
|
|
606
|
+
return obj;
|
|
607
|
+
}
|
|
608
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
609
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
610
|
+
return obj;
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
// src/functions/evaluate/node-runtime/safeDynamicRequire.ts
|
|
614
|
+
import { createRequire } from "node:module";
|
|
615
|
+
var noop = () => {
|
|
616
|
+
};
|
|
617
|
+
var safeDynamicRequire = noop;
|
|
618
|
+
try {
|
|
619
|
+
safeDynamicRequire = createRequire(import.meta.url);
|
|
620
|
+
} catch (error) {
|
|
621
|
+
try {
|
|
622
|
+
safeDynamicRequire = eval("require");
|
|
623
|
+
} catch (error2) {
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/functions/evaluate/node-runtime/node-runtime.ts
|
|
628
|
+
var getSyncValName = (key) => `bldr_${key}_sync`;
|
|
629
|
+
var BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
630
|
+
var INJECTED_IVM_GLOBAL = "BUILDER_IVM";
|
|
631
|
+
var REF_TO_PROXY_FN = `
|
|
632
|
+
var refToProxy = (obj) => {
|
|
633
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
634
|
+
return obj;
|
|
635
|
+
}
|
|
636
|
+
return new Proxy({}, {
|
|
349
637
|
get(target, key) {
|
|
350
638
|
if (key === 'copySync') {
|
|
351
639
|
return () => obj.copySync();
|
|
@@ -477,9 +765,6 @@ var runInNode = ({
|
|
|
477
765
|
}
|
|
478
766
|
};
|
|
479
767
|
|
|
480
|
-
// src/helpers/nullable.ts
|
|
481
|
-
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
482
|
-
|
|
483
768
|
// src/functions/is-node-runtime.ts
|
|
484
769
|
function isNodeRuntime() {
|
|
485
770
|
return typeof process !== "undefined" && checkIsDefined(process?.versions?.node);
|
|
@@ -524,7 +809,8 @@ function evaluate({
|
|
|
524
809
|
rootState,
|
|
525
810
|
rootSetState,
|
|
526
811
|
event,
|
|
527
|
-
isExpression = true
|
|
812
|
+
isExpression = true,
|
|
813
|
+
trackingContext
|
|
528
814
|
}) {
|
|
529
815
|
if (code.trim() === "") {
|
|
530
816
|
return void 0;
|
|
@@ -540,7 +826,7 @@ function evaluate({
|
|
|
540
826
|
code: parseCode(code, {
|
|
541
827
|
isExpression
|
|
542
828
|
}),
|
|
543
|
-
builder: getBuilderGlobals(),
|
|
829
|
+
builder: getBuilderGlobals(trackingContext),
|
|
544
830
|
context,
|
|
545
831
|
event,
|
|
546
832
|
rootSetState,
|
|
@@ -920,661 +1206,401 @@ function bindScrollInViewAnimation(animation) {
|
|
|
920
1206
|
const defaultState = animation.steps[0].styles;
|
|
921
1207
|
function attachDefaultState() {
|
|
922
1208
|
assign(element.style, defaultState);
|
|
923
|
-
}
|
|
924
|
-
attachDefaultState();
|
|
925
|
-
setTimeout(() => {
|
|
926
|
-
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
927
|
-
if (animation.delay) {
|
|
928
|
-
element.style.transitionDelay = animation.delay + "s";
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
document.addEventListener("scroll", onScroll, {
|
|
932
|
-
capture: true,
|
|
933
|
-
passive: true
|
|
934
|
-
});
|
|
935
|
-
immediateOnScroll();
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
// src/helpers/css.ts
|
|
940
|
-
var convertStyleMapToCSSArray = (style) => {
|
|
941
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
942
|
-
if (typeof value === "string") {
|
|
943
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
944
|
-
} else {
|
|
945
|
-
return void 0;
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
return cssProps.filter(checkIsDefined);
|
|
949
|
-
};
|
|
950
|
-
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
951
|
-
var createCssClass = ({
|
|
952
|
-
mediaQuery,
|
|
953
|
-
className,
|
|
954
|
-
styles
|
|
955
|
-
}) => {
|
|
956
|
-
const cssClass = `.${className} {
|
|
957
|
-
${convertStyleMapToCSS(styles)}
|
|
958
|
-
}`;
|
|
959
|
-
if (mediaQuery) {
|
|
960
|
-
return `${mediaQuery} {
|
|
961
|
-
${cssClass}
|
|
962
|
-
}`;
|
|
963
|
-
} else {
|
|
964
|
-
return cssClass;
|
|
965
|
-
}
|
|
966
|
-
};
|
|
967
|
-
|
|
968
|
-
// src/functions/transform-style-property.ts
|
|
969
|
-
function transformStyleProperty({
|
|
970
|
-
style
|
|
971
|
-
}) {
|
|
972
|
-
return style;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
// src/functions/get-style.ts
|
|
976
|
-
var getStyle = ({
|
|
977
|
-
block,
|
|
978
|
-
context
|
|
979
|
-
}) => {
|
|
980
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
981
|
-
style: block.style || {},
|
|
982
|
-
context,
|
|
983
|
-
block
|
|
984
|
-
}));
|
|
985
|
-
};
|
|
986
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
987
|
-
switch (TARGET) {
|
|
988
|
-
case "svelte":
|
|
989
|
-
case "vue":
|
|
990
|
-
case "solid":
|
|
991
|
-
case "angular":
|
|
992
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
993
|
-
case "qwik":
|
|
994
|
-
case "reactNative":
|
|
995
|
-
case "react":
|
|
996
|
-
case "rsc":
|
|
997
|
-
return style;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
// src/components/block/block.helpers.ts
|
|
1002
|
-
var checkIsComponentRestricted = (component, model) => {
|
|
1003
|
-
if (!component)
|
|
1004
|
-
return true;
|
|
1005
|
-
if (!model)
|
|
1006
|
-
return false;
|
|
1007
|
-
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
1008
|
-
};
|
|
1009
|
-
var getComponent = ({
|
|
1010
|
-
block,
|
|
1011
|
-
registeredComponents,
|
|
1012
|
-
model
|
|
1013
|
-
}) => {
|
|
1014
|
-
const componentName = block.component?.name;
|
|
1015
|
-
if (!componentName) {
|
|
1016
|
-
return null;
|
|
1017
|
-
}
|
|
1018
|
-
const ref = registeredComponents[componentName];
|
|
1019
|
-
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
1020
|
-
return void 0;
|
|
1021
|
-
} else {
|
|
1022
|
-
return ref;
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
var getRepeatItemData = ({
|
|
1026
|
-
block,
|
|
1027
|
-
context
|
|
1028
|
-
}) => {
|
|
1029
|
-
const {
|
|
1030
|
-
repeat,
|
|
1031
|
-
...blockWithoutRepeat
|
|
1032
|
-
} = block;
|
|
1033
|
-
if (!repeat?.collection) {
|
|
1034
|
-
return void 0;
|
|
1035
|
-
}
|
|
1036
|
-
const itemsArray = evaluate({
|
|
1037
|
-
code: repeat.collection,
|
|
1038
|
-
localState: context.localState,
|
|
1039
|
-
rootState: context.rootState,
|
|
1040
|
-
rootSetState: context.rootSetState,
|
|
1041
|
-
context: context.context
|
|
1042
|
-
});
|
|
1043
|
-
if (!Array.isArray(itemsArray)) {
|
|
1044
|
-
return void 0;
|
|
1045
|
-
}
|
|
1046
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
1047
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
1048
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
1049
|
-
context: {
|
|
1050
|
-
...context,
|
|
1051
|
-
localState: {
|
|
1052
|
-
...context.localState,
|
|
1053
|
-
$index: index,
|
|
1054
|
-
$item: item,
|
|
1055
|
-
[itemNameToUse]: item,
|
|
1056
|
-
[`$${itemNameToUse}Index`]: index
|
|
1057
|
-
}
|
|
1058
|
-
},
|
|
1059
|
-
block: blockWithoutRepeat
|
|
1060
|
-
}));
|
|
1061
|
-
return repeatArray;
|
|
1062
|
-
};
|
|
1063
|
-
var provideLinkComponent = (block, linkComponent) => {
|
|
1064
|
-
if (block?.shouldReceiveBuilderProps?.builderLinkComponent)
|
|
1065
|
-
return {
|
|
1066
|
-
builderLinkComponent: linkComponent
|
|
1067
|
-
};
|
|
1068
|
-
return {};
|
|
1069
|
-
};
|
|
1070
|
-
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
1071
|
-
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
1072
|
-
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
1073
|
-
return !checkIsComponentRestricted(component, model);
|
|
1074
|
-
}));
|
|
1075
|
-
return {
|
|
1076
|
-
builderComponents: filteredRegisteredComponents
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
return {};
|
|
1080
|
-
};
|
|
1081
|
-
var provideBuilderBlock = (block, builderBlock) => {
|
|
1082
|
-
if (block?.shouldReceiveBuilderProps?.builderBlock)
|
|
1083
|
-
return {
|
|
1084
|
-
builderBlock
|
|
1085
|
-
};
|
|
1086
|
-
return {};
|
|
1087
|
-
};
|
|
1088
|
-
var provideBuilderContext = (block, context) => {
|
|
1089
|
-
if (block?.shouldReceiveBuilderProps?.builderContext)
|
|
1090
|
-
return {
|
|
1091
|
-
builderContext: context
|
|
1092
|
-
};
|
|
1093
|
-
return {};
|
|
1094
|
-
};
|
|
1095
|
-
var generateKey = (index) => {
|
|
1096
|
-
return index.toString();
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
// src/functions/event-handler-name.ts
|
|
1100
|
-
function capitalizeFirstLetter(string) {
|
|
1101
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1102
|
-
}
|
|
1103
|
-
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
1104
|
-
|
|
1105
|
-
// src/functions/get-block-actions-handler.ts
|
|
1106
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
1107
|
-
code: value,
|
|
1108
|
-
context: options.context,
|
|
1109
|
-
localState: options.localState,
|
|
1110
|
-
rootState: options.rootState,
|
|
1111
|
-
rootSetState: options.rootSetState,
|
|
1112
|
-
event,
|
|
1113
|
-
isExpression: false
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
// src/functions/get-block-actions.ts
|
|
1117
|
-
function getBlockActions(options) {
|
|
1118
|
-
const obj = {};
|
|
1119
|
-
const optionActions = options.block.actions ?? {};
|
|
1120
|
-
for (const key in optionActions) {
|
|
1121
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
1122
|
-
continue;
|
|
1123
|
-
}
|
|
1124
|
-
const value = optionActions[key];
|
|
1125
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
1126
|
-
if (options.stripPrefix) {
|
|
1127
|
-
switch (TARGET) {
|
|
1128
|
-
case "vue":
|
|
1129
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
1130
|
-
break;
|
|
1131
|
-
case "svelte":
|
|
1132
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
1133
|
-
break;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
1137
|
-
}
|
|
1138
|
-
return obj;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
// src/functions/transform-block-properties.ts
|
|
1142
|
-
function transformBlockProperties({
|
|
1143
|
-
properties
|
|
1144
|
-
}) {
|
|
1145
|
-
return properties;
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
// src/functions/get-block-properties.ts
|
|
1149
|
-
var extractRelevantRootBlockProperties = (block) => {
|
|
1150
|
-
return {
|
|
1151
|
-
href: block.href
|
|
1152
|
-
};
|
|
1153
|
-
};
|
|
1154
|
-
function getBlockProperties({
|
|
1155
|
-
block,
|
|
1156
|
-
context
|
|
1157
|
-
}) {
|
|
1158
|
-
const properties = {
|
|
1159
|
-
...extractRelevantRootBlockProperties(block),
|
|
1160
|
-
...block.properties,
|
|
1161
|
-
"builder-id": block.id,
|
|
1162
|
-
style: getStyle({
|
|
1163
|
-
block,
|
|
1164
|
-
context
|
|
1165
|
-
}),
|
|
1166
|
-
[getClassPropName()]: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
1167
|
-
};
|
|
1168
|
-
return transformBlockProperties({
|
|
1169
|
-
properties,
|
|
1170
|
-
context,
|
|
1171
|
-
block
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// src/components/block/components/block-wrapper.tsx
|
|
1176
|
-
function BlockWrapper(props) {
|
|
1177
|
-
return <><Dynamic_renderer_default
|
|
1178
|
-
TagName={props.Wrapper}
|
|
1179
|
-
attributes={getBlockProperties({
|
|
1180
|
-
block: props.block,
|
|
1181
|
-
context: props.context
|
|
1182
|
-
})}
|
|
1183
|
-
actionAttributes={getBlockActions({
|
|
1184
|
-
block: props.block,
|
|
1185
|
-
rootState: props.context.rootState,
|
|
1186
|
-
rootSetState: props.context.rootSetState,
|
|
1187
|
-
localState: props.context.localState,
|
|
1188
|
-
context: props.context.context,
|
|
1189
|
-
stripPrefix: true
|
|
1190
|
-
})}
|
|
1191
|
-
>{props.children}</Dynamic_renderer_default></>;
|
|
1192
|
-
}
|
|
1193
|
-
var Block_wrapper_default = BlockWrapper;
|
|
1194
|
-
|
|
1195
|
-
// src/components/block/components/component-ref/component-ref.tsx
|
|
1196
|
-
import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
|
|
1197
|
-
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1198
|
-
|
|
1199
|
-
// src/components/block/components/interactive-element.tsx
|
|
1200
|
-
import { Show as Show2, on, createEffect, createMemo as createMemo2, createSignal as createSignal2 } from "solid-js";
|
|
1201
|
-
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
1202
|
-
|
|
1203
|
-
// src/functions/is-previewing.ts
|
|
1204
|
-
function isPreviewing(search) {
|
|
1205
|
-
const searchToUse = search || (isBrowser() ? window.location.search : void 0);
|
|
1206
|
-
if (!searchToUse) {
|
|
1207
|
-
return false;
|
|
1208
|
-
}
|
|
1209
|
-
const normalizedSearch = getSearchString(searchToUse);
|
|
1210
|
-
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
// src/functions/register-component.ts
|
|
1214
|
-
var createRegisterComponentMessage = (info) => ({
|
|
1215
|
-
type: "builder.registerComponent",
|
|
1216
|
-
data: serializeIncludingFunctions(info)
|
|
1217
|
-
});
|
|
1218
|
-
var serializeFn = (fnValue) => {
|
|
1219
|
-
const fnStr = fnValue.toString().trim();
|
|
1220
|
-
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1221
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
1222
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
1223
|
-
};
|
|
1224
|
-
function serializeIncludingFunctions(info) {
|
|
1225
|
-
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
1226
|
-
if (typeof value === "function") {
|
|
1227
|
-
return serializeFn(value);
|
|
1228
|
-
}
|
|
1229
|
-
return value;
|
|
1230
|
-
}));
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
// src/functions/register.ts
|
|
1234
|
-
var registry = {};
|
|
1235
|
-
function register(type, info) {
|
|
1236
|
-
if (type === "plugin") {
|
|
1237
|
-
info = serializeIncludingFunctions(info);
|
|
1238
|
-
}
|
|
1239
|
-
let typeList = registry[type];
|
|
1240
|
-
if (!typeList) {
|
|
1241
|
-
typeList = registry[type] = [];
|
|
1242
|
-
}
|
|
1243
|
-
typeList.push(info);
|
|
1244
|
-
if (isBrowser()) {
|
|
1245
|
-
const message = {
|
|
1246
|
-
type: "builder.register",
|
|
1247
|
-
data: {
|
|
1248
|
-
type,
|
|
1249
|
-
info
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
try {
|
|
1253
|
-
parent.postMessage(message, "*");
|
|
1254
|
-
if (parent !== window) {
|
|
1255
|
-
window.postMessage(message, "*");
|
|
1256
|
-
}
|
|
1257
|
-
} catch (err) {
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
function registerAction(action) {
|
|
1262
|
-
if (isBrowser()) {
|
|
1263
|
-
const actionClone = JSON.parse(JSON.stringify(action));
|
|
1264
|
-
if (action.action) {
|
|
1265
|
-
actionClone.action = action.action.toString();
|
|
1266
|
-
}
|
|
1267
|
-
window.parent?.postMessage({
|
|
1268
|
-
type: "builder.registerAction",
|
|
1269
|
-
data: actionClone
|
|
1270
|
-
}, "*");
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
// src/functions/set-editor-settings.ts
|
|
1275
|
-
var settings = {};
|
|
1276
|
-
function setEditorSettings(newSettings) {
|
|
1277
|
-
if (isBrowser()) {
|
|
1278
|
-
Object.assign(settings, newSettings);
|
|
1279
|
-
const message = {
|
|
1280
|
-
type: "builder.settingsChange",
|
|
1281
|
-
data: settings
|
|
1282
|
-
};
|
|
1283
|
-
parent.postMessage(message, "*");
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
// src/functions/get-builder-search-params/index.ts
|
|
1288
|
-
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
1289
|
-
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
1290
|
-
var getBuilderSearchParams = (_options) => {
|
|
1291
|
-
if (!_options) {
|
|
1292
|
-
return {};
|
|
1293
|
-
}
|
|
1294
|
-
const options = normalizeSearchParams(_options);
|
|
1295
|
-
const newOptions = {};
|
|
1296
|
-
Object.keys(options).forEach((key) => {
|
|
1297
|
-
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1298
|
-
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1299
|
-
newOptions[trimmedKey] = options[key];
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
return newOptions;
|
|
1303
|
-
};
|
|
1304
|
-
var getBuilderSearchParamsFromWindow = () => {
|
|
1305
|
-
if (!isBrowser()) {
|
|
1306
|
-
return {};
|
|
1307
|
-
}
|
|
1308
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
1309
|
-
return getBuilderSearchParams(searchParams);
|
|
1310
|
-
};
|
|
1311
|
-
|
|
1312
|
-
// src/constants/sdk-version.ts
|
|
1313
|
-
var SDK_VERSION = "5.1.0";
|
|
1314
|
-
|
|
1315
|
-
// src/helpers/sdk-headers.ts
|
|
1316
|
-
var getSdkHeaders = () => ({
|
|
1317
|
-
"X-Builder-SDK": TARGET,
|
|
1318
|
-
"X-Builder-SDK-GEN": "2",
|
|
1319
|
-
"X-Builder-SDK-Version": SDK_VERSION
|
|
1320
|
-
});
|
|
1321
|
-
|
|
1322
|
-
// src/helpers/url.ts
|
|
1323
|
-
var getTopLevelDomain = (host) => {
|
|
1324
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
1325
|
-
return host;
|
|
1326
|
-
}
|
|
1327
|
-
const parts = host.split(".");
|
|
1328
|
-
if (parts.length > 2) {
|
|
1329
|
-
return parts.slice(1).join(".");
|
|
1330
|
-
}
|
|
1331
|
-
return host;
|
|
1332
|
-
};
|
|
1333
|
-
|
|
1334
|
-
// src/helpers/cookie.ts
|
|
1335
|
-
var getCookieSync = ({
|
|
1336
|
-
name,
|
|
1337
|
-
canTrack
|
|
1338
|
-
}) => {
|
|
1339
|
-
try {
|
|
1340
|
-
if (!canTrack) {
|
|
1341
|
-
return void 0;
|
|
1342
|
-
}
|
|
1343
|
-
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1344
|
-
} catch (err) {
|
|
1345
|
-
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1346
|
-
return void 0;
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
var getCookie = async (args) => getCookieSync(args);
|
|
1350
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1351
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1352
|
-
var createCookieString = ({
|
|
1353
|
-
name,
|
|
1354
|
-
value,
|
|
1355
|
-
expires
|
|
1356
|
-
}) => {
|
|
1357
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1358
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1359
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1360
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1361
|
-
const cookie = stringifyCookie(cookieValue);
|
|
1362
|
-
return cookie;
|
|
1363
|
-
};
|
|
1364
|
-
var setCookie = async ({
|
|
1365
|
-
name,
|
|
1366
|
-
value,
|
|
1367
|
-
expires,
|
|
1368
|
-
canTrack
|
|
1369
|
-
}) => {
|
|
1370
|
-
try {
|
|
1371
|
-
if (!canTrack) {
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
const cookie = createCookieString({
|
|
1375
|
-
name,
|
|
1376
|
-
value,
|
|
1377
|
-
expires
|
|
1209
|
+
}
|
|
1210
|
+
attachDefaultState();
|
|
1211
|
+
setTimeout(() => {
|
|
1212
|
+
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
1213
|
+
if (animation.delay) {
|
|
1214
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
1215
|
+
}
|
|
1378
1216
|
});
|
|
1379
|
-
document.
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
// src/helpers/uuid.ts
|
|
1386
|
-
function uuidv4() {
|
|
1387
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
1388
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
1389
|
-
return v.toString(16);
|
|
1217
|
+
document.addEventListener("scroll", onScroll, {
|
|
1218
|
+
capture: true,
|
|
1219
|
+
passive: true
|
|
1220
|
+
});
|
|
1221
|
+
immediateOnScroll();
|
|
1390
1222
|
});
|
|
1391
1223
|
}
|
|
1392
|
-
function uuid() {
|
|
1393
|
-
return uuidv4().replace(/-/g, "");
|
|
1394
|
-
}
|
|
1395
1224
|
|
|
1396
|
-
// src/helpers/
|
|
1397
|
-
var
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
const sessionId = await getCookie({
|
|
1405
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
1406
|
-
canTrack
|
|
1225
|
+
// src/helpers/css.ts
|
|
1226
|
+
var convertStyleMapToCSSArray = (style) => {
|
|
1227
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
1228
|
+
if (typeof value === "string") {
|
|
1229
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
1230
|
+
} else {
|
|
1231
|
+
return void 0;
|
|
1232
|
+
}
|
|
1407
1233
|
});
|
|
1408
|
-
|
|
1409
|
-
|
|
1234
|
+
return cssProps.filter(checkIsDefined);
|
|
1235
|
+
};
|
|
1236
|
+
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
1237
|
+
var createCssClass = ({
|
|
1238
|
+
mediaQuery,
|
|
1239
|
+
className,
|
|
1240
|
+
styles
|
|
1241
|
+
}) => {
|
|
1242
|
+
const cssClass = `.${className} {
|
|
1243
|
+
${convertStyleMapToCSS(styles)}
|
|
1244
|
+
}`;
|
|
1245
|
+
if (mediaQuery) {
|
|
1246
|
+
return `${mediaQuery} {
|
|
1247
|
+
${cssClass}
|
|
1248
|
+
}`;
|
|
1410
1249
|
} else {
|
|
1411
|
-
|
|
1412
|
-
setSessionId({
|
|
1413
|
-
id: newSessionId,
|
|
1414
|
-
canTrack
|
|
1415
|
-
});
|
|
1416
|
-
return newSessionId;
|
|
1250
|
+
return cssClass;
|
|
1417
1251
|
}
|
|
1418
1252
|
};
|
|
1419
|
-
var createSessionId = () => uuid();
|
|
1420
|
-
var setSessionId = ({
|
|
1421
|
-
id,
|
|
1422
|
-
canTrack
|
|
1423
|
-
}) => setCookie({
|
|
1424
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
1425
|
-
value: id,
|
|
1426
|
-
canTrack
|
|
1427
|
-
});
|
|
1428
1253
|
|
|
1429
|
-
// src/
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1254
|
+
// src/functions/transform-style-property.ts
|
|
1255
|
+
function transformStyleProperty({
|
|
1256
|
+
style
|
|
1257
|
+
}) {
|
|
1258
|
+
return style;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// src/functions/get-style.ts
|
|
1262
|
+
var getStyle = ({
|
|
1263
|
+
block,
|
|
1264
|
+
context
|
|
1434
1265
|
}) => {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1266
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
1267
|
+
style: block.style || {},
|
|
1268
|
+
context,
|
|
1269
|
+
block
|
|
1270
|
+
}));
|
|
1271
|
+
};
|
|
1272
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
1273
|
+
switch (TARGET) {
|
|
1274
|
+
case "svelte":
|
|
1275
|
+
case "vue":
|
|
1276
|
+
case "solid":
|
|
1277
|
+
case "angular":
|
|
1278
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
1279
|
+
case "qwik":
|
|
1280
|
+
case "reactNative":
|
|
1281
|
+
case "react":
|
|
1282
|
+
case "rsc":
|
|
1283
|
+
return style;
|
|
1442
1284
|
}
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/components/block/block.helpers.ts
|
|
1288
|
+
var checkIsComponentRestricted = (component, model) => {
|
|
1289
|
+
if (!component)
|
|
1290
|
+
return true;
|
|
1291
|
+
if (!model)
|
|
1292
|
+
return false;
|
|
1293
|
+
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
1443
1294
|
};
|
|
1444
|
-
var
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1295
|
+
var getComponent = ({
|
|
1296
|
+
block,
|
|
1297
|
+
registeredComponents,
|
|
1298
|
+
model
|
|
1448
1299
|
}) => {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1300
|
+
const componentName = block.component?.name;
|
|
1301
|
+
if (!componentName) {
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
const ref = registeredComponents[componentName];
|
|
1305
|
+
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
1306
|
+
return void 0;
|
|
1307
|
+
} else {
|
|
1308
|
+
return ref;
|
|
1454
1309
|
}
|
|
1455
1310
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
var getVisitorId = ({
|
|
1460
|
-
canTrack
|
|
1311
|
+
var getRepeatItemData = ({
|
|
1312
|
+
block,
|
|
1313
|
+
context
|
|
1461
1314
|
}) => {
|
|
1462
|
-
|
|
1315
|
+
const {
|
|
1316
|
+
repeat,
|
|
1317
|
+
...blockWithoutRepeat
|
|
1318
|
+
} = block;
|
|
1319
|
+
if (!repeat?.collection) {
|
|
1463
1320
|
return void 0;
|
|
1464
1321
|
}
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
|
|
1322
|
+
const itemsArray = evaluate({
|
|
1323
|
+
code: repeat.collection,
|
|
1324
|
+
localState: context.localState,
|
|
1325
|
+
rootState: context.rootState,
|
|
1326
|
+
rootSetState: context.rootSetState,
|
|
1327
|
+
context: context.context
|
|
1468
1328
|
});
|
|
1469
|
-
if (
|
|
1470
|
-
return
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1329
|
+
if (!Array.isArray(itemsArray)) {
|
|
1330
|
+
return void 0;
|
|
1331
|
+
}
|
|
1332
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
1333
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
1334
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
1335
|
+
context: {
|
|
1336
|
+
...context,
|
|
1337
|
+
localState: {
|
|
1338
|
+
...context.localState,
|
|
1339
|
+
$index: index,
|
|
1340
|
+
$item: item,
|
|
1341
|
+
[itemNameToUse]: item,
|
|
1342
|
+
[`$${itemNameToUse}Index`]: index
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
block: blockWithoutRepeat
|
|
1346
|
+
}));
|
|
1347
|
+
return repeatArray;
|
|
1348
|
+
};
|
|
1349
|
+
var provideLinkComponent = (block, linkComponent) => {
|
|
1350
|
+
if (block?.shouldReceiveBuilderProps?.builderLinkComponent)
|
|
1351
|
+
return {
|
|
1352
|
+
builderLinkComponent: linkComponent
|
|
1353
|
+
};
|
|
1354
|
+
return {};
|
|
1355
|
+
};
|
|
1356
|
+
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
1357
|
+
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
1358
|
+
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
1359
|
+
return !checkIsComponentRestricted(component, model);
|
|
1360
|
+
}));
|
|
1361
|
+
return {
|
|
1362
|
+
builderComponents: filteredRegisteredComponents
|
|
1363
|
+
};
|
|
1478
1364
|
}
|
|
1365
|
+
return {};
|
|
1479
1366
|
};
|
|
1480
|
-
var
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1367
|
+
var provideBuilderBlock = (block, builderBlock) => {
|
|
1368
|
+
if (block?.shouldReceiveBuilderProps?.builderBlock)
|
|
1369
|
+
return {
|
|
1370
|
+
builderBlock
|
|
1371
|
+
};
|
|
1372
|
+
return {};
|
|
1373
|
+
};
|
|
1374
|
+
var provideBuilderContext = (block, context) => {
|
|
1375
|
+
if (block?.shouldReceiveBuilderProps?.builderContext)
|
|
1376
|
+
return {
|
|
1377
|
+
builderContext: context
|
|
1378
|
+
};
|
|
1379
|
+
return {};
|
|
1380
|
+
};
|
|
1381
|
+
var generateKey = (index) => {
|
|
1382
|
+
return index.toString();
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// src/functions/event-handler-name.ts
|
|
1386
|
+
function capitalizeFirstLetter(string) {
|
|
1387
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1388
|
+
}
|
|
1389
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
1390
|
+
|
|
1391
|
+
// src/functions/get-block-actions-handler.ts
|
|
1392
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
1393
|
+
code: value,
|
|
1394
|
+
context: options.context,
|
|
1395
|
+
localState: options.localState,
|
|
1396
|
+
rootState: options.rootState,
|
|
1397
|
+
rootSetState: options.rootSetState,
|
|
1398
|
+
event,
|
|
1399
|
+
isExpression: false,
|
|
1400
|
+
trackingContext: options.trackingContext
|
|
1488
1401
|
});
|
|
1489
1402
|
|
|
1490
|
-
// src/functions/
|
|
1491
|
-
function
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1403
|
+
// src/functions/get-block-actions.ts
|
|
1404
|
+
function getBlockActions(options) {
|
|
1405
|
+
const obj = {};
|
|
1406
|
+
const optionActions = options.block.actions ?? {};
|
|
1407
|
+
for (const key in optionActions) {
|
|
1408
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
const value = optionActions[key];
|
|
1412
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
1413
|
+
if (options.stripPrefix) {
|
|
1414
|
+
switch (TARGET) {
|
|
1415
|
+
case "vue":
|
|
1416
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
1417
|
+
break;
|
|
1418
|
+
case "svelte":
|
|
1419
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
1420
|
+
break;
|
|
1421
|
+
}
|
|
1495
1422
|
}
|
|
1423
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
1496
1424
|
}
|
|
1425
|
+
return obj;
|
|
1497
1426
|
}
|
|
1498
1427
|
|
|
1499
|
-
// src/functions/
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
})
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
}
|
|
1509
|
-
const sessionId = await getSessionId({
|
|
1510
|
-
canTrack
|
|
1511
|
-
});
|
|
1512
|
-
const visitorId = getVisitorId({
|
|
1513
|
-
canTrack
|
|
1514
|
-
});
|
|
1428
|
+
// src/functions/transform-block-properties.ts
|
|
1429
|
+
function transformBlockProperties({
|
|
1430
|
+
properties
|
|
1431
|
+
}) {
|
|
1432
|
+
return properties;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
// src/functions/get-block-properties.ts
|
|
1436
|
+
var extractRelevantRootBlockProperties = (block) => {
|
|
1515
1437
|
return {
|
|
1516
|
-
|
|
1517
|
-
visitorId
|
|
1438
|
+
href: block.href
|
|
1518
1439
|
};
|
|
1519
1440
|
};
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
url: location.href,
|
|
1532
|
-
...metadata
|
|
1533
|
-
},
|
|
1534
|
-
...await getTrackingEventData({
|
|
1535
|
-
canTrack
|
|
1441
|
+
function getBlockProperties({
|
|
1442
|
+
block,
|
|
1443
|
+
context
|
|
1444
|
+
}) {
|
|
1445
|
+
const properties = {
|
|
1446
|
+
...extractRelevantRootBlockProperties(block),
|
|
1447
|
+
...block.properties,
|
|
1448
|
+
"builder-id": block.id,
|
|
1449
|
+
style: getStyle({
|
|
1450
|
+
block,
|
|
1451
|
+
context
|
|
1536
1452
|
}),
|
|
1537
|
-
|
|
1538
|
-
|
|
1453
|
+
[getClassPropName()]: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
1454
|
+
};
|
|
1455
|
+
return transformBlockProperties({
|
|
1456
|
+
properties,
|
|
1457
|
+
context,
|
|
1458
|
+
block
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// src/components/block/components/block-wrapper.tsx
|
|
1463
|
+
function BlockWrapper(props) {
|
|
1464
|
+
return <><Dynamic_renderer_default
|
|
1465
|
+
TagName={props.Wrapper}
|
|
1466
|
+
attributes={getBlockProperties({
|
|
1467
|
+
block: props.block,
|
|
1468
|
+
context: props.context
|
|
1469
|
+
})}
|
|
1470
|
+
actionAttributes={getBlockActions({
|
|
1471
|
+
block: props.block,
|
|
1472
|
+
rootState: props.context.rootState,
|
|
1473
|
+
rootSetState: props.context.rootSetState,
|
|
1474
|
+
localState: props.context.localState,
|
|
1475
|
+
context: props.context.context,
|
|
1476
|
+
stripPrefix: true,
|
|
1477
|
+
trackingContext: {
|
|
1478
|
+
apiKey: props.context.apiKey,
|
|
1479
|
+
canTrack: props.context.canTrack ?? true,
|
|
1480
|
+
contentId: props.context.content?.id,
|
|
1481
|
+
variationId: props.context.content?.testVariationId
|
|
1482
|
+
}
|
|
1483
|
+
})}
|
|
1484
|
+
>{props.children}</Dynamic_renderer_default></>;
|
|
1485
|
+
}
|
|
1486
|
+
var Block_wrapper_default = BlockWrapper;
|
|
1487
|
+
|
|
1488
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
1489
|
+
import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
|
|
1490
|
+
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1491
|
+
|
|
1492
|
+
// src/components/block/components/interactive-element.tsx
|
|
1493
|
+
import { Show as Show2, on, createEffect, createMemo as createMemo2, createSignal as createSignal2 } from "solid-js";
|
|
1494
|
+
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
1495
|
+
|
|
1496
|
+
// src/functions/is-previewing.ts
|
|
1497
|
+
function isPreviewing(search) {
|
|
1498
|
+
const searchToUse = search || (isBrowser() ? window.location.search : void 0);
|
|
1499
|
+
if (!searchToUse) {
|
|
1500
|
+
return false;
|
|
1539
1501
|
}
|
|
1502
|
+
const normalizedSearch = getSearchString(searchToUse);
|
|
1503
|
+
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// src/functions/register-component.ts
|
|
1507
|
+
var createRegisterComponentMessage = (info) => ({
|
|
1508
|
+
type: "builder.registerComponent",
|
|
1509
|
+
data: serializeIncludingFunctions(info)
|
|
1540
1510
|
});
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1511
|
+
var serializeFn = (fnValue) => {
|
|
1512
|
+
const fnStr = fnValue.toString().trim();
|
|
1513
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1514
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
1515
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
1516
|
+
};
|
|
1517
|
+
function serializeIncludingFunctions(info) {
|
|
1518
|
+
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
1519
|
+
if (typeof value === "function") {
|
|
1520
|
+
return serializeFn(value);
|
|
1521
|
+
}
|
|
1522
|
+
return value;
|
|
1523
|
+
}));
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// src/functions/register.ts
|
|
1527
|
+
var registry = {};
|
|
1528
|
+
function register(type, info) {
|
|
1529
|
+
if (type === "plugin") {
|
|
1530
|
+
info = serializeIncludingFunctions(info);
|
|
1548
1531
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1532
|
+
let typeList = registry[type];
|
|
1533
|
+
if (!typeList) {
|
|
1534
|
+
typeList = registry[type] = [];
|
|
1551
1535
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1536
|
+
typeList.push(info);
|
|
1537
|
+
if (isBrowser()) {
|
|
1538
|
+
const message = {
|
|
1539
|
+
type: "builder.register",
|
|
1540
|
+
data: {
|
|
1541
|
+
type,
|
|
1542
|
+
info
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
try {
|
|
1546
|
+
parent.postMessage(message, "*");
|
|
1547
|
+
if (parent !== window) {
|
|
1548
|
+
window.postMessage(message, "*");
|
|
1549
|
+
}
|
|
1550
|
+
} catch (err) {
|
|
1551
|
+
}
|
|
1554
1552
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1553
|
+
}
|
|
1554
|
+
function registerAction(action) {
|
|
1555
|
+
if (isBrowser()) {
|
|
1556
|
+
const actionClone = JSON.parse(JSON.stringify(action));
|
|
1557
|
+
if (action.action) {
|
|
1558
|
+
actionClone.action = action.action.toString();
|
|
1559
|
+
}
|
|
1560
|
+
window.parent?.postMessage({
|
|
1561
|
+
type: "builder.registerAction",
|
|
1562
|
+
data: actionClone
|
|
1563
|
+
}, "*");
|
|
1557
1564
|
}
|
|
1558
|
-
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
1559
|
-
const url = `${baseUrl}/api/v1/track`;
|
|
1560
|
-
logFetch(url);
|
|
1561
|
-
return fetch(url, {
|
|
1562
|
-
method: "POST",
|
|
1563
|
-
body: JSON.stringify({
|
|
1564
|
-
events: [await createEvent(eventProps)]
|
|
1565
|
-
}),
|
|
1566
|
-
headers: {
|
|
1567
|
-
"content-type": "application/json",
|
|
1568
|
-
...getSdkHeaders()
|
|
1569
|
-
},
|
|
1570
|
-
mode: "cors"
|
|
1571
|
-
}).catch((err) => {
|
|
1572
|
-
});
|
|
1573
1565
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1566
|
+
|
|
1567
|
+
// src/functions/set-editor-settings.ts
|
|
1568
|
+
var settings = {};
|
|
1569
|
+
function setEditorSettings(newSettings) {
|
|
1570
|
+
if (isBrowser()) {
|
|
1571
|
+
Object.assign(settings, newSettings);
|
|
1572
|
+
const message = {
|
|
1573
|
+
type: "builder.settingsChange",
|
|
1574
|
+
data: settings
|
|
1575
|
+
};
|
|
1576
|
+
parent.postMessage(message, "*");
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// src/functions/get-builder-search-params/index.ts
|
|
1581
|
+
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
1582
|
+
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
1583
|
+
var getBuilderSearchParams = (_options) => {
|
|
1584
|
+
if (!_options) {
|
|
1585
|
+
return {};
|
|
1586
|
+
}
|
|
1587
|
+
const options = normalizeSearchParams(_options);
|
|
1588
|
+
const newOptions = {};
|
|
1589
|
+
Object.keys(options).forEach((key) => {
|
|
1590
|
+
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1591
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1592
|
+
newOptions[trimmedKey] = options[key];
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
return newOptions;
|
|
1596
|
+
};
|
|
1597
|
+
var getBuilderSearchParamsFromWindow = () => {
|
|
1598
|
+
if (!isBrowser()) {
|
|
1599
|
+
return {};
|
|
1600
|
+
}
|
|
1601
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1602
|
+
return getBuilderSearchParams(searchParams);
|
|
1603
|
+
};
|
|
1578
1604
|
|
|
1579
1605
|
// src/functions/is-from-trusted-host.ts
|
|
1580
1606
|
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
@@ -2316,7 +2342,13 @@ function InteractiveElement(props) {
|
|
|
2316
2342
|
rootState: props.context.rootState,
|
|
2317
2343
|
rootSetState: props.context.rootSetState,
|
|
2318
2344
|
localState: props.context.localState,
|
|
2319
|
-
context: props.context.context
|
|
2345
|
+
context: props.context.context,
|
|
2346
|
+
trackingContext: {
|
|
2347
|
+
apiKey: props.context.apiKey,
|
|
2348
|
+
canTrack: props.context.canTrack ?? true,
|
|
2349
|
+
contentId: props.context.content?.id,
|
|
2350
|
+
variationId: props.context.content?.testVariationId
|
|
2351
|
+
}
|
|
2320
2352
|
})
|
|
2321
2353
|
} : {};
|
|
2322
2354
|
});
|