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