@builder.io/sdk-solid 4.0.7 → 4.0.9
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/dist/index.d.ts +14 -2
- package/lib/browser/dev.js +369 -283
- package/lib/browser/dev.jsx +325 -282
- package/lib/browser/index.js +369 -283
- package/lib/browser/index.jsx +325 -282
- package/lib/edge/dev.js +369 -283
- package/lib/edge/dev.jsx +325 -282
- package/lib/edge/index.js +369 -283
- package/lib/edge/index.jsx +325 -282
- package/lib/node/dev.js +369 -283
- package/lib/node/dev.jsx +325 -282
- package/lib/node/index.js +369 -283
- package/lib/node/index.jsx +325 -282
- package/package.json +1 -1
package/lib/edge/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic
|
|
1
|
+
import { delegateEvents, createComponent, memo, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic } from 'solid-js/web';
|
|
2
2
|
import { createContext, useContext, Show, For, createMemo, onMount, createSignal, createEffect, on } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -4390,6 +4390,7 @@ var awaiter_default = Awaiter;
|
|
|
4390
4390
|
|
|
4391
4391
|
// src/components/block/components/interactive-element.tsx
|
|
4392
4392
|
function InteractiveElement(props) {
|
|
4393
|
+
createSignal(0);
|
|
4393
4394
|
const attributes = createMemo(() => {
|
|
4394
4395
|
return props.includeBlockProps ? {
|
|
4395
4396
|
...getBlockProperties({
|
|
@@ -4408,6 +4409,11 @@ function InteractiveElement(props) {
|
|
|
4408
4409
|
const targetWrapperProps = createMemo(() => {
|
|
4409
4410
|
return props.wrapperProps;
|
|
4410
4411
|
});
|
|
4412
|
+
const onUpdateFn_0_props_wrapperProps = createMemo(() => props.wrapperProps);
|
|
4413
|
+
const onUpdateFn_0_props_block__component__options = createMemo(() => props.block?.component?.options);
|
|
4414
|
+
function onUpdateFn_0() {
|
|
4415
|
+
}
|
|
4416
|
+
createEffect(on(() => [onUpdateFn_0_props_wrapperProps(), onUpdateFn_0_props_block__component__options()], onUpdateFn_0));
|
|
4411
4417
|
return createComponent(Show, {
|
|
4412
4418
|
get fallback() {
|
|
4413
4419
|
return createComponent(Dynamic, mergeProps(targetWrapperProps, {
|
|
@@ -4834,7 +4840,7 @@ function Block(props) {
|
|
|
4834
4840
|
});
|
|
4835
4841
|
}
|
|
4836
4842
|
var block_default = Block;
|
|
4837
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4843
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
4838
4844
|
display: flex;
|
|
4839
4845
|
flex-direction: column;
|
|
4840
4846
|
align-items: stretch;
|
|
@@ -4883,7 +4889,7 @@ function BlocksWrapper(props) {
|
|
|
4883
4889
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
4884
4890
|
return [createComponent(Dynamic, mergeProps({
|
|
4885
4891
|
get ["class"]() {
|
|
4886
|
-
return className() + " dynamic-
|
|
4892
|
+
return className() + " dynamic-450facf4";
|
|
4887
4893
|
},
|
|
4888
4894
|
ref(r$) {
|
|
4889
4895
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4930,17 +4936,17 @@ function Blocks(props) {
|
|
|
4930
4936
|
get styleProp() {
|
|
4931
4937
|
return props.styleProp;
|
|
4932
4938
|
},
|
|
4939
|
+
get BlocksWrapperProps() {
|
|
4940
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4941
|
+
},
|
|
4933
4942
|
get classNameProp() {
|
|
4934
4943
|
return props.className;
|
|
4935
4944
|
},
|
|
4936
4945
|
get BlocksWrapper() {
|
|
4937
4946
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
4938
4947
|
},
|
|
4939
|
-
get BlocksWrapperProps() {
|
|
4940
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4941
|
-
},
|
|
4942
4948
|
get children() {
|
|
4943
|
-
return createComponent(Show, {
|
|
4949
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
4944
4950
|
get when() {
|
|
4945
4951
|
return props.blocks;
|
|
4946
4952
|
},
|
|
@@ -4969,7 +4975,7 @@ function Blocks(props) {
|
|
|
4969
4975
|
}
|
|
4970
4976
|
});
|
|
4971
4977
|
}
|
|
4972
|
-
});
|
|
4978
|
+
})];
|
|
4973
4979
|
}
|
|
4974
4980
|
});
|
|
4975
4981
|
}
|
|
@@ -5393,6 +5399,166 @@ function SectionComponent(props) {
|
|
|
5393
5399
|
}
|
|
5394
5400
|
var section_default = SectionComponent;
|
|
5395
5401
|
|
|
5402
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
5403
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
5404
|
+
function isString(val) {
|
|
5405
|
+
return typeof val === "string";
|
|
5406
|
+
}
|
|
5407
|
+
function isNumber(val) {
|
|
5408
|
+
return typeof val === "number";
|
|
5409
|
+
}
|
|
5410
|
+
function objectMatchesQuery(userattr, query2) {
|
|
5411
|
+
const result = (() => {
|
|
5412
|
+
const property = query2.property;
|
|
5413
|
+
const operator = query2.operator;
|
|
5414
|
+
let testValue = query2.value;
|
|
5415
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
5416
|
+
testValue = query2.value.slice(0, -1);
|
|
5417
|
+
}
|
|
5418
|
+
if (!(property && operator)) {
|
|
5419
|
+
return true;
|
|
5420
|
+
}
|
|
5421
|
+
if (Array.isArray(testValue)) {
|
|
5422
|
+
if (operator === "isNot") {
|
|
5423
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
5424
|
+
property,
|
|
5425
|
+
operator,
|
|
5426
|
+
value: val
|
|
5427
|
+
}));
|
|
5428
|
+
}
|
|
5429
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
5430
|
+
property,
|
|
5431
|
+
operator,
|
|
5432
|
+
value: val
|
|
5433
|
+
}));
|
|
5434
|
+
}
|
|
5435
|
+
const value = userattr[property];
|
|
5436
|
+
if (Array.isArray(value)) {
|
|
5437
|
+
return value.includes(testValue);
|
|
5438
|
+
}
|
|
5439
|
+
switch (operator) {
|
|
5440
|
+
case "is":
|
|
5441
|
+
return value === testValue;
|
|
5442
|
+
case "isNot":
|
|
5443
|
+
return value !== testValue;
|
|
5444
|
+
case "contains":
|
|
5445
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
5446
|
+
case "startsWith":
|
|
5447
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
5448
|
+
case "endsWith":
|
|
5449
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
5450
|
+
case "greaterThan":
|
|
5451
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
5452
|
+
case "lessThan":
|
|
5453
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
5454
|
+
case "greaterThanOrEqualTo":
|
|
5455
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
5456
|
+
case "lessThanOrEqualTo":
|
|
5457
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
5458
|
+
default:
|
|
5459
|
+
return false;
|
|
5460
|
+
}
|
|
5461
|
+
})();
|
|
5462
|
+
return result;
|
|
5463
|
+
}
|
|
5464
|
+
const item = {
|
|
5465
|
+
query,
|
|
5466
|
+
startDate,
|
|
5467
|
+
endDate
|
|
5468
|
+
};
|
|
5469
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
5470
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
5471
|
+
return false;
|
|
5472
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
5473
|
+
return false;
|
|
5474
|
+
}
|
|
5475
|
+
if (!item.query || !item.query.length) {
|
|
5476
|
+
return true;
|
|
5477
|
+
}
|
|
5478
|
+
return item.query.every((filter) => {
|
|
5479
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
var PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, isHydrationTarget, locale) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const parentDiv = document.currentScript?.parentElement;\n const variantId = parentDiv?.getAttribute('data-variant-id');\n const isDefaultVariant = variantId === `${blockId}-default`;\n const isWinningVariant = winningVariantIndex !== -1 && variantId === `${blockId}-${winningVariantIndex}` || winningVariantIndex === -1 && isDefaultVariant;\n if (isWinningVariant && !isDefaultVariant) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultVariant) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n const itsStyleEl = parentDiv?.previousElementSibling;\n if (itsStyleEl) {\n itsStyleEl.remove();\n }\n parentDiv?.remove();\n }\n const thisScript = document.currentScript;\n if (thisScript) {\n thisScript.remove();\n }\n }\n}";
|
|
5483
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
5484
|
+
var UPDATE_VISIBILITY_STYLES_SCRIPT = "function updateVisibilityStylesScript(variants, blockId, isHydrationTarget, locale) {\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const visibilityStylesEl = document.currentScript?.previousElementSibling;\n if (!visibilityStylesEl) {\n return;\n }\n if (isHydrationTarget) {\n visibilityStylesEl.remove();\n const currentScript = document.currentScript;\n if (currentScript) {\n currentScript.remove();\n }\n } else {\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n if (winningVariantIndex !== -1) {\n let newStyleStr = variants?.map((_, index) => {\n if (index === winningVariantIndex) return '';\n return `div[data-variant-id=\"${blockId}-${index}\"] { display: none !important; } `;\n }).join('') || '';\n newStyleStr += `div[data-variant-id=\"${blockId}-default\"] { display: none !important; } `;\n visibilityStylesEl.innerHTML = newStyleStr;\n }\n }\n}";
|
|
5485
|
+
|
|
5486
|
+
// src/blocks/personalization-container/helpers.ts
|
|
5487
|
+
var DEFAULT_INDEX = "default";
|
|
5488
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
5489
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
5490
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
5491
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
5492
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
5493
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
5494
|
+
const hasVariants = variants && variants.length > 0;
|
|
5495
|
+
if (TARGET === "reactNative")
|
|
5496
|
+
return false;
|
|
5497
|
+
if (!hasVariants)
|
|
5498
|
+
return false;
|
|
5499
|
+
if (!canTrack)
|
|
5500
|
+
return false;
|
|
5501
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
5502
|
+
return true;
|
|
5503
|
+
if (isBrowser())
|
|
5504
|
+
return false;
|
|
5505
|
+
return true;
|
|
5506
|
+
}
|
|
5507
|
+
function getBlocksToRender({
|
|
5508
|
+
variants,
|
|
5509
|
+
previewingIndex,
|
|
5510
|
+
isHydrated,
|
|
5511
|
+
filteredVariants,
|
|
5512
|
+
fallbackBlocks
|
|
5513
|
+
}) {
|
|
5514
|
+
const fallback = {
|
|
5515
|
+
blocks: fallbackBlocks ?? [],
|
|
5516
|
+
path: "this.children",
|
|
5517
|
+
index: DEFAULT_INDEX
|
|
5518
|
+
};
|
|
5519
|
+
if (isHydrated && isEditing()) {
|
|
5520
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
5521
|
+
const variant = variants?.[previewingIndex];
|
|
5522
|
+
if (variant) {
|
|
5523
|
+
return {
|
|
5524
|
+
blocks: variant.blocks,
|
|
5525
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
5526
|
+
index: previewingIndex
|
|
5527
|
+
};
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
return fallback;
|
|
5531
|
+
}
|
|
5532
|
+
if (isBrowser()) {
|
|
5533
|
+
const winningVariant = filteredVariants?.[0];
|
|
5534
|
+
if (winningVariant && variants) {
|
|
5535
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
5536
|
+
if (variantIndex !== -1) {
|
|
5537
|
+
return {
|
|
5538
|
+
blocks: winningVariant.blocks,
|
|
5539
|
+
path: `variants.${variantIndex}.blocks`,
|
|
5540
|
+
index: variantIndex
|
|
5541
|
+
};
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
}
|
|
5545
|
+
return fallback;
|
|
5546
|
+
}
|
|
5547
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
5548
|
+
return `
|
|
5549
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
5550
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
5551
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
5552
|
+
`;
|
|
5553
|
+
};
|
|
5554
|
+
var isHydrationTarget = TARGET === "react";
|
|
5555
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
5556
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5557
|
+
};
|
|
5558
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
5559
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5560
|
+
};
|
|
5561
|
+
|
|
5396
5562
|
// src/helpers/url.ts
|
|
5397
5563
|
var getTopLevelDomain = (host) => {
|
|
5398
5564
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -6371,7 +6537,8 @@ var componentInfo6 = {
|
|
|
6371
6537
|
name: "PersonalizationContainer",
|
|
6372
6538
|
shouldReceiveBuilderProps: {
|
|
6373
6539
|
builderBlock: true,
|
|
6374
|
-
builderContext: true
|
|
6540
|
+
builderContext: true,
|
|
6541
|
+
builderComponents: true
|
|
6375
6542
|
},
|
|
6376
6543
|
noWrap: true,
|
|
6377
6544
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -6433,208 +6600,22 @@ function isPreviewing(_search) {
|
|
|
6433
6600
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
6434
6601
|
}
|
|
6435
6602
|
|
|
6436
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
6437
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
6438
|
-
function isString(val) {
|
|
6439
|
-
return typeof val === "string";
|
|
6440
|
-
}
|
|
6441
|
-
function isNumber(val) {
|
|
6442
|
-
return typeof val === "number";
|
|
6443
|
-
}
|
|
6444
|
-
function objectMatchesQuery(userattr, query2) {
|
|
6445
|
-
const result = (() => {
|
|
6446
|
-
const property = query2.property;
|
|
6447
|
-
const operator = query2.operator;
|
|
6448
|
-
let testValue = query2.value;
|
|
6449
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
6450
|
-
testValue = query2.value.slice(0, -1);
|
|
6451
|
-
}
|
|
6452
|
-
if (!(property && operator)) {
|
|
6453
|
-
return true;
|
|
6454
|
-
}
|
|
6455
|
-
if (Array.isArray(testValue)) {
|
|
6456
|
-
if (operator === "isNot") {
|
|
6457
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
6458
|
-
property,
|
|
6459
|
-
operator,
|
|
6460
|
-
value: val
|
|
6461
|
-
}));
|
|
6462
|
-
}
|
|
6463
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
6464
|
-
property,
|
|
6465
|
-
operator,
|
|
6466
|
-
value: val
|
|
6467
|
-
}));
|
|
6468
|
-
}
|
|
6469
|
-
const value = userattr[property];
|
|
6470
|
-
if (Array.isArray(value)) {
|
|
6471
|
-
return value.includes(testValue);
|
|
6472
|
-
}
|
|
6473
|
-
switch (operator) {
|
|
6474
|
-
case "is":
|
|
6475
|
-
return value === testValue;
|
|
6476
|
-
case "isNot":
|
|
6477
|
-
return value !== testValue;
|
|
6478
|
-
case "contains":
|
|
6479
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
6480
|
-
case "startsWith":
|
|
6481
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
6482
|
-
case "endsWith":
|
|
6483
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
6484
|
-
case "greaterThan":
|
|
6485
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
6486
|
-
case "lessThan":
|
|
6487
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
6488
|
-
case "greaterThanOrEqualTo":
|
|
6489
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
6490
|
-
case "lessThanOrEqualTo":
|
|
6491
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
6492
|
-
default:
|
|
6493
|
-
return false;
|
|
6494
|
-
}
|
|
6495
|
-
})();
|
|
6496
|
-
return result;
|
|
6497
|
-
}
|
|
6498
|
-
const item = {
|
|
6499
|
-
query,
|
|
6500
|
-
startDate,
|
|
6501
|
-
endDate
|
|
6502
|
-
};
|
|
6503
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
6504
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
6505
|
-
return false;
|
|
6506
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
6507
|
-
return false;
|
|
6508
|
-
}
|
|
6509
|
-
if (!item.query || !item.query.length) {
|
|
6510
|
-
return true;
|
|
6511
|
-
}
|
|
6512
|
-
return item.query.every((filter) => {
|
|
6513
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
6514
|
-
});
|
|
6515
|
-
}
|
|
6516
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
6517
|
-
if (!navigator.cookieEnabled) {
|
|
6518
|
-
return;
|
|
6519
|
-
}
|
|
6520
|
-
function getCookie(name) {
|
|
6521
|
-
const nameEQ = name + '=';
|
|
6522
|
-
const ca = document.cookie.split(';');
|
|
6523
|
-
for (let i = 0; i < ca.length; i++) {
|
|
6524
|
-
let c = ca[i];
|
|
6525
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
6526
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
6527
|
-
}
|
|
6528
|
-
return null;
|
|
6529
|
-
}
|
|
6530
|
-
function removeVariants() {
|
|
6531
|
-
variants?.forEach(function (_, index) {
|
|
6532
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
6533
|
-
});
|
|
6534
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
6535
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
6536
|
-
}
|
|
6537
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
6538
|
-
if (locale) {
|
|
6539
|
-
attributes.locale = locale;
|
|
6540
|
-
}
|
|
6541
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
6542
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
6543
|
-
});
|
|
6544
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
6545
|
-
if (isDebug) {
|
|
6546
|
-
console.debug('PersonalizationContainer', {
|
|
6547
|
-
attributes,
|
|
6548
|
-
variants,
|
|
6549
|
-
winningVariantIndex
|
|
6550
|
-
});
|
|
6551
|
-
}
|
|
6552
|
-
if (winningVariantIndex !== -1) {
|
|
6553
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
6554
|
-
if (winningVariant) {
|
|
6555
|
-
const parentNode = winningVariant.parentNode;
|
|
6556
|
-
if (parentNode) {
|
|
6557
|
-
const newParent = parentNode.cloneNode(false);
|
|
6558
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
6559
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
6560
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
6561
|
-
}
|
|
6562
|
-
if (isDebug) {
|
|
6563
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
6564
|
-
}
|
|
6565
|
-
}
|
|
6566
|
-
} else if (variants && variants.length > 0) {
|
|
6567
|
-
removeVariants();
|
|
6568
|
-
}
|
|
6569
|
-
}`;
|
|
6570
|
-
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
6571
|
-
|
|
6572
|
-
// src/blocks/personalization-container/helpers.ts
|
|
6573
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
6574
|
-
const hasVariants = variants && variants.length > 0;
|
|
6575
|
-
if (TARGET === "reactNative")
|
|
6576
|
-
return false;
|
|
6577
|
-
if (!hasVariants)
|
|
6578
|
-
return false;
|
|
6579
|
-
if (!canTrack)
|
|
6580
|
-
return false;
|
|
6581
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
6582
|
-
return true;
|
|
6583
|
-
if (isBrowser())
|
|
6584
|
-
return false;
|
|
6585
|
-
return true;
|
|
6586
|
-
}
|
|
6587
|
-
function getBlocksToRender({
|
|
6588
|
-
variants,
|
|
6589
|
-
previewingIndex,
|
|
6590
|
-
isHydrated,
|
|
6591
|
-
filteredVariants,
|
|
6592
|
-
fallbackBlocks
|
|
6593
|
-
}) {
|
|
6594
|
-
const fallback = {
|
|
6595
|
-
blocks: fallbackBlocks ?? [],
|
|
6596
|
-
path: "this.children"
|
|
6597
|
-
};
|
|
6598
|
-
if (isHydrated && isEditing()) {
|
|
6599
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
6600
|
-
const variant = variants[previewingIndex];
|
|
6601
|
-
return {
|
|
6602
|
-
blocks: variant.blocks,
|
|
6603
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
6604
|
-
};
|
|
6605
|
-
}
|
|
6606
|
-
return fallback;
|
|
6607
|
-
}
|
|
6608
|
-
if (isBrowser()) {
|
|
6609
|
-
const winningVariant = filteredVariants?.[0];
|
|
6610
|
-
if (winningVariant) {
|
|
6611
|
-
return {
|
|
6612
|
-
blocks: winningVariant.blocks,
|
|
6613
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
6614
|
-
};
|
|
6615
|
-
}
|
|
6616
|
-
}
|
|
6617
|
-
return fallback;
|
|
6618
|
-
}
|
|
6619
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
6620
|
-
return `
|
|
6621
|
-
(function() {
|
|
6622
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
6623
|
-
${PERSONALIZATION_SCRIPT}
|
|
6624
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
6625
|
-
})();
|
|
6626
|
-
`;
|
|
6627
|
-
};
|
|
6628
|
-
|
|
6629
6603
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
6630
6604
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
6631
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
6632
6605
|
function PersonalizationContainer(props) {
|
|
6633
6606
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
6634
6607
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6608
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
6635
6609
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
6636
6610
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
6637
|
-
const [
|
|
6611
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
6612
|
+
const attrs = createMemo(() => {
|
|
6613
|
+
return {
|
|
6614
|
+
...props.attributes,
|
|
6615
|
+
...{},
|
|
6616
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
6617
|
+
};
|
|
6618
|
+
});
|
|
6638
6619
|
const filteredVariants = createMemo(() => {
|
|
6639
6620
|
return (props.variants || []).filter((variant) => {
|
|
6640
6621
|
return filterWithCustomTargeting({
|
|
@@ -6649,26 +6630,26 @@ function PersonalizationContainer(props) {
|
|
|
6649
6630
|
return getBlocksToRender({
|
|
6650
6631
|
variants: props.variants,
|
|
6651
6632
|
fallbackBlocks: props.builderBlock?.children,
|
|
6652
|
-
isHydrated:
|
|
6633
|
+
isHydrated: shouldResetVariants(),
|
|
6653
6634
|
filteredVariants: filteredVariants(),
|
|
6654
6635
|
previewingIndex: props.previewingIndex
|
|
6655
6636
|
});
|
|
6656
6637
|
});
|
|
6657
6638
|
const hideVariantsStyleString = createMemo(() => {
|
|
6658
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
6639
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
6659
6640
|
});
|
|
6660
6641
|
let rootRef;
|
|
6661
6642
|
onMount(() => {
|
|
6662
|
-
|
|
6663
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
6664
|
-
setUserAttributes(
|
|
6643
|
+
setShouldResetVariants(true);
|
|
6644
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
6645
|
+
setUserAttributes(attrs2);
|
|
6665
6646
|
});
|
|
6666
6647
|
if (!(isEditing() || isPreviewing())) {
|
|
6667
6648
|
const variant = filteredVariants()[0];
|
|
6668
6649
|
if (rootRef) {
|
|
6669
6650
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
6670
6651
|
detail: {
|
|
6671
|
-
variant: variant ||
|
|
6652
|
+
variant: variant || DEFAULT_INDEX,
|
|
6672
6653
|
content: props.builderContext?.content
|
|
6673
6654
|
},
|
|
6674
6655
|
bubbles: true
|
|
@@ -6678,7 +6659,7 @@ function PersonalizationContainer(props) {
|
|
|
6678
6659
|
if (entry.isIntersecting && rootRef) {
|
|
6679
6660
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
6680
6661
|
detail: {
|
|
6681
|
-
variant: variant ||
|
|
6662
|
+
variant: variant || DEFAULT_INDEX,
|
|
6682
6663
|
content: props.builderContext?.content
|
|
6683
6664
|
},
|
|
6684
6665
|
bubbles: true
|
|
@@ -6695,70 +6676,158 @@ function PersonalizationContainer(props) {
|
|
|
6695
6676
|
const _el$ = _tmpl$9();
|
|
6696
6677
|
const _ref$ = rootRef;
|
|
6697
6678
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
6698
|
-
spread(_el$, mergeProps(
|
|
6699
|
-
get ["class"]() {
|
|
6700
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
6701
|
-
}
|
|
6702
|
-
}, () => props.attributes), false, true);
|
|
6679
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
6703
6680
|
insert(_el$, createComponent(Show, {
|
|
6704
6681
|
get when() {
|
|
6705
|
-
return
|
|
6682
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6706
6683
|
},
|
|
6707
6684
|
get children() {
|
|
6708
|
-
return
|
|
6709
|
-
get
|
|
6710
|
-
return
|
|
6685
|
+
return createComponent(blocks_default, {
|
|
6686
|
+
get blocks() {
|
|
6687
|
+
return blocksToRender().blocks;
|
|
6711
6688
|
},
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
return (() => {
|
|
6715
|
-
const _el$2 = _tmpl$25();
|
|
6716
|
-
setAttribute(_el$2, "key", index);
|
|
6717
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
6718
|
-
get blocks() {
|
|
6719
|
-
return variant.blocks;
|
|
6720
|
-
},
|
|
6721
|
-
get parent() {
|
|
6722
|
-
return props.builderBlock?.id;
|
|
6723
|
-
},
|
|
6724
|
-
path: `component.options.variants.${index}.blocks`
|
|
6725
|
-
}));
|
|
6726
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
6727
|
-
return _el$2;
|
|
6728
|
-
})();
|
|
6729
|
-
}
|
|
6730
|
-
}), createComponent(inlined_styles_default, {
|
|
6731
|
-
get nonce() {
|
|
6732
|
-
return props.builderContext?.nonce || "";
|
|
6689
|
+
get parent() {
|
|
6690
|
+
return props.builderBlock?.id;
|
|
6733
6691
|
},
|
|
6734
|
-
get
|
|
6735
|
-
return
|
|
6692
|
+
get path() {
|
|
6693
|
+
return blocksToRender().path;
|
|
6736
6694
|
},
|
|
6737
|
-
get
|
|
6738
|
-
return
|
|
6739
|
-
}
|
|
6740
|
-
}), createComponent(inlined_script_default, {
|
|
6741
|
-
get nonce() {
|
|
6742
|
-
return props.builderContext?.nonce || "";
|
|
6695
|
+
get context() {
|
|
6696
|
+
return props.builderContext;
|
|
6743
6697
|
},
|
|
6744
|
-
get
|
|
6745
|
-
return
|
|
6698
|
+
get registeredComponents() {
|
|
6699
|
+
return props.builderComponents;
|
|
6746
6700
|
},
|
|
6747
|
-
get
|
|
6748
|
-
return
|
|
6701
|
+
get BlocksWrapperProps() {
|
|
6702
|
+
return {
|
|
6703
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6704
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6705
|
+
};
|
|
6749
6706
|
}
|
|
6750
|
-
})
|
|
6707
|
+
});
|
|
6751
6708
|
}
|
|
6752
6709
|
}), null);
|
|
6753
|
-
insert(_el$, createComponent(
|
|
6754
|
-
get
|
|
6755
|
-
return
|
|
6756
|
-
},
|
|
6757
|
-
get parent() {
|
|
6758
|
-
return props.builderBlock?.id;
|
|
6710
|
+
insert(_el$, createComponent(Show, {
|
|
6711
|
+
get when() {
|
|
6712
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
6759
6713
|
},
|
|
6760
|
-
get
|
|
6761
|
-
return
|
|
6714
|
+
get children() {
|
|
6715
|
+
return [createComponent(Show, {
|
|
6716
|
+
get when() {
|
|
6717
|
+
return shouldRenderVariants();
|
|
6718
|
+
},
|
|
6719
|
+
get children() {
|
|
6720
|
+
return [createComponent(inlined_styles_default, {
|
|
6721
|
+
get nonce() {
|
|
6722
|
+
return props.builderContext?.nonce || "";
|
|
6723
|
+
},
|
|
6724
|
+
get styles() {
|
|
6725
|
+
return hideVariantsStyleString();
|
|
6726
|
+
},
|
|
6727
|
+
get id() {
|
|
6728
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
6729
|
+
}
|
|
6730
|
+
}), createComponent(inlined_script_default, {
|
|
6731
|
+
get nonce() {
|
|
6732
|
+
return props.builderContext?.nonce || "";
|
|
6733
|
+
},
|
|
6734
|
+
get scriptStr() {
|
|
6735
|
+
return updateVisibilityStylesScript();
|
|
6736
|
+
},
|
|
6737
|
+
get id() {
|
|
6738
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
6739
|
+
}
|
|
6740
|
+
}), createComponent(For, {
|
|
6741
|
+
get each() {
|
|
6742
|
+
return props.variants;
|
|
6743
|
+
},
|
|
6744
|
+
children: (variant, _index) => {
|
|
6745
|
+
const index = _index();
|
|
6746
|
+
return createComponent(blocks_default, {
|
|
6747
|
+
get key() {
|
|
6748
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
6749
|
+
},
|
|
6750
|
+
get BlocksWrapperProps() {
|
|
6751
|
+
return {
|
|
6752
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6753
|
+
"aria-hidden": true,
|
|
6754
|
+
hidden: true,
|
|
6755
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
6756
|
+
};
|
|
6757
|
+
},
|
|
6758
|
+
get blocks() {
|
|
6759
|
+
return variant.blocks;
|
|
6760
|
+
},
|
|
6761
|
+
get parent() {
|
|
6762
|
+
return props.builderBlock?.id;
|
|
6763
|
+
},
|
|
6764
|
+
path: `component.options.variants.${index}.blocks`,
|
|
6765
|
+
get context() {
|
|
6766
|
+
return props.builderContext;
|
|
6767
|
+
},
|
|
6768
|
+
get registeredComponents() {
|
|
6769
|
+
return props.builderComponents;
|
|
6770
|
+
},
|
|
6771
|
+
get children() {
|
|
6772
|
+
return createComponent(inlined_script_default, {
|
|
6773
|
+
get nonce() {
|
|
6774
|
+
return props.builderContext?.nonce || "";
|
|
6775
|
+
},
|
|
6776
|
+
get scriptStr() {
|
|
6777
|
+
return scriptStr();
|
|
6778
|
+
},
|
|
6779
|
+
get id() {
|
|
6780
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
6781
|
+
}
|
|
6782
|
+
});
|
|
6783
|
+
}
|
|
6784
|
+
});
|
|
6785
|
+
}
|
|
6786
|
+
})];
|
|
6787
|
+
}
|
|
6788
|
+
}), createComponent(blocks_default, {
|
|
6789
|
+
get blocks() {
|
|
6790
|
+
return blocksToRender().blocks;
|
|
6791
|
+
},
|
|
6792
|
+
get parent() {
|
|
6793
|
+
return props.builderBlock?.id;
|
|
6794
|
+
},
|
|
6795
|
+
get path() {
|
|
6796
|
+
return blocksToRender().path;
|
|
6797
|
+
},
|
|
6798
|
+
get context() {
|
|
6799
|
+
return props.builderContext;
|
|
6800
|
+
},
|
|
6801
|
+
get registeredComponents() {
|
|
6802
|
+
return props.builderComponents;
|
|
6803
|
+
},
|
|
6804
|
+
get BlocksWrapperProps() {
|
|
6805
|
+
return {
|
|
6806
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6807
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6808
|
+
};
|
|
6809
|
+
},
|
|
6810
|
+
get children() {
|
|
6811
|
+
return createComponent(Show, {
|
|
6812
|
+
get when() {
|
|
6813
|
+
return shouldRenderVariants();
|
|
6814
|
+
},
|
|
6815
|
+
get children() {
|
|
6816
|
+
return createComponent(inlined_script_default, {
|
|
6817
|
+
get nonce() {
|
|
6818
|
+
return props.builderContext?.nonce || "";
|
|
6819
|
+
},
|
|
6820
|
+
get scriptStr() {
|
|
6821
|
+
return scriptStr();
|
|
6822
|
+
},
|
|
6823
|
+
get id() {
|
|
6824
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
6825
|
+
}
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6828
|
+
});
|
|
6829
|
+
}
|
|
6830
|
+
})];
|
|
6762
6831
|
}
|
|
6763
6832
|
}), null);
|
|
6764
6833
|
return _el$;
|
|
@@ -7045,7 +7114,7 @@ var componentInfo10 = {
|
|
|
7045
7114
|
}
|
|
7046
7115
|
};
|
|
7047
7116
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
7048
|
-
var _tmpl$
|
|
7117
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
7049
7118
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
7050
7119
|
function Tabs(props) {
|
|
7051
7120
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -7060,7 +7129,7 @@ function Tabs(props) {
|
|
|
7060
7129
|
}
|
|
7061
7130
|
}
|
|
7062
7131
|
return (() => {
|
|
7063
|
-
const _el$ = _tmpl$
|
|
7132
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
7064
7133
|
_el$2.style.setProperty("display", "flex");
|
|
7065
7134
|
_el$2.style.setProperty("flex-direction", "row");
|
|
7066
7135
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -7592,7 +7661,7 @@ function logFetch(url) {
|
|
|
7592
7661
|
|
|
7593
7662
|
// src/blocks/form/form/form.tsx
|
|
7594
7663
|
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
|
|
7595
|
-
var _tmpl$
|
|
7664
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
7596
7665
|
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
|
|
7597
7666
|
padding: 10px;
|
|
7598
7667
|
color: red;
|
|
@@ -7785,7 +7854,7 @@ function FormComponent(props) {
|
|
|
7785
7854
|
}
|
|
7786
7855
|
let formRef;
|
|
7787
7856
|
return [(() => {
|
|
7788
|
-
const _el$ = _tmpl$
|
|
7857
|
+
const _el$ = _tmpl$26();
|
|
7789
7858
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
7790
7859
|
const _ref$ = formRef;
|
|
7791
7860
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -7997,7 +8066,7 @@ var componentInfo16 = {
|
|
|
7997
8066
|
noWrap: true
|
|
7998
8067
|
};
|
|
7999
8068
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
8000
|
-
var _tmpl$
|
|
8069
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
8001
8070
|
function SelectComponent(props) {
|
|
8002
8071
|
return (() => {
|
|
8003
8072
|
const _el$ = _tmpl$17();
|
|
@@ -8025,7 +8094,7 @@ function SelectComponent(props) {
|
|
|
8025
8094
|
children: (option, _index) => {
|
|
8026
8095
|
const index = _index();
|
|
8027
8096
|
return (() => {
|
|
8028
|
-
const _el$2 = _tmpl$
|
|
8097
|
+
const _el$2 = _tmpl$27();
|
|
8029
8098
|
insert(_el$2, () => option.name || option.value);
|
|
8030
8099
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
8031
8100
|
effect(() => _el$2.value = option.value);
|
|
@@ -8269,7 +8338,7 @@ var componentInfo20 = {
|
|
|
8269
8338
|
}
|
|
8270
8339
|
};
|
|
8271
8340
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
8272
|
-
var _tmpl$
|
|
8341
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
8273
8342
|
function Video(props) {
|
|
8274
8343
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
8275
8344
|
const videoProps = createMemo(() => {
|
|
@@ -8324,7 +8393,7 @@ function Video(props) {
|
|
|
8324
8393
|
}
|
|
8325
8394
|
});
|
|
8326
8395
|
return (() => {
|
|
8327
|
-
const _el$ = _tmpl$
|
|
8396
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
8328
8397
|
_el$.style.setProperty("position", "relative");
|
|
8329
8398
|
const _ref$ = videoRef;
|
|
8330
8399
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -8461,7 +8530,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
8461
8530
|
}, {
|
|
8462
8531
|
component: text_default,
|
|
8463
8532
|
...componentInfo11
|
|
8464
|
-
}, ...TARGET
|
|
8533
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
8465
8534
|
component: personalization_container_default,
|
|
8466
8535
|
...componentInfo6
|
|
8467
8536
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -8498,7 +8567,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
8498
8567
|
|
|
8499
8568
|
// src/components/content-variants/helpers.ts
|
|
8500
8569
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
8501
|
-
var
|
|
8570
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
8502
8571
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
8503
8572
|
...variant,
|
|
8504
8573
|
testVariationId: variant.id,
|
|
@@ -8523,20 +8592,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
8523
8592
|
};
|
|
8524
8593
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8525
8594
|
var isAngularSDK = TARGET === "angular";
|
|
8526
|
-
var
|
|
8595
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
8527
8596
|
var getInitVariantsFnsScriptString = () => `
|
|
8528
8597
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
8529
|
-
window.${
|
|
8598
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
8530
8599
|
`;
|
|
8531
8600
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
8532
8601
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
8533
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
8602
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
8534
8603
|
)`;
|
|
8535
8604
|
var getUpdateVariantVisibilityScript = ({
|
|
8536
8605
|
contentId,
|
|
8537
8606
|
variationId
|
|
8538
|
-
}) => `window.${
|
|
8539
|
-
"${variationId}", "${contentId}", ${
|
|
8607
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
8608
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
8540
8609
|
)`;
|
|
8541
8610
|
|
|
8542
8611
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -8545,7 +8614,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8545
8614
|
}
|
|
8546
8615
|
|
|
8547
8616
|
// src/constants/sdk-version.ts
|
|
8548
|
-
var SDK_VERSION = "4.0.
|
|
8617
|
+
var SDK_VERSION = "4.0.9";
|
|
8549
8618
|
|
|
8550
8619
|
// src/helpers/sdk-headers.ts
|
|
8551
8620
|
var getSdkHeaders = () => ({
|
|
@@ -9961,7 +10030,7 @@ function ContentVariants(props) {
|
|
|
9961
10030
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
9962
10031
|
},
|
|
9963
10032
|
get children() {
|
|
9964
|
-
return createComponent(inlined_script_default, {
|
|
10033
|
+
return [createComponent(inlined_script_default, {
|
|
9965
10034
|
id: "builderio-init-variants-fns",
|
|
9966
10035
|
get scriptStr() {
|
|
9967
10036
|
return getInitVariantsFnsScriptString();
|
|
@@ -9969,7 +10038,22 @@ function ContentVariants(props) {
|
|
|
9969
10038
|
get nonce() {
|
|
9970
10039
|
return props.nonce || "";
|
|
9971
10040
|
}
|
|
9972
|
-
})
|
|
10041
|
+
}), createComponent(Show, {
|
|
10042
|
+
get when() {
|
|
10043
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
10044
|
+
},
|
|
10045
|
+
get children() {
|
|
10046
|
+
return createComponent(inlined_script_default, {
|
|
10047
|
+
id: "builderio-init-personalization-variants-fns",
|
|
10048
|
+
get nonce() {
|
|
10049
|
+
return props.nonce || "";
|
|
10050
|
+
},
|
|
10051
|
+
get scriptStr() {
|
|
10052
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
10053
|
+
}
|
|
10054
|
+
});
|
|
10055
|
+
}
|
|
10056
|
+
})];
|
|
9973
10057
|
}
|
|
9974
10058
|
}), createComponent(Show, {
|
|
9975
10059
|
get when() {
|
|
@@ -10157,9 +10241,10 @@ var fetchSymbolContent = async ({
|
|
|
10157
10241
|
};
|
|
10158
10242
|
|
|
10159
10243
|
// src/blocks/symbol/symbol.tsx
|
|
10160
|
-
var _tmpl$
|
|
10244
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
10161
10245
|
function Symbol2(props) {
|
|
10162
10246
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
10247
|
+
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
10163
10248
|
const blocksWrapper = createMemo(() => {
|
|
10164
10249
|
return "div";
|
|
10165
10250
|
});
|
|
@@ -10170,7 +10255,7 @@ function Symbol2(props) {
|
|
|
10170
10255
|
return [...[props.attributes[getClassPropName()]], "builder-symbol", props.symbol?.inline ? "builder-inline-symbol" : void 0, props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0].filter(Boolean).join(" ");
|
|
10171
10256
|
});
|
|
10172
10257
|
function setContent() {
|
|
10173
|
-
if (contentToUse())
|
|
10258
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
10174
10259
|
return;
|
|
10175
10260
|
fetchSymbolContent({
|
|
10176
10261
|
symbol: props.symbol,
|
|
@@ -10178,6 +10263,7 @@ function Symbol2(props) {
|
|
|
10178
10263
|
}).then((newContent) => {
|
|
10179
10264
|
if (newContent) {
|
|
10180
10265
|
setContentToUse(newContent);
|
|
10266
|
+
setSymbolEntry(props.symbol?.entry);
|
|
10181
10267
|
}
|
|
10182
10268
|
});
|
|
10183
10269
|
}
|
|
@@ -10189,7 +10275,7 @@ function Symbol2(props) {
|
|
|
10189
10275
|
}
|
|
10190
10276
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
10191
10277
|
return (() => {
|
|
10192
|
-
const _el$ = _tmpl$
|
|
10278
|
+
const _el$ = _tmpl$29();
|
|
10193
10279
|
spread(_el$, mergeProps({
|
|
10194
10280
|
get ["class"]() {
|
|
10195
10281
|
return className();
|