@builder.io/sdk-solid 5.0.1 → 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 +463 -433
- package/lib/node/dev.jsx +1007 -977
- package/lib/node/index.js +828 -798
- package/lib/node/index.jsx +829 -799
- package/package.json +1 -1
package/lib/browser/index.js
CHANGED
|
@@ -213,145 +213,431 @@ var getUserAttributes = () => {
|
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
// src/
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
// src/constants/sdk-version.ts
|
|
217
|
+
var SDK_VERSION = "5.1.1";
|
|
218
|
+
|
|
219
|
+
// src/helpers/sdk-headers.ts
|
|
220
|
+
var getSdkHeaders = () => ({
|
|
221
|
+
"X-Builder-SDK": TARGET,
|
|
222
|
+
"X-Builder-SDK-GEN": "2",
|
|
223
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// src/helpers/nullable.ts
|
|
227
|
+
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
228
|
+
|
|
229
|
+
// src/helpers/url.ts
|
|
230
|
+
var getTopLevelDomain = (host) => {
|
|
231
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
232
|
+
return host;
|
|
233
|
+
}
|
|
234
|
+
const parts = host.split(".");
|
|
235
|
+
if (parts.length > 2) {
|
|
236
|
+
return parts.slice(1).join(".");
|
|
237
|
+
}
|
|
238
|
+
return host;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// src/helpers/cookie.ts
|
|
242
|
+
var getCookieSync = ({
|
|
243
|
+
name,
|
|
244
|
+
canTrack
|
|
222
245
|
}) => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
246
|
+
try {
|
|
247
|
+
if (!canTrack) {
|
|
248
|
+
return void 0;
|
|
249
|
+
}
|
|
250
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
251
|
+
} catch (err) {
|
|
252
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
231
255
|
};
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
isExpression = true
|
|
256
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
257
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
258
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
259
|
+
var createCookieString = ({
|
|
260
|
+
name,
|
|
261
|
+
value,
|
|
262
|
+
expires
|
|
240
263
|
}) => {
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
);
|
|
245
|
-
const
|
|
246
|
-
return
|
|
264
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
265
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
266
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
267
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
268
|
+
const cookie = stringifyCookie(cookieValue);
|
|
269
|
+
return cookie;
|
|
247
270
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
const val = target[prop];
|
|
259
|
-
if (typeof val === "object" && val !== null) {
|
|
260
|
-
return flattenState({
|
|
261
|
-
rootState: val,
|
|
262
|
-
localState: void 0,
|
|
263
|
-
rootSetState: rootSetState ? (subState) => {
|
|
264
|
-
target[prop] = subState;
|
|
265
|
-
rootSetState(target);
|
|
266
|
-
} : void 0
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return val;
|
|
270
|
-
},
|
|
271
|
-
set: (target, prop, value) => {
|
|
272
|
-
if (localState && prop in localState) {
|
|
273
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
274
|
-
}
|
|
275
|
-
target[prop] = value;
|
|
276
|
-
rootSetState?.(target);
|
|
277
|
-
return true;
|
|
271
|
+
var setCookie = async ({
|
|
272
|
+
name,
|
|
273
|
+
value,
|
|
274
|
+
expires,
|
|
275
|
+
canTrack
|
|
276
|
+
}) => {
|
|
277
|
+
try {
|
|
278
|
+
if (!canTrack) {
|
|
279
|
+
return;
|
|
278
280
|
}
|
|
281
|
+
const cookie = createCookieString({
|
|
282
|
+
name,
|
|
283
|
+
value,
|
|
284
|
+
expires
|
|
285
|
+
});
|
|
286
|
+
document.cookie = cookie;
|
|
287
|
+
} catch (err) {
|
|
288
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// src/helpers/uuid.ts
|
|
293
|
+
function uuidv4() {
|
|
294
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
295
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
296
|
+
return v.toString(16);
|
|
279
297
|
});
|
|
280
298
|
}
|
|
299
|
+
function uuid() {
|
|
300
|
+
return uuidv4().replace(/-/g, "");
|
|
301
|
+
}
|
|
281
302
|
|
|
282
|
-
// src/
|
|
283
|
-
var
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
context,
|
|
287
|
-
event,
|
|
288
|
-
localState,
|
|
289
|
-
rootSetState,
|
|
290
|
-
rootState
|
|
303
|
+
// src/helpers/sessionId.ts
|
|
304
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
305
|
+
var getSessionId = async ({
|
|
306
|
+
canTrack
|
|
291
307
|
}) => {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
localState,
|
|
299
|
-
rootSetState
|
|
300
|
-
})
|
|
308
|
+
if (!canTrack) {
|
|
309
|
+
return void 0;
|
|
310
|
+
}
|
|
311
|
+
const sessionId = await getCookie({
|
|
312
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
313
|
+
canTrack
|
|
301
314
|
});
|
|
302
|
-
|
|
315
|
+
if (checkIsDefined(sessionId)) {
|
|
316
|
+
return sessionId;
|
|
317
|
+
} else {
|
|
318
|
+
const newSessionId = createSessionId();
|
|
319
|
+
setSessionId({
|
|
320
|
+
id: newSessionId,
|
|
321
|
+
canTrack
|
|
322
|
+
});
|
|
323
|
+
return newSessionId;
|
|
324
|
+
}
|
|
303
325
|
};
|
|
326
|
+
var createSessionId = () => uuid();
|
|
327
|
+
var setSessionId = ({
|
|
328
|
+
id,
|
|
329
|
+
canTrack
|
|
330
|
+
}) => setCookie({
|
|
331
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
332
|
+
value: id,
|
|
333
|
+
canTrack
|
|
334
|
+
});
|
|
304
335
|
|
|
305
|
-
// src/helpers/
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return typeof process !== "undefined" && checkIsDefined(process?.versions?.node);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// src/functions/evaluate/should-force-browser-runtime-in-node.ts
|
|
314
|
-
var shouldForceBrowserRuntimeInNode = ({
|
|
315
|
-
shouldLogWarning
|
|
336
|
+
// src/helpers/localStorage.ts
|
|
337
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
338
|
+
var getLocalStorageItem = ({
|
|
339
|
+
key,
|
|
340
|
+
canTrack
|
|
316
341
|
}) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const isNode20 = process.version.startsWith("v20");
|
|
321
|
-
const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
|
|
322
|
-
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
323
|
-
if (shouldLogWarning) {
|
|
324
|
-
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
325
|
-
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
326
|
-
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
327
|
-
`);
|
|
342
|
+
try {
|
|
343
|
+
if (canTrack) {
|
|
344
|
+
return getLocalStorage()?.getItem(key);
|
|
328
345
|
}
|
|
329
|
-
return
|
|
346
|
+
return void 0;
|
|
347
|
+
} catch (err) {
|
|
348
|
+
return void 0;
|
|
330
349
|
}
|
|
331
|
-
return false;
|
|
332
350
|
};
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
351
|
+
var setLocalStorageItem = ({
|
|
352
|
+
key,
|
|
353
|
+
canTrack,
|
|
354
|
+
value
|
|
355
|
+
}) => {
|
|
356
|
+
try {
|
|
357
|
+
if (canTrack) {
|
|
358
|
+
getLocalStorage()?.setItem(key, value);
|
|
359
|
+
}
|
|
360
|
+
} catch (err) {
|
|
361
|
+
}
|
|
344
362
|
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
363
|
+
|
|
364
|
+
// src/helpers/visitorId.ts
|
|
365
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
366
|
+
var getVisitorId = ({
|
|
367
|
+
canTrack
|
|
368
|
+
}) => {
|
|
369
|
+
if (!canTrack) {
|
|
370
|
+
return void 0;
|
|
371
|
+
}
|
|
372
|
+
const visitorId = getLocalStorageItem({
|
|
373
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
374
|
+
canTrack
|
|
375
|
+
});
|
|
376
|
+
if (checkIsDefined(visitorId)) {
|
|
377
|
+
return visitorId;
|
|
378
|
+
} else {
|
|
379
|
+
const newVisitorId = createVisitorId();
|
|
380
|
+
setVisitorId({
|
|
381
|
+
id: newVisitorId,
|
|
382
|
+
canTrack
|
|
383
|
+
});
|
|
384
|
+
return newVisitorId;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var createVisitorId = () => uuid();
|
|
388
|
+
var setVisitorId = ({
|
|
389
|
+
id,
|
|
390
|
+
canTrack
|
|
391
|
+
}) => setLocalStorageItem({
|
|
392
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
393
|
+
value: id,
|
|
394
|
+
canTrack
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// src/functions/log-fetch.ts
|
|
398
|
+
function logFetch(url) {
|
|
399
|
+
if (typeof process !== "undefined" && process.env?.DEBUG) {
|
|
400
|
+
if (String(process.env.DEBUG) == "true") {
|
|
401
|
+
logger.log(url);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/functions/track/index.ts
|
|
407
|
+
var getTrackingEventData = async ({
|
|
408
|
+
canTrack
|
|
409
|
+
}) => {
|
|
410
|
+
if (!canTrack) {
|
|
411
|
+
return {
|
|
412
|
+
visitorId: void 0,
|
|
413
|
+
sessionId: void 0
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const sessionId = await getSessionId({
|
|
417
|
+
canTrack
|
|
418
|
+
});
|
|
419
|
+
const visitorId = getVisitorId({
|
|
420
|
+
canTrack
|
|
421
|
+
});
|
|
422
|
+
return {
|
|
423
|
+
sessionId,
|
|
424
|
+
visitorId
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
var createEvent = async ({
|
|
428
|
+
type: eventType,
|
|
429
|
+
canTrack,
|
|
430
|
+
apiKey,
|
|
431
|
+
metadata,
|
|
432
|
+
...properties
|
|
433
|
+
}) => ({
|
|
434
|
+
type: eventType,
|
|
435
|
+
data: {
|
|
436
|
+
...properties,
|
|
437
|
+
metadata: {
|
|
438
|
+
url: location.href,
|
|
439
|
+
...metadata
|
|
440
|
+
},
|
|
441
|
+
...await getTrackingEventData({
|
|
442
|
+
canTrack
|
|
443
|
+
}),
|
|
444
|
+
userAttributes: getUserAttributes(),
|
|
445
|
+
ownerId: apiKey
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
async function _track({
|
|
449
|
+
apiHost,
|
|
450
|
+
...eventProps
|
|
451
|
+
}) {
|
|
452
|
+
if (!eventProps.apiKey) {
|
|
453
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (!eventProps.canTrack) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (isEditing()) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
466
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
467
|
+
logFetch(url);
|
|
468
|
+
return fetch(url, {
|
|
469
|
+
method: "POST",
|
|
470
|
+
body: JSON.stringify({
|
|
471
|
+
events: [await createEvent(eventProps)]
|
|
472
|
+
}),
|
|
473
|
+
headers: {
|
|
474
|
+
"content-type": "application/json",
|
|
475
|
+
...getSdkHeaders()
|
|
476
|
+
},
|
|
477
|
+
mode: "cors"
|
|
478
|
+
}).catch((err) => {
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
var track = (args) => _track({
|
|
482
|
+
...args,
|
|
483
|
+
canTrack: true
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// src/functions/evaluate/helpers.ts
|
|
487
|
+
var getFunctionArguments = ({
|
|
488
|
+
builder,
|
|
489
|
+
context,
|
|
490
|
+
event,
|
|
491
|
+
state
|
|
492
|
+
}) => {
|
|
493
|
+
return Object.entries({
|
|
494
|
+
state,
|
|
495
|
+
Builder: builder,
|
|
496
|
+
// legacy
|
|
497
|
+
builder,
|
|
498
|
+
context,
|
|
499
|
+
event
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
var getBuilderGlobals = (trackingContext) => ({
|
|
503
|
+
isEditing: isEditing(),
|
|
504
|
+
isBrowser: isBrowser(),
|
|
505
|
+
isServer: !isBrowser(),
|
|
506
|
+
getUserAttributes: () => getUserAttributes(),
|
|
507
|
+
trackConversion: (amount, customProperties) => {
|
|
508
|
+
if (!trackingContext?.apiKey || trackingContext?.canTrack === false) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
_track({
|
|
512
|
+
type: "conversion",
|
|
513
|
+
apiKey: trackingContext.apiKey,
|
|
514
|
+
canTrack: trackingContext.canTrack ?? true,
|
|
515
|
+
contentId: trackingContext.contentId,
|
|
516
|
+
variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
|
|
517
|
+
metadata: {
|
|
518
|
+
...customProperties || {},
|
|
519
|
+
...amount !== void 0 ? {
|
|
520
|
+
amount
|
|
521
|
+
} : {}
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
var parseCode = (code, {
|
|
527
|
+
isExpression = true
|
|
528
|
+
}) => {
|
|
529
|
+
const useReturn = (
|
|
530
|
+
// we disable this for cases where we definitely don't want a return
|
|
531
|
+
isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
|
|
532
|
+
);
|
|
533
|
+
const useCode = useReturn ? `return (${code});` : code;
|
|
534
|
+
return useCode;
|
|
535
|
+
};
|
|
536
|
+
function flattenState({
|
|
537
|
+
rootState,
|
|
538
|
+
localState,
|
|
539
|
+
rootSetState
|
|
540
|
+
}) {
|
|
541
|
+
return new Proxy(rootState, {
|
|
542
|
+
get: (target, prop) => {
|
|
543
|
+
if (localState && prop in localState) {
|
|
544
|
+
return localState[prop];
|
|
545
|
+
}
|
|
546
|
+
const val = target[prop];
|
|
547
|
+
if (typeof val === "object" && val !== null) {
|
|
548
|
+
return flattenState({
|
|
549
|
+
rootState: val,
|
|
550
|
+
localState: void 0,
|
|
551
|
+
rootSetState: rootSetState ? (subState) => {
|
|
552
|
+
target[prop] = subState;
|
|
553
|
+
rootSetState(target);
|
|
554
|
+
} : void 0
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
return val;
|
|
558
|
+
},
|
|
559
|
+
set: (target, prop, value) => {
|
|
560
|
+
if (localState && prop in localState) {
|
|
561
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
562
|
+
}
|
|
563
|
+
target[prop] = value;
|
|
564
|
+
rootSetState?.(target);
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
571
|
+
var runInBrowser = ({
|
|
572
|
+
code,
|
|
573
|
+
builder,
|
|
574
|
+
context,
|
|
575
|
+
event,
|
|
576
|
+
localState,
|
|
577
|
+
rootSetState,
|
|
578
|
+
rootState
|
|
579
|
+
}) => {
|
|
580
|
+
const functionArgs = getFunctionArguments({
|
|
581
|
+
builder,
|
|
582
|
+
context,
|
|
583
|
+
event,
|
|
584
|
+
state: flattenState({
|
|
585
|
+
rootState,
|
|
586
|
+
localState,
|
|
587
|
+
rootSetState
|
|
588
|
+
})
|
|
589
|
+
});
|
|
590
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// src/functions/is-node-runtime.ts
|
|
594
|
+
function isNodeRuntime() {
|
|
595
|
+
return typeof process !== "undefined" && checkIsDefined(process?.versions?.node);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/functions/evaluate/should-force-browser-runtime-in-node.ts
|
|
599
|
+
var shouldForceBrowserRuntimeInNode = ({
|
|
600
|
+
shouldLogWarning
|
|
601
|
+
}) => {
|
|
602
|
+
if (!isNodeRuntime())
|
|
603
|
+
return false;
|
|
604
|
+
const isArm64 = process.arch === "arm64";
|
|
605
|
+
const isNode20 = process.version.startsWith("v20");
|
|
606
|
+
const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
|
|
607
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
608
|
+
if (shouldLogWarning) {
|
|
609
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
610
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
611
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
612
|
+
`);
|
|
613
|
+
}
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
return false;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/functions/evaluate/choose-eval.ts
|
|
620
|
+
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode({
|
|
621
|
+
shouldLogWarning: true
|
|
622
|
+
}) ? runInBrowser(args) : runInBrowser(args);
|
|
623
|
+
|
|
624
|
+
// src/functions/evaluate/evaluate.ts
|
|
625
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
626
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
627
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
628
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
629
|
+
};
|
|
630
|
+
function evaluate({
|
|
631
|
+
code,
|
|
632
|
+
context,
|
|
633
|
+
localState,
|
|
634
|
+
rootState,
|
|
635
|
+
rootSetState,
|
|
636
|
+
event,
|
|
637
|
+
isExpression = true,
|
|
638
|
+
trackingContext
|
|
639
|
+
}) {
|
|
640
|
+
if (code.trim() === "") {
|
|
355
641
|
return void 0;
|
|
356
642
|
}
|
|
357
643
|
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
@@ -365,7 +651,7 @@ function evaluate({
|
|
|
365
651
|
code: parseCode(code, {
|
|
366
652
|
isExpression
|
|
367
653
|
}),
|
|
368
|
-
builder: getBuilderGlobals(),
|
|
654
|
+
builder: getBuilderGlobals(trackingContext),
|
|
369
655
|
context,
|
|
370
656
|
event,
|
|
371
657
|
rootSetState,
|
|
@@ -758,660 +1044,400 @@ function bindScrollInViewAnimation(animation) {
|
|
|
758
1044
|
assign(element.style, defaultState);
|
|
759
1045
|
}
|
|
760
1046
|
attachDefaultState();
|
|
761
|
-
setTimeout(() => {
|
|
762
|
-
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
763
|
-
if (animation.delay) {
|
|
764
|
-
element.style.transitionDelay = animation.delay + "s";
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
document.addEventListener("scroll", onScroll, {
|
|
768
|
-
capture: true,
|
|
769
|
-
passive: true
|
|
770
|
-
});
|
|
771
|
-
immediateOnScroll();
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
// src/helpers/css.ts
|
|
776
|
-
var convertStyleMapToCSSArray = (style) => {
|
|
777
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
778
|
-
if (typeof value === "string") {
|
|
779
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
780
|
-
} else {
|
|
781
|
-
return void 0;
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
return cssProps.filter(checkIsDefined);
|
|
785
|
-
};
|
|
786
|
-
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
787
|
-
var createCssClass = ({
|
|
788
|
-
mediaQuery,
|
|
789
|
-
className,
|
|
790
|
-
styles
|
|
791
|
-
}) => {
|
|
792
|
-
const cssClass = `.${className} {
|
|
793
|
-
${convertStyleMapToCSS(styles)}
|
|
794
|
-
}`;
|
|
795
|
-
if (mediaQuery) {
|
|
796
|
-
return `${mediaQuery} {
|
|
797
|
-
${cssClass}
|
|
798
|
-
}`;
|
|
799
|
-
} else {
|
|
800
|
-
return cssClass;
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
|
|
804
|
-
// src/functions/transform-style-property.ts
|
|
805
|
-
function transformStyleProperty({
|
|
806
|
-
style
|
|
807
|
-
}) {
|
|
808
|
-
return style;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
// src/functions/get-style.ts
|
|
812
|
-
var getStyle = ({
|
|
813
|
-
block,
|
|
814
|
-
context
|
|
815
|
-
}) => {
|
|
816
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
817
|
-
style: block.style || {},
|
|
818
|
-
context,
|
|
819
|
-
block
|
|
820
|
-
}));
|
|
821
|
-
};
|
|
822
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
823
|
-
switch (TARGET) {
|
|
824
|
-
case "svelte":
|
|
825
|
-
case "vue":
|
|
826
|
-
case "solid":
|
|
827
|
-
case "angular":
|
|
828
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
829
|
-
case "qwik":
|
|
830
|
-
case "reactNative":
|
|
831
|
-
case "react":
|
|
832
|
-
case "rsc":
|
|
833
|
-
return style;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// src/components/block/block.helpers.ts
|
|
838
|
-
var checkIsComponentRestricted = (component, model) => {
|
|
839
|
-
if (!component)
|
|
840
|
-
return true;
|
|
841
|
-
if (!model)
|
|
842
|
-
return false;
|
|
843
|
-
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
844
|
-
};
|
|
845
|
-
var getComponent = ({
|
|
846
|
-
block,
|
|
847
|
-
registeredComponents,
|
|
848
|
-
model
|
|
849
|
-
}) => {
|
|
850
|
-
const componentName = block.component?.name;
|
|
851
|
-
if (!componentName) {
|
|
852
|
-
return null;
|
|
853
|
-
}
|
|
854
|
-
const ref = registeredComponents[componentName];
|
|
855
|
-
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
856
|
-
return void 0;
|
|
857
|
-
} else {
|
|
858
|
-
return ref;
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
var getRepeatItemData = ({
|
|
862
|
-
block,
|
|
863
|
-
context
|
|
864
|
-
}) => {
|
|
865
|
-
const {
|
|
866
|
-
repeat,
|
|
867
|
-
...blockWithoutRepeat
|
|
868
|
-
} = block;
|
|
869
|
-
if (!repeat?.collection) {
|
|
870
|
-
return void 0;
|
|
871
|
-
}
|
|
872
|
-
const itemsArray = evaluate({
|
|
873
|
-
code: repeat.collection,
|
|
874
|
-
localState: context.localState,
|
|
875
|
-
rootState: context.rootState,
|
|
876
|
-
rootSetState: context.rootSetState,
|
|
877
|
-
context: context.context
|
|
878
|
-
});
|
|
879
|
-
if (!Array.isArray(itemsArray)) {
|
|
880
|
-
return void 0;
|
|
881
|
-
}
|
|
882
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
883
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
884
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
885
|
-
context: {
|
|
886
|
-
...context,
|
|
887
|
-
localState: {
|
|
888
|
-
...context.localState,
|
|
889
|
-
$index: index,
|
|
890
|
-
$item: item,
|
|
891
|
-
[itemNameToUse]: item,
|
|
892
|
-
[`$${itemNameToUse}Index`]: index
|
|
893
|
-
}
|
|
894
|
-
},
|
|
895
|
-
block: blockWithoutRepeat
|
|
896
|
-
}));
|
|
897
|
-
return repeatArray;
|
|
898
|
-
};
|
|
899
|
-
var provideLinkComponent = (block, linkComponent) => {
|
|
900
|
-
if (block?.shouldReceiveBuilderProps?.builderLinkComponent)
|
|
901
|
-
return {
|
|
902
|
-
builderLinkComponent: linkComponent
|
|
903
|
-
};
|
|
904
|
-
return {};
|
|
905
|
-
};
|
|
906
|
-
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
907
|
-
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
908
|
-
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
909
|
-
return !checkIsComponentRestricted(component, model);
|
|
910
|
-
}));
|
|
911
|
-
return {
|
|
912
|
-
builderComponents: filteredRegisteredComponents
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
return {};
|
|
916
|
-
};
|
|
917
|
-
var provideBuilderBlock = (block, builderBlock) => {
|
|
918
|
-
if (block?.shouldReceiveBuilderProps?.builderBlock)
|
|
919
|
-
return {
|
|
920
|
-
builderBlock
|
|
921
|
-
};
|
|
922
|
-
return {};
|
|
923
|
-
};
|
|
924
|
-
var provideBuilderContext = (block, context) => {
|
|
925
|
-
if (block?.shouldReceiveBuilderProps?.builderContext)
|
|
926
|
-
return {
|
|
927
|
-
builderContext: context
|
|
928
|
-
};
|
|
929
|
-
return {};
|
|
930
|
-
};
|
|
931
|
-
var generateKey = (index) => {
|
|
932
|
-
return index.toString();
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
// src/functions/event-handler-name.ts
|
|
936
|
-
function capitalizeFirstLetter(string) {
|
|
937
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
938
|
-
}
|
|
939
|
-
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
940
|
-
|
|
941
|
-
// src/functions/get-block-actions-handler.ts
|
|
942
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
943
|
-
code: value,
|
|
944
|
-
context: options.context,
|
|
945
|
-
localState: options.localState,
|
|
946
|
-
rootState: options.rootState,
|
|
947
|
-
rootSetState: options.rootSetState,
|
|
948
|
-
event,
|
|
949
|
-
isExpression: false
|
|
950
|
-
});
|
|
951
|
-
|
|
952
|
-
// src/functions/get-block-actions.ts
|
|
953
|
-
function getBlockActions(options) {
|
|
954
|
-
const obj = {};
|
|
955
|
-
const optionActions = options.block.actions ?? {};
|
|
956
|
-
for (const key in optionActions) {
|
|
957
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
958
|
-
continue;
|
|
959
|
-
}
|
|
960
|
-
const value = optionActions[key];
|
|
961
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
962
|
-
if (options.stripPrefix) {
|
|
963
|
-
switch (TARGET) {
|
|
964
|
-
case "vue":
|
|
965
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
966
|
-
break;
|
|
967
|
-
case "svelte":
|
|
968
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
973
|
-
}
|
|
974
|
-
return obj;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
// src/functions/transform-block-properties.ts
|
|
978
|
-
function transformBlockProperties({
|
|
979
|
-
properties
|
|
980
|
-
}) {
|
|
981
|
-
return properties;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
// src/functions/get-block-properties.ts
|
|
985
|
-
var extractRelevantRootBlockProperties = (block) => {
|
|
986
|
-
return {
|
|
987
|
-
href: block.href
|
|
988
|
-
};
|
|
989
|
-
};
|
|
990
|
-
function getBlockProperties({
|
|
991
|
-
block,
|
|
992
|
-
context
|
|
993
|
-
}) {
|
|
994
|
-
const properties = {
|
|
995
|
-
...extractRelevantRootBlockProperties(block),
|
|
996
|
-
...block.properties,
|
|
997
|
-
"builder-id": block.id,
|
|
998
|
-
style: getStyle({
|
|
999
|
-
block,
|
|
1000
|
-
context
|
|
1001
|
-
}),
|
|
1002
|
-
[getClassPropName()]: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
1003
|
-
};
|
|
1004
|
-
return transformBlockProperties({
|
|
1005
|
-
properties,
|
|
1006
|
-
context,
|
|
1007
|
-
block
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// src/components/block/components/block-wrapper.tsx
|
|
1012
|
-
function BlockWrapper(props) {
|
|
1013
|
-
return createComponent(dynamic_renderer_default, {
|
|
1014
|
-
get TagName() {
|
|
1015
|
-
return props.Wrapper;
|
|
1016
|
-
},
|
|
1017
|
-
get attributes() {
|
|
1018
|
-
return getBlockProperties({
|
|
1019
|
-
block: props.block,
|
|
1020
|
-
context: props.context
|
|
1021
|
-
});
|
|
1022
|
-
},
|
|
1023
|
-
get actionAttributes() {
|
|
1024
|
-
return getBlockActions({
|
|
1025
|
-
block: props.block,
|
|
1026
|
-
rootState: props.context.rootState,
|
|
1027
|
-
rootSetState: props.context.rootSetState,
|
|
1028
|
-
localState: props.context.localState,
|
|
1029
|
-
context: props.context.context,
|
|
1030
|
-
stripPrefix: true
|
|
1031
|
-
});
|
|
1032
|
-
},
|
|
1033
|
-
get children() {
|
|
1034
|
-
return props.children;
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
var block_wrapper_default = BlockWrapper;
|
|
1039
|
-
|
|
1040
|
-
// src/functions/is-previewing.ts
|
|
1041
|
-
function isPreviewing(search) {
|
|
1042
|
-
const searchToUse = search || (isBrowser() ? window.location.search : void 0);
|
|
1043
|
-
if (!searchToUse) {
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
const normalizedSearch = getSearchString(searchToUse);
|
|
1047
|
-
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
// src/functions/register-component.ts
|
|
1051
|
-
var createRegisterComponentMessage = (info) => ({
|
|
1052
|
-
type: "builder.registerComponent",
|
|
1053
|
-
data: serializeIncludingFunctions(info)
|
|
1054
|
-
});
|
|
1055
|
-
var serializeFn = (fnValue) => {
|
|
1056
|
-
const fnStr = fnValue.toString().trim();
|
|
1057
|
-
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1058
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
1059
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
1060
|
-
};
|
|
1061
|
-
function serializeIncludingFunctions(info) {
|
|
1062
|
-
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
1063
|
-
if (typeof value === "function") {
|
|
1064
|
-
return serializeFn(value);
|
|
1065
|
-
}
|
|
1066
|
-
return value;
|
|
1067
|
-
}));
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
// src/functions/register.ts
|
|
1071
|
-
var registry = {};
|
|
1072
|
-
function register(type, info) {
|
|
1073
|
-
if (type === "plugin") {
|
|
1074
|
-
info = serializeIncludingFunctions(info);
|
|
1075
|
-
}
|
|
1076
|
-
let typeList = registry[type];
|
|
1077
|
-
if (!typeList) {
|
|
1078
|
-
typeList = registry[type] = [];
|
|
1079
|
-
}
|
|
1080
|
-
typeList.push(info);
|
|
1081
|
-
if (isBrowser()) {
|
|
1082
|
-
const message = {
|
|
1083
|
-
type: "builder.register",
|
|
1084
|
-
data: {
|
|
1085
|
-
type,
|
|
1086
|
-
info
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
try {
|
|
1090
|
-
parent.postMessage(message, "*");
|
|
1091
|
-
if (parent !== window) {
|
|
1092
|
-
window.postMessage(message, "*");
|
|
1093
|
-
}
|
|
1094
|
-
} catch (err) {
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
function registerAction(action) {
|
|
1099
|
-
if (isBrowser()) {
|
|
1100
|
-
const actionClone = JSON.parse(JSON.stringify(action));
|
|
1101
|
-
if (action.action) {
|
|
1102
|
-
actionClone.action = action.action.toString();
|
|
1103
|
-
}
|
|
1104
|
-
window.parent?.postMessage({
|
|
1105
|
-
type: "builder.registerAction",
|
|
1106
|
-
data: actionClone
|
|
1107
|
-
}, "*");
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
// src/functions/set-editor-settings.ts
|
|
1112
|
-
var settings = {};
|
|
1113
|
-
function setEditorSettings(newSettings) {
|
|
1114
|
-
if (isBrowser()) {
|
|
1115
|
-
Object.assign(settings, newSettings);
|
|
1116
|
-
const message = {
|
|
1117
|
-
type: "builder.settingsChange",
|
|
1118
|
-
data: settings
|
|
1119
|
-
};
|
|
1120
|
-
parent.postMessage(message, "*");
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
// src/functions/get-builder-search-params/index.ts
|
|
1125
|
-
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
1126
|
-
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
1127
|
-
var getBuilderSearchParams = (_options) => {
|
|
1128
|
-
if (!_options) {
|
|
1129
|
-
return {};
|
|
1130
|
-
}
|
|
1131
|
-
const options = normalizeSearchParams(_options);
|
|
1132
|
-
const newOptions = {};
|
|
1133
|
-
Object.keys(options).forEach((key) => {
|
|
1134
|
-
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1135
|
-
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1136
|
-
newOptions[trimmedKey] = options[key];
|
|
1137
|
-
}
|
|
1138
|
-
});
|
|
1139
|
-
return newOptions;
|
|
1140
|
-
};
|
|
1141
|
-
var getBuilderSearchParamsFromWindow = () => {
|
|
1142
|
-
if (!isBrowser()) {
|
|
1143
|
-
return {};
|
|
1144
|
-
}
|
|
1145
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
1146
|
-
return getBuilderSearchParams(searchParams);
|
|
1147
|
-
};
|
|
1148
|
-
|
|
1149
|
-
// src/constants/sdk-version.ts
|
|
1150
|
-
var SDK_VERSION = "5.0.1";
|
|
1151
|
-
|
|
1152
|
-
// src/helpers/sdk-headers.ts
|
|
1153
|
-
var getSdkHeaders = () => ({
|
|
1154
|
-
"X-Builder-SDK": TARGET,
|
|
1155
|
-
"X-Builder-SDK-GEN": "2",
|
|
1156
|
-
"X-Builder-SDK-Version": SDK_VERSION
|
|
1157
|
-
});
|
|
1158
|
-
|
|
1159
|
-
// src/helpers/url.ts
|
|
1160
|
-
var getTopLevelDomain = (host) => {
|
|
1161
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
1162
|
-
return host;
|
|
1163
|
-
}
|
|
1164
|
-
const parts = host.split(".");
|
|
1165
|
-
if (parts.length > 2) {
|
|
1166
|
-
return parts.slice(1).join(".");
|
|
1167
|
-
}
|
|
1168
|
-
return host;
|
|
1169
|
-
};
|
|
1170
|
-
|
|
1171
|
-
// src/helpers/cookie.ts
|
|
1172
|
-
var getCookieSync = ({
|
|
1173
|
-
name,
|
|
1174
|
-
canTrack
|
|
1175
|
-
}) => {
|
|
1176
|
-
try {
|
|
1177
|
-
if (!canTrack) {
|
|
1178
|
-
return void 0;
|
|
1179
|
-
}
|
|
1180
|
-
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1181
|
-
} catch (err) {
|
|
1182
|
-
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1183
|
-
return void 0;
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
var getCookie = async (args) => getCookieSync(args);
|
|
1187
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1188
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1189
|
-
var createCookieString = ({
|
|
1190
|
-
name,
|
|
1191
|
-
value,
|
|
1192
|
-
expires
|
|
1193
|
-
}) => {
|
|
1194
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1195
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1196
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1197
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1198
|
-
const cookie = stringifyCookie(cookieValue);
|
|
1199
|
-
return cookie;
|
|
1200
|
-
};
|
|
1201
|
-
var setCookie = async ({
|
|
1202
|
-
name,
|
|
1203
|
-
value,
|
|
1204
|
-
expires,
|
|
1205
|
-
canTrack
|
|
1206
|
-
}) => {
|
|
1207
|
-
try {
|
|
1208
|
-
if (!canTrack) {
|
|
1209
|
-
return;
|
|
1210
|
-
}
|
|
1211
|
-
const cookie = createCookieString({
|
|
1212
|
-
name,
|
|
1213
|
-
value,
|
|
1214
|
-
expires
|
|
1047
|
+
setTimeout(() => {
|
|
1048
|
+
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
1049
|
+
if (animation.delay) {
|
|
1050
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
1051
|
+
}
|
|
1215
1052
|
});
|
|
1216
|
-
document.
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
// src/helpers/uuid.ts
|
|
1223
|
-
function uuidv4() {
|
|
1224
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
1225
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
1226
|
-
return v.toString(16);
|
|
1053
|
+
document.addEventListener("scroll", onScroll, {
|
|
1054
|
+
capture: true,
|
|
1055
|
+
passive: true
|
|
1056
|
+
});
|
|
1057
|
+
immediateOnScroll();
|
|
1227
1058
|
});
|
|
1228
1059
|
}
|
|
1229
|
-
function uuid() {
|
|
1230
|
-
return uuidv4().replace(/-/g, "");
|
|
1231
|
-
}
|
|
1232
1060
|
|
|
1233
|
-
// src/helpers/
|
|
1234
|
-
var
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
const sessionId = await getCookie({
|
|
1242
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
1243
|
-
canTrack
|
|
1061
|
+
// src/helpers/css.ts
|
|
1062
|
+
var convertStyleMapToCSSArray = (style) => {
|
|
1063
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
1064
|
+
if (typeof value === "string") {
|
|
1065
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
1066
|
+
} else {
|
|
1067
|
+
return void 0;
|
|
1068
|
+
}
|
|
1244
1069
|
});
|
|
1245
|
-
|
|
1246
|
-
|
|
1070
|
+
return cssProps.filter(checkIsDefined);
|
|
1071
|
+
};
|
|
1072
|
+
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
1073
|
+
var createCssClass = ({
|
|
1074
|
+
mediaQuery,
|
|
1075
|
+
className,
|
|
1076
|
+
styles
|
|
1077
|
+
}) => {
|
|
1078
|
+
const cssClass = `.${className} {
|
|
1079
|
+
${convertStyleMapToCSS(styles)}
|
|
1080
|
+
}`;
|
|
1081
|
+
if (mediaQuery) {
|
|
1082
|
+
return `${mediaQuery} {
|
|
1083
|
+
${cssClass}
|
|
1084
|
+
}`;
|
|
1247
1085
|
} else {
|
|
1248
|
-
|
|
1249
|
-
setSessionId({
|
|
1250
|
-
id: newSessionId,
|
|
1251
|
-
canTrack
|
|
1252
|
-
});
|
|
1253
|
-
return newSessionId;
|
|
1086
|
+
return cssClass;
|
|
1254
1087
|
}
|
|
1255
1088
|
};
|
|
1256
|
-
var createSessionId = () => uuid();
|
|
1257
|
-
var setSessionId = ({
|
|
1258
|
-
id,
|
|
1259
|
-
canTrack
|
|
1260
|
-
}) => setCookie({
|
|
1261
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
1262
|
-
value: id,
|
|
1263
|
-
canTrack
|
|
1264
|
-
});
|
|
1265
1089
|
|
|
1266
|
-
// src/
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1090
|
+
// src/functions/transform-style-property.ts
|
|
1091
|
+
function transformStyleProperty({
|
|
1092
|
+
style
|
|
1093
|
+
}) {
|
|
1094
|
+
return style;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// src/functions/get-style.ts
|
|
1098
|
+
var getStyle = ({
|
|
1099
|
+
block,
|
|
1100
|
+
context
|
|
1271
1101
|
}) => {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1102
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
1103
|
+
style: block.style || {},
|
|
1104
|
+
context,
|
|
1105
|
+
block
|
|
1106
|
+
}));
|
|
1107
|
+
};
|
|
1108
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
1109
|
+
switch (TARGET) {
|
|
1110
|
+
case "svelte":
|
|
1111
|
+
case "vue":
|
|
1112
|
+
case "solid":
|
|
1113
|
+
case "angular":
|
|
1114
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
1115
|
+
case "qwik":
|
|
1116
|
+
case "reactNative":
|
|
1117
|
+
case "react":
|
|
1118
|
+
case "rsc":
|
|
1119
|
+
return style;
|
|
1279
1120
|
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// src/components/block/block.helpers.ts
|
|
1124
|
+
var checkIsComponentRestricted = (component, model) => {
|
|
1125
|
+
if (!component)
|
|
1126
|
+
return true;
|
|
1127
|
+
if (!model)
|
|
1128
|
+
return false;
|
|
1129
|
+
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
1280
1130
|
};
|
|
1281
|
-
var
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1131
|
+
var getComponent = ({
|
|
1132
|
+
block,
|
|
1133
|
+
registeredComponents,
|
|
1134
|
+
model
|
|
1285
1135
|
}) => {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1136
|
+
const componentName = block.component?.name;
|
|
1137
|
+
if (!componentName) {
|
|
1138
|
+
return null;
|
|
1139
|
+
}
|
|
1140
|
+
const ref = registeredComponents[componentName];
|
|
1141
|
+
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
1142
|
+
return void 0;
|
|
1143
|
+
} else {
|
|
1144
|
+
return ref;
|
|
1291
1145
|
}
|
|
1292
1146
|
};
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
var getVisitorId = ({
|
|
1297
|
-
canTrack
|
|
1147
|
+
var getRepeatItemData = ({
|
|
1148
|
+
block,
|
|
1149
|
+
context
|
|
1298
1150
|
}) => {
|
|
1299
|
-
|
|
1151
|
+
const {
|
|
1152
|
+
repeat,
|
|
1153
|
+
...blockWithoutRepeat
|
|
1154
|
+
} = block;
|
|
1155
|
+
if (!repeat?.collection) {
|
|
1300
1156
|
return void 0;
|
|
1301
1157
|
}
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1158
|
+
const itemsArray = evaluate({
|
|
1159
|
+
code: repeat.collection,
|
|
1160
|
+
localState: context.localState,
|
|
1161
|
+
rootState: context.rootState,
|
|
1162
|
+
rootSetState: context.rootSetState,
|
|
1163
|
+
context: context.context
|
|
1305
1164
|
});
|
|
1306
|
-
if (
|
|
1307
|
-
return
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1165
|
+
if (!Array.isArray(itemsArray)) {
|
|
1166
|
+
return void 0;
|
|
1167
|
+
}
|
|
1168
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
1169
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
1170
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
1171
|
+
context: {
|
|
1172
|
+
...context,
|
|
1173
|
+
localState: {
|
|
1174
|
+
...context.localState,
|
|
1175
|
+
$index: index,
|
|
1176
|
+
$item: item,
|
|
1177
|
+
[itemNameToUse]: item,
|
|
1178
|
+
[`$${itemNameToUse}Index`]: index
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
block: blockWithoutRepeat
|
|
1182
|
+
}));
|
|
1183
|
+
return repeatArray;
|
|
1184
|
+
};
|
|
1185
|
+
var provideLinkComponent = (block, linkComponent) => {
|
|
1186
|
+
if (block?.shouldReceiveBuilderProps?.builderLinkComponent)
|
|
1187
|
+
return {
|
|
1188
|
+
builderLinkComponent: linkComponent
|
|
1189
|
+
};
|
|
1190
|
+
return {};
|
|
1191
|
+
};
|
|
1192
|
+
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
1193
|
+
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
1194
|
+
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
1195
|
+
return !checkIsComponentRestricted(component, model);
|
|
1196
|
+
}));
|
|
1197
|
+
return {
|
|
1198
|
+
builderComponents: filteredRegisteredComponents
|
|
1199
|
+
};
|
|
1315
1200
|
}
|
|
1201
|
+
return {};
|
|
1316
1202
|
};
|
|
1317
|
-
var
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1203
|
+
var provideBuilderBlock = (block, builderBlock) => {
|
|
1204
|
+
if (block?.shouldReceiveBuilderProps?.builderBlock)
|
|
1205
|
+
return {
|
|
1206
|
+
builderBlock
|
|
1207
|
+
};
|
|
1208
|
+
return {};
|
|
1209
|
+
};
|
|
1210
|
+
var provideBuilderContext = (block, context) => {
|
|
1211
|
+
if (block?.shouldReceiveBuilderProps?.builderContext)
|
|
1212
|
+
return {
|
|
1213
|
+
builderContext: context
|
|
1214
|
+
};
|
|
1215
|
+
return {};
|
|
1216
|
+
};
|
|
1217
|
+
var generateKey = (index) => {
|
|
1218
|
+
return index.toString();
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
// src/functions/event-handler-name.ts
|
|
1222
|
+
function capitalizeFirstLetter(string) {
|
|
1223
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1224
|
+
}
|
|
1225
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
1226
|
+
|
|
1227
|
+
// src/functions/get-block-actions-handler.ts
|
|
1228
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
1229
|
+
code: value,
|
|
1230
|
+
context: options.context,
|
|
1231
|
+
localState: options.localState,
|
|
1232
|
+
rootState: options.rootState,
|
|
1233
|
+
rootSetState: options.rootSetState,
|
|
1234
|
+
event,
|
|
1235
|
+
isExpression: false,
|
|
1236
|
+
trackingContext: options.trackingContext
|
|
1325
1237
|
});
|
|
1326
1238
|
|
|
1327
|
-
// src/functions/
|
|
1328
|
-
function
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1239
|
+
// src/functions/get-block-actions.ts
|
|
1240
|
+
function getBlockActions(options) {
|
|
1241
|
+
const obj = {};
|
|
1242
|
+
const optionActions = options.block.actions ?? {};
|
|
1243
|
+
for (const key in optionActions) {
|
|
1244
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
const value = optionActions[key];
|
|
1248
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
1249
|
+
if (options.stripPrefix) {
|
|
1250
|
+
switch (TARGET) {
|
|
1251
|
+
case "vue":
|
|
1252
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
1253
|
+
break;
|
|
1254
|
+
case "svelte":
|
|
1255
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1332
1258
|
}
|
|
1259
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
1333
1260
|
}
|
|
1261
|
+
return obj;
|
|
1334
1262
|
}
|
|
1335
1263
|
|
|
1336
|
-
// src/functions/
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
})
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1346
|
-
const sessionId = await getSessionId({
|
|
1347
|
-
canTrack
|
|
1348
|
-
});
|
|
1349
|
-
const visitorId = getVisitorId({
|
|
1350
|
-
canTrack
|
|
1351
|
-
});
|
|
1264
|
+
// src/functions/transform-block-properties.ts
|
|
1265
|
+
function transformBlockProperties({
|
|
1266
|
+
properties
|
|
1267
|
+
}) {
|
|
1268
|
+
return properties;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// src/functions/get-block-properties.ts
|
|
1272
|
+
var extractRelevantRootBlockProperties = (block) => {
|
|
1352
1273
|
return {
|
|
1353
|
-
|
|
1354
|
-
visitorId
|
|
1274
|
+
href: block.href
|
|
1355
1275
|
};
|
|
1356
1276
|
};
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
url: location.href,
|
|
1369
|
-
...metadata
|
|
1370
|
-
},
|
|
1371
|
-
...await getTrackingEventData({
|
|
1372
|
-
canTrack
|
|
1277
|
+
function getBlockProperties({
|
|
1278
|
+
block,
|
|
1279
|
+
context
|
|
1280
|
+
}) {
|
|
1281
|
+
const properties = {
|
|
1282
|
+
...extractRelevantRootBlockProperties(block),
|
|
1283
|
+
...block.properties,
|
|
1284
|
+
"builder-id": block.id,
|
|
1285
|
+
style: getStyle({
|
|
1286
|
+
block,
|
|
1287
|
+
context
|
|
1373
1288
|
}),
|
|
1374
|
-
|
|
1375
|
-
|
|
1289
|
+
[getClassPropName()]: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
1290
|
+
};
|
|
1291
|
+
return transformBlockProperties({
|
|
1292
|
+
properties,
|
|
1293
|
+
context,
|
|
1294
|
+
block
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// src/components/block/components/block-wrapper.tsx
|
|
1299
|
+
function BlockWrapper(props) {
|
|
1300
|
+
return createComponent(dynamic_renderer_default, {
|
|
1301
|
+
get TagName() {
|
|
1302
|
+
return props.Wrapper;
|
|
1303
|
+
},
|
|
1304
|
+
get attributes() {
|
|
1305
|
+
return getBlockProperties({
|
|
1306
|
+
block: props.block,
|
|
1307
|
+
context: props.context
|
|
1308
|
+
});
|
|
1309
|
+
},
|
|
1310
|
+
get actionAttributes() {
|
|
1311
|
+
return getBlockActions({
|
|
1312
|
+
block: props.block,
|
|
1313
|
+
rootState: props.context.rootState,
|
|
1314
|
+
rootSetState: props.context.rootSetState,
|
|
1315
|
+
localState: props.context.localState,
|
|
1316
|
+
context: props.context.context,
|
|
1317
|
+
stripPrefix: true,
|
|
1318
|
+
trackingContext: {
|
|
1319
|
+
apiKey: props.context.apiKey,
|
|
1320
|
+
canTrack: props.context.canTrack ?? true,
|
|
1321
|
+
contentId: props.context.content?.id,
|
|
1322
|
+
variationId: props.context.content?.testVariationId
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
},
|
|
1326
|
+
get children() {
|
|
1327
|
+
return props.children;
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
var block_wrapper_default = BlockWrapper;
|
|
1332
|
+
|
|
1333
|
+
// src/functions/is-previewing.ts
|
|
1334
|
+
function isPreviewing(search) {
|
|
1335
|
+
const searchToUse = search || (isBrowser() ? window.location.search : void 0);
|
|
1336
|
+
if (!searchToUse) {
|
|
1337
|
+
return false;
|
|
1376
1338
|
}
|
|
1339
|
+
const normalizedSearch = getSearchString(searchToUse);
|
|
1340
|
+
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/functions/register-component.ts
|
|
1344
|
+
var createRegisterComponentMessage = (info) => ({
|
|
1345
|
+
type: "builder.registerComponent",
|
|
1346
|
+
data: serializeIncludingFunctions(info)
|
|
1377
1347
|
});
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1348
|
+
var serializeFn = (fnValue) => {
|
|
1349
|
+
const fnStr = fnValue.toString().trim();
|
|
1350
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1351
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
1352
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
1353
|
+
};
|
|
1354
|
+
function serializeIncludingFunctions(info) {
|
|
1355
|
+
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
1356
|
+
if (typeof value === "function") {
|
|
1357
|
+
return serializeFn(value);
|
|
1358
|
+
}
|
|
1359
|
+
return value;
|
|
1360
|
+
}));
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// src/functions/register.ts
|
|
1364
|
+
var registry = {};
|
|
1365
|
+
function register(type, info) {
|
|
1366
|
+
if (type === "plugin") {
|
|
1367
|
+
info = serializeIncludingFunctions(info);
|
|
1385
1368
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1369
|
+
let typeList = registry[type];
|
|
1370
|
+
if (!typeList) {
|
|
1371
|
+
typeList = registry[type] = [];
|
|
1388
1372
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1373
|
+
typeList.push(info);
|
|
1374
|
+
if (isBrowser()) {
|
|
1375
|
+
const message = {
|
|
1376
|
+
type: "builder.register",
|
|
1377
|
+
data: {
|
|
1378
|
+
type,
|
|
1379
|
+
info
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
try {
|
|
1383
|
+
parent.postMessage(message, "*");
|
|
1384
|
+
if (parent !== window) {
|
|
1385
|
+
window.postMessage(message, "*");
|
|
1386
|
+
}
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
}
|
|
1391
1389
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1390
|
+
}
|
|
1391
|
+
function registerAction(action) {
|
|
1392
|
+
if (isBrowser()) {
|
|
1393
|
+
const actionClone = JSON.parse(JSON.stringify(action));
|
|
1394
|
+
if (action.action) {
|
|
1395
|
+
actionClone.action = action.action.toString();
|
|
1396
|
+
}
|
|
1397
|
+
window.parent?.postMessage({
|
|
1398
|
+
type: "builder.registerAction",
|
|
1399
|
+
data: actionClone
|
|
1400
|
+
}, "*");
|
|
1394
1401
|
}
|
|
1395
|
-
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
1396
|
-
const url = `${baseUrl}/api/v1/track`;
|
|
1397
|
-
logFetch(url);
|
|
1398
|
-
return fetch(url, {
|
|
1399
|
-
method: "POST",
|
|
1400
|
-
body: JSON.stringify({
|
|
1401
|
-
events: [await createEvent(eventProps)]
|
|
1402
|
-
}),
|
|
1403
|
-
headers: {
|
|
1404
|
-
"content-type": "application/json",
|
|
1405
|
-
...getSdkHeaders()
|
|
1406
|
-
},
|
|
1407
|
-
mode: "cors"
|
|
1408
|
-
}).catch((err) => {
|
|
1409
|
-
});
|
|
1410
1402
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1403
|
+
|
|
1404
|
+
// src/functions/set-editor-settings.ts
|
|
1405
|
+
var settings = {};
|
|
1406
|
+
function setEditorSettings(newSettings) {
|
|
1407
|
+
if (isBrowser()) {
|
|
1408
|
+
Object.assign(settings, newSettings);
|
|
1409
|
+
const message = {
|
|
1410
|
+
type: "builder.settingsChange",
|
|
1411
|
+
data: settings
|
|
1412
|
+
};
|
|
1413
|
+
parent.postMessage(message, "*");
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
// src/functions/get-builder-search-params/index.ts
|
|
1418
|
+
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
1419
|
+
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
1420
|
+
var getBuilderSearchParams = (_options) => {
|
|
1421
|
+
if (!_options) {
|
|
1422
|
+
return {};
|
|
1423
|
+
}
|
|
1424
|
+
const options = normalizeSearchParams(_options);
|
|
1425
|
+
const newOptions = {};
|
|
1426
|
+
Object.keys(options).forEach((key) => {
|
|
1427
|
+
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1428
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1429
|
+
newOptions[trimmedKey] = options[key];
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
return newOptions;
|
|
1433
|
+
};
|
|
1434
|
+
var getBuilderSearchParamsFromWindow = () => {
|
|
1435
|
+
if (!isBrowser()) {
|
|
1436
|
+
return {};
|
|
1437
|
+
}
|
|
1438
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1439
|
+
return getBuilderSearchParams(searchParams);
|
|
1440
|
+
};
|
|
1415
1441
|
|
|
1416
1442
|
// src/functions/is-from-trusted-host.ts
|
|
1417
1443
|
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
@@ -2152,7 +2178,13 @@ function InteractiveElement(props) {
|
|
|
2152
2178
|
rootState: props.context.rootState,
|
|
2153
2179
|
rootSetState: props.context.rootSetState,
|
|
2154
2180
|
localState: props.context.localState,
|
|
2155
|
-
context: props.context.context
|
|
2181
|
+
context: props.context.context,
|
|
2182
|
+
trackingContext: {
|
|
2183
|
+
apiKey: props.context.apiKey,
|
|
2184
|
+
canTrack: props.context.canTrack ?? true,
|
|
2185
|
+
contentId: props.context.content?.id,
|
|
2186
|
+
variationId: props.context.content?.testVariationId
|
|
2187
|
+
}
|
|
2156
2188
|
})
|
|
2157
2189
|
} : {};
|
|
2158
2190
|
});
|