@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/browser/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
|
// src/blocks/button/button.tsx
|
|
@@ -1209,6 +1209,7 @@ var awaiter_default = Awaiter;
|
|
|
1209
1209
|
|
|
1210
1210
|
// src/components/block/components/interactive-element.tsx
|
|
1211
1211
|
function InteractiveElement(props) {
|
|
1212
|
+
createSignal(0);
|
|
1212
1213
|
const attributes = createMemo(() => {
|
|
1213
1214
|
return props.includeBlockProps ? {
|
|
1214
1215
|
...getBlockProperties({
|
|
@@ -1227,6 +1228,11 @@ function InteractiveElement(props) {
|
|
|
1227
1228
|
const targetWrapperProps = createMemo(() => {
|
|
1228
1229
|
return props.wrapperProps;
|
|
1229
1230
|
});
|
|
1231
|
+
const onUpdateFn_0_props_wrapperProps = createMemo(() => props.wrapperProps);
|
|
1232
|
+
const onUpdateFn_0_props_block__component__options = createMemo(() => props.block?.component?.options);
|
|
1233
|
+
function onUpdateFn_0() {
|
|
1234
|
+
}
|
|
1235
|
+
createEffect(on(() => [onUpdateFn_0_props_wrapperProps(), onUpdateFn_0_props_block__component__options()], onUpdateFn_0));
|
|
1230
1236
|
return createComponent(Show, {
|
|
1231
1237
|
get fallback() {
|
|
1232
1238
|
return createComponent(Dynamic, mergeProps(targetWrapperProps, {
|
|
@@ -1653,7 +1659,7 @@ function Block(props) {
|
|
|
1653
1659
|
});
|
|
1654
1660
|
}
|
|
1655
1661
|
var block_default = Block;
|
|
1656
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1662
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1657
1663
|
display: flex;
|
|
1658
1664
|
flex-direction: column;
|
|
1659
1665
|
align-items: stretch;
|
|
@@ -1702,7 +1708,7 @@ function BlocksWrapper(props) {
|
|
|
1702
1708
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1703
1709
|
return [createComponent(Dynamic, mergeProps({
|
|
1704
1710
|
get ["class"]() {
|
|
1705
|
-
return className() + " dynamic-
|
|
1711
|
+
return className() + " dynamic-450facf4";
|
|
1706
1712
|
},
|
|
1707
1713
|
ref(r$) {
|
|
1708
1714
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1749,17 +1755,17 @@ function Blocks(props) {
|
|
|
1749
1755
|
get styleProp() {
|
|
1750
1756
|
return props.styleProp;
|
|
1751
1757
|
},
|
|
1758
|
+
get BlocksWrapperProps() {
|
|
1759
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1760
|
+
},
|
|
1752
1761
|
get classNameProp() {
|
|
1753
1762
|
return props.className;
|
|
1754
1763
|
},
|
|
1755
1764
|
get BlocksWrapper() {
|
|
1756
1765
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1757
1766
|
},
|
|
1758
|
-
get BlocksWrapperProps() {
|
|
1759
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1760
|
-
},
|
|
1761
1767
|
get children() {
|
|
1762
|
-
return createComponent(Show, {
|
|
1768
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1763
1769
|
get when() {
|
|
1764
1770
|
return props.blocks;
|
|
1765
1771
|
},
|
|
@@ -1788,7 +1794,7 @@ function Blocks(props) {
|
|
|
1788
1794
|
}
|
|
1789
1795
|
});
|
|
1790
1796
|
}
|
|
1791
|
-
});
|
|
1797
|
+
})];
|
|
1792
1798
|
}
|
|
1793
1799
|
});
|
|
1794
1800
|
}
|
|
@@ -2212,6 +2218,166 @@ function SectionComponent(props) {
|
|
|
2212
2218
|
}
|
|
2213
2219
|
var section_default = SectionComponent;
|
|
2214
2220
|
|
|
2221
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2222
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2223
|
+
function isString(val) {
|
|
2224
|
+
return typeof val === "string";
|
|
2225
|
+
}
|
|
2226
|
+
function isNumber(val) {
|
|
2227
|
+
return typeof val === "number";
|
|
2228
|
+
}
|
|
2229
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2230
|
+
const result = (() => {
|
|
2231
|
+
const property = query2.property;
|
|
2232
|
+
const operator = query2.operator;
|
|
2233
|
+
let testValue = query2.value;
|
|
2234
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2235
|
+
testValue = query2.value.slice(0, -1);
|
|
2236
|
+
}
|
|
2237
|
+
if (!(property && operator)) {
|
|
2238
|
+
return true;
|
|
2239
|
+
}
|
|
2240
|
+
if (Array.isArray(testValue)) {
|
|
2241
|
+
if (operator === "isNot") {
|
|
2242
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2243
|
+
property,
|
|
2244
|
+
operator,
|
|
2245
|
+
value: val
|
|
2246
|
+
}));
|
|
2247
|
+
}
|
|
2248
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2249
|
+
property,
|
|
2250
|
+
operator,
|
|
2251
|
+
value: val
|
|
2252
|
+
}));
|
|
2253
|
+
}
|
|
2254
|
+
const value = userattr[property];
|
|
2255
|
+
if (Array.isArray(value)) {
|
|
2256
|
+
return value.includes(testValue);
|
|
2257
|
+
}
|
|
2258
|
+
switch (operator) {
|
|
2259
|
+
case "is":
|
|
2260
|
+
return value === testValue;
|
|
2261
|
+
case "isNot":
|
|
2262
|
+
return value !== testValue;
|
|
2263
|
+
case "contains":
|
|
2264
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2265
|
+
case "startsWith":
|
|
2266
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2267
|
+
case "endsWith":
|
|
2268
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2269
|
+
case "greaterThan":
|
|
2270
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2271
|
+
case "lessThan":
|
|
2272
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2273
|
+
case "greaterThanOrEqualTo":
|
|
2274
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2275
|
+
case "lessThanOrEqualTo":
|
|
2276
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2277
|
+
default:
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
})();
|
|
2281
|
+
return result;
|
|
2282
|
+
}
|
|
2283
|
+
const item = {
|
|
2284
|
+
query,
|
|
2285
|
+
startDate,
|
|
2286
|
+
endDate
|
|
2287
|
+
};
|
|
2288
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2289
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2290
|
+
return false;
|
|
2291
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
2294
|
+
if (!item.query || !item.query.length) {
|
|
2295
|
+
return true;
|
|
2296
|
+
}
|
|
2297
|
+
return item.query.every((filter) => {
|
|
2298
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
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}";
|
|
2302
|
+
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}";
|
|
2303
|
+
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}";
|
|
2304
|
+
|
|
2305
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2306
|
+
var DEFAULT_INDEX = "default";
|
|
2307
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2308
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2309
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2310
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2311
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2312
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2313
|
+
const hasVariants = variants && variants.length > 0;
|
|
2314
|
+
if (TARGET === "reactNative")
|
|
2315
|
+
return false;
|
|
2316
|
+
if (!hasVariants)
|
|
2317
|
+
return false;
|
|
2318
|
+
if (!canTrack)
|
|
2319
|
+
return false;
|
|
2320
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2321
|
+
return true;
|
|
2322
|
+
if (isBrowser())
|
|
2323
|
+
return false;
|
|
2324
|
+
return true;
|
|
2325
|
+
}
|
|
2326
|
+
function getBlocksToRender({
|
|
2327
|
+
variants,
|
|
2328
|
+
previewingIndex,
|
|
2329
|
+
isHydrated,
|
|
2330
|
+
filteredVariants,
|
|
2331
|
+
fallbackBlocks
|
|
2332
|
+
}) {
|
|
2333
|
+
const fallback = {
|
|
2334
|
+
blocks: fallbackBlocks ?? [],
|
|
2335
|
+
path: "this.children",
|
|
2336
|
+
index: DEFAULT_INDEX
|
|
2337
|
+
};
|
|
2338
|
+
if (isHydrated && isEditing()) {
|
|
2339
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2340
|
+
const variant = variants?.[previewingIndex];
|
|
2341
|
+
if (variant) {
|
|
2342
|
+
return {
|
|
2343
|
+
blocks: variant.blocks,
|
|
2344
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2345
|
+
index: previewingIndex
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
return fallback;
|
|
2350
|
+
}
|
|
2351
|
+
if (isBrowser()) {
|
|
2352
|
+
const winningVariant = filteredVariants?.[0];
|
|
2353
|
+
if (winningVariant && variants) {
|
|
2354
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2355
|
+
if (variantIndex !== -1) {
|
|
2356
|
+
return {
|
|
2357
|
+
blocks: winningVariant.blocks,
|
|
2358
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2359
|
+
index: variantIndex
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
return fallback;
|
|
2365
|
+
}
|
|
2366
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2367
|
+
return `
|
|
2368
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2369
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2370
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2371
|
+
`;
|
|
2372
|
+
};
|
|
2373
|
+
var isHydrationTarget = TARGET === "react";
|
|
2374
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2375
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2376
|
+
};
|
|
2377
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2378
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2379
|
+
};
|
|
2380
|
+
|
|
2215
2381
|
// src/helpers/url.ts
|
|
2216
2382
|
var getTopLevelDomain = (host) => {
|
|
2217
2383
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -3190,7 +3356,8 @@ var componentInfo6 = {
|
|
|
3190
3356
|
name: "PersonalizationContainer",
|
|
3191
3357
|
shouldReceiveBuilderProps: {
|
|
3192
3358
|
builderBlock: true,
|
|
3193
|
-
builderContext: true
|
|
3359
|
+
builderContext: true,
|
|
3360
|
+
builderComponents: true
|
|
3194
3361
|
},
|
|
3195
3362
|
noWrap: true,
|
|
3196
3363
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3252,208 +3419,22 @@ function isPreviewing(_search) {
|
|
|
3252
3419
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3253
3420
|
}
|
|
3254
3421
|
|
|
3255
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3256
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3257
|
-
function isString(val) {
|
|
3258
|
-
return typeof val === "string";
|
|
3259
|
-
}
|
|
3260
|
-
function isNumber(val) {
|
|
3261
|
-
return typeof val === "number";
|
|
3262
|
-
}
|
|
3263
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3264
|
-
const result = (() => {
|
|
3265
|
-
const property = query2.property;
|
|
3266
|
-
const operator = query2.operator;
|
|
3267
|
-
let testValue = query2.value;
|
|
3268
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3269
|
-
testValue = query2.value.slice(0, -1);
|
|
3270
|
-
}
|
|
3271
|
-
if (!(property && operator)) {
|
|
3272
|
-
return true;
|
|
3273
|
-
}
|
|
3274
|
-
if (Array.isArray(testValue)) {
|
|
3275
|
-
if (operator === "isNot") {
|
|
3276
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3277
|
-
property,
|
|
3278
|
-
operator,
|
|
3279
|
-
value: val
|
|
3280
|
-
}));
|
|
3281
|
-
}
|
|
3282
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3283
|
-
property,
|
|
3284
|
-
operator,
|
|
3285
|
-
value: val
|
|
3286
|
-
}));
|
|
3287
|
-
}
|
|
3288
|
-
const value = userattr[property];
|
|
3289
|
-
if (Array.isArray(value)) {
|
|
3290
|
-
return value.includes(testValue);
|
|
3291
|
-
}
|
|
3292
|
-
switch (operator) {
|
|
3293
|
-
case "is":
|
|
3294
|
-
return value === testValue;
|
|
3295
|
-
case "isNot":
|
|
3296
|
-
return value !== testValue;
|
|
3297
|
-
case "contains":
|
|
3298
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3299
|
-
case "startsWith":
|
|
3300
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3301
|
-
case "endsWith":
|
|
3302
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3303
|
-
case "greaterThan":
|
|
3304
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3305
|
-
case "lessThan":
|
|
3306
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3307
|
-
case "greaterThanOrEqualTo":
|
|
3308
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3309
|
-
case "lessThanOrEqualTo":
|
|
3310
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3311
|
-
default:
|
|
3312
|
-
return false;
|
|
3313
|
-
}
|
|
3314
|
-
})();
|
|
3315
|
-
return result;
|
|
3316
|
-
}
|
|
3317
|
-
const item = {
|
|
3318
|
-
query,
|
|
3319
|
-
startDate,
|
|
3320
|
-
endDate
|
|
3321
|
-
};
|
|
3322
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3323
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3324
|
-
return false;
|
|
3325
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3326
|
-
return false;
|
|
3327
|
-
}
|
|
3328
|
-
if (!item.query || !item.query.length) {
|
|
3329
|
-
return true;
|
|
3330
|
-
}
|
|
3331
|
-
return item.query.every((filter) => {
|
|
3332
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3335
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3336
|
-
if (!navigator.cookieEnabled) {
|
|
3337
|
-
return;
|
|
3338
|
-
}
|
|
3339
|
-
function getCookie(name) {
|
|
3340
|
-
const nameEQ = name + '=';
|
|
3341
|
-
const ca = document.cookie.split(';');
|
|
3342
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3343
|
-
let c = ca[i];
|
|
3344
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3345
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3346
|
-
}
|
|
3347
|
-
return null;
|
|
3348
|
-
}
|
|
3349
|
-
function removeVariants() {
|
|
3350
|
-
variants?.forEach(function (_, index) {
|
|
3351
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3352
|
-
});
|
|
3353
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3354
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3355
|
-
}
|
|
3356
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3357
|
-
if (locale) {
|
|
3358
|
-
attributes.locale = locale;
|
|
3359
|
-
}
|
|
3360
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3361
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3362
|
-
});
|
|
3363
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3364
|
-
if (isDebug) {
|
|
3365
|
-
console.debug('PersonalizationContainer', {
|
|
3366
|
-
attributes,
|
|
3367
|
-
variants,
|
|
3368
|
-
winningVariantIndex
|
|
3369
|
-
});
|
|
3370
|
-
}
|
|
3371
|
-
if (winningVariantIndex !== -1) {
|
|
3372
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3373
|
-
if (winningVariant) {
|
|
3374
|
-
const parentNode = winningVariant.parentNode;
|
|
3375
|
-
if (parentNode) {
|
|
3376
|
-
const newParent = parentNode.cloneNode(false);
|
|
3377
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3378
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3379
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3380
|
-
}
|
|
3381
|
-
if (isDebug) {
|
|
3382
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
} else if (variants && variants.length > 0) {
|
|
3386
|
-
removeVariants();
|
|
3387
|
-
}
|
|
3388
|
-
}`;
|
|
3389
|
-
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}";
|
|
3390
|
-
|
|
3391
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3392
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3393
|
-
const hasVariants = variants && variants.length > 0;
|
|
3394
|
-
if (TARGET === "reactNative")
|
|
3395
|
-
return false;
|
|
3396
|
-
if (!hasVariants)
|
|
3397
|
-
return false;
|
|
3398
|
-
if (!canTrack)
|
|
3399
|
-
return false;
|
|
3400
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3401
|
-
return true;
|
|
3402
|
-
if (isBrowser())
|
|
3403
|
-
return false;
|
|
3404
|
-
return true;
|
|
3405
|
-
}
|
|
3406
|
-
function getBlocksToRender({
|
|
3407
|
-
variants,
|
|
3408
|
-
previewingIndex,
|
|
3409
|
-
isHydrated,
|
|
3410
|
-
filteredVariants,
|
|
3411
|
-
fallbackBlocks
|
|
3412
|
-
}) {
|
|
3413
|
-
const fallback = {
|
|
3414
|
-
blocks: fallbackBlocks ?? [],
|
|
3415
|
-
path: "this.children"
|
|
3416
|
-
};
|
|
3417
|
-
if (isHydrated && isEditing()) {
|
|
3418
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3419
|
-
const variant = variants[previewingIndex];
|
|
3420
|
-
return {
|
|
3421
|
-
blocks: variant.blocks,
|
|
3422
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3423
|
-
};
|
|
3424
|
-
}
|
|
3425
|
-
return fallback;
|
|
3426
|
-
}
|
|
3427
|
-
if (isBrowser()) {
|
|
3428
|
-
const winningVariant = filteredVariants?.[0];
|
|
3429
|
-
if (winningVariant) {
|
|
3430
|
-
return {
|
|
3431
|
-
blocks: winningVariant.blocks,
|
|
3432
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3433
|
-
};
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
return fallback;
|
|
3437
|
-
}
|
|
3438
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3439
|
-
return `
|
|
3440
|
-
(function() {
|
|
3441
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3442
|
-
${PERSONALIZATION_SCRIPT}
|
|
3443
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3444
|
-
})();
|
|
3445
|
-
`;
|
|
3446
|
-
};
|
|
3447
|
-
|
|
3448
3422
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3449
3423
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3450
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3451
3424
|
function PersonalizationContainer(props) {
|
|
3452
3425
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3453
3426
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3427
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3454
3428
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3455
3429
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3456
|
-
const [
|
|
3430
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3431
|
+
const attrs = createMemo(() => {
|
|
3432
|
+
return {
|
|
3433
|
+
...props.attributes,
|
|
3434
|
+
...{},
|
|
3435
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3436
|
+
};
|
|
3437
|
+
});
|
|
3457
3438
|
const filteredVariants = createMemo(() => {
|
|
3458
3439
|
return (props.variants || []).filter((variant) => {
|
|
3459
3440
|
return filterWithCustomTargeting({
|
|
@@ -3468,26 +3449,26 @@ function PersonalizationContainer(props) {
|
|
|
3468
3449
|
return getBlocksToRender({
|
|
3469
3450
|
variants: props.variants,
|
|
3470
3451
|
fallbackBlocks: props.builderBlock?.children,
|
|
3471
|
-
isHydrated:
|
|
3452
|
+
isHydrated: shouldResetVariants(),
|
|
3472
3453
|
filteredVariants: filteredVariants(),
|
|
3473
3454
|
previewingIndex: props.previewingIndex
|
|
3474
3455
|
});
|
|
3475
3456
|
});
|
|
3476
3457
|
const hideVariantsStyleString = createMemo(() => {
|
|
3477
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3458
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3478
3459
|
});
|
|
3479
3460
|
let rootRef;
|
|
3480
3461
|
onMount(() => {
|
|
3481
|
-
|
|
3482
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3483
|
-
setUserAttributes(
|
|
3462
|
+
setShouldResetVariants(true);
|
|
3463
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3464
|
+
setUserAttributes(attrs2);
|
|
3484
3465
|
});
|
|
3485
3466
|
if (!(isEditing() || isPreviewing())) {
|
|
3486
3467
|
const variant = filteredVariants()[0];
|
|
3487
3468
|
if (rootRef) {
|
|
3488
3469
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3489
3470
|
detail: {
|
|
3490
|
-
variant: variant ||
|
|
3471
|
+
variant: variant || DEFAULT_INDEX,
|
|
3491
3472
|
content: props.builderContext?.content
|
|
3492
3473
|
},
|
|
3493
3474
|
bubbles: true
|
|
@@ -3497,7 +3478,7 @@ function PersonalizationContainer(props) {
|
|
|
3497
3478
|
if (entry.isIntersecting && rootRef) {
|
|
3498
3479
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3499
3480
|
detail: {
|
|
3500
|
-
variant: variant ||
|
|
3481
|
+
variant: variant || DEFAULT_INDEX,
|
|
3501
3482
|
content: props.builderContext?.content
|
|
3502
3483
|
},
|
|
3503
3484
|
bubbles: true
|
|
@@ -3514,70 +3495,158 @@ function PersonalizationContainer(props) {
|
|
|
3514
3495
|
const _el$ = _tmpl$9();
|
|
3515
3496
|
const _ref$ = rootRef;
|
|
3516
3497
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3517
|
-
spread(_el$, mergeProps(
|
|
3518
|
-
get ["class"]() {
|
|
3519
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3520
|
-
}
|
|
3521
|
-
}, () => props.attributes), false, true);
|
|
3498
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3522
3499
|
insert(_el$, createComponent(Show, {
|
|
3523
3500
|
get when() {
|
|
3524
|
-
return
|
|
3501
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3525
3502
|
},
|
|
3526
3503
|
get children() {
|
|
3527
|
-
return
|
|
3528
|
-
get
|
|
3529
|
-
return
|
|
3504
|
+
return createComponent(blocks_default, {
|
|
3505
|
+
get blocks() {
|
|
3506
|
+
return blocksToRender().blocks;
|
|
3530
3507
|
},
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
return (() => {
|
|
3534
|
-
const _el$2 = _tmpl$25();
|
|
3535
|
-
setAttribute(_el$2, "key", index);
|
|
3536
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3537
|
-
get blocks() {
|
|
3538
|
-
return variant.blocks;
|
|
3539
|
-
},
|
|
3540
|
-
get parent() {
|
|
3541
|
-
return props.builderBlock?.id;
|
|
3542
|
-
},
|
|
3543
|
-
path: `component.options.variants.${index}.blocks`
|
|
3544
|
-
}));
|
|
3545
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3546
|
-
return _el$2;
|
|
3547
|
-
})();
|
|
3548
|
-
}
|
|
3549
|
-
}), createComponent(inlined_styles_default, {
|
|
3550
|
-
get nonce() {
|
|
3551
|
-
return props.builderContext?.nonce || "";
|
|
3508
|
+
get parent() {
|
|
3509
|
+
return props.builderBlock?.id;
|
|
3552
3510
|
},
|
|
3553
|
-
get
|
|
3554
|
-
return
|
|
3511
|
+
get path() {
|
|
3512
|
+
return blocksToRender().path;
|
|
3555
3513
|
},
|
|
3556
|
-
get
|
|
3557
|
-
return
|
|
3558
|
-
}
|
|
3559
|
-
}), createComponent(inlined_script_default, {
|
|
3560
|
-
get nonce() {
|
|
3561
|
-
return props.builderContext?.nonce || "";
|
|
3514
|
+
get context() {
|
|
3515
|
+
return props.builderContext;
|
|
3562
3516
|
},
|
|
3563
|
-
get
|
|
3564
|
-
return
|
|
3517
|
+
get registeredComponents() {
|
|
3518
|
+
return props.builderComponents;
|
|
3565
3519
|
},
|
|
3566
|
-
get
|
|
3567
|
-
return
|
|
3520
|
+
get BlocksWrapperProps() {
|
|
3521
|
+
return {
|
|
3522
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3523
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3524
|
+
};
|
|
3568
3525
|
}
|
|
3569
|
-
})
|
|
3526
|
+
});
|
|
3570
3527
|
}
|
|
3571
3528
|
}), null);
|
|
3572
|
-
insert(_el$, createComponent(
|
|
3573
|
-
get
|
|
3574
|
-
return
|
|
3575
|
-
},
|
|
3576
|
-
get parent() {
|
|
3577
|
-
return props.builderBlock?.id;
|
|
3529
|
+
insert(_el$, createComponent(Show, {
|
|
3530
|
+
get when() {
|
|
3531
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3578
3532
|
},
|
|
3579
|
-
get
|
|
3580
|
-
return
|
|
3533
|
+
get children() {
|
|
3534
|
+
return [createComponent(Show, {
|
|
3535
|
+
get when() {
|
|
3536
|
+
return shouldRenderVariants();
|
|
3537
|
+
},
|
|
3538
|
+
get children() {
|
|
3539
|
+
return [createComponent(inlined_styles_default, {
|
|
3540
|
+
get nonce() {
|
|
3541
|
+
return props.builderContext?.nonce || "";
|
|
3542
|
+
},
|
|
3543
|
+
get styles() {
|
|
3544
|
+
return hideVariantsStyleString();
|
|
3545
|
+
},
|
|
3546
|
+
get id() {
|
|
3547
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3548
|
+
}
|
|
3549
|
+
}), createComponent(inlined_script_default, {
|
|
3550
|
+
get nonce() {
|
|
3551
|
+
return props.builderContext?.nonce || "";
|
|
3552
|
+
},
|
|
3553
|
+
get scriptStr() {
|
|
3554
|
+
return updateVisibilityStylesScript();
|
|
3555
|
+
},
|
|
3556
|
+
get id() {
|
|
3557
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3558
|
+
}
|
|
3559
|
+
}), createComponent(For, {
|
|
3560
|
+
get each() {
|
|
3561
|
+
return props.variants;
|
|
3562
|
+
},
|
|
3563
|
+
children: (variant, _index) => {
|
|
3564
|
+
const index = _index();
|
|
3565
|
+
return createComponent(blocks_default, {
|
|
3566
|
+
get key() {
|
|
3567
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3568
|
+
},
|
|
3569
|
+
get BlocksWrapperProps() {
|
|
3570
|
+
return {
|
|
3571
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3572
|
+
"aria-hidden": true,
|
|
3573
|
+
hidden: true,
|
|
3574
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3575
|
+
};
|
|
3576
|
+
},
|
|
3577
|
+
get blocks() {
|
|
3578
|
+
return variant.blocks;
|
|
3579
|
+
},
|
|
3580
|
+
get parent() {
|
|
3581
|
+
return props.builderBlock?.id;
|
|
3582
|
+
},
|
|
3583
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3584
|
+
get context() {
|
|
3585
|
+
return props.builderContext;
|
|
3586
|
+
},
|
|
3587
|
+
get registeredComponents() {
|
|
3588
|
+
return props.builderComponents;
|
|
3589
|
+
},
|
|
3590
|
+
get children() {
|
|
3591
|
+
return createComponent(inlined_script_default, {
|
|
3592
|
+
get nonce() {
|
|
3593
|
+
return props.builderContext?.nonce || "";
|
|
3594
|
+
},
|
|
3595
|
+
get scriptStr() {
|
|
3596
|
+
return scriptStr();
|
|
3597
|
+
},
|
|
3598
|
+
get id() {
|
|
3599
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
})];
|
|
3606
|
+
}
|
|
3607
|
+
}), createComponent(blocks_default, {
|
|
3608
|
+
get blocks() {
|
|
3609
|
+
return blocksToRender().blocks;
|
|
3610
|
+
},
|
|
3611
|
+
get parent() {
|
|
3612
|
+
return props.builderBlock?.id;
|
|
3613
|
+
},
|
|
3614
|
+
get path() {
|
|
3615
|
+
return blocksToRender().path;
|
|
3616
|
+
},
|
|
3617
|
+
get context() {
|
|
3618
|
+
return props.builderContext;
|
|
3619
|
+
},
|
|
3620
|
+
get registeredComponents() {
|
|
3621
|
+
return props.builderComponents;
|
|
3622
|
+
},
|
|
3623
|
+
get BlocksWrapperProps() {
|
|
3624
|
+
return {
|
|
3625
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3626
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3627
|
+
};
|
|
3628
|
+
},
|
|
3629
|
+
get children() {
|
|
3630
|
+
return createComponent(Show, {
|
|
3631
|
+
get when() {
|
|
3632
|
+
return shouldRenderVariants();
|
|
3633
|
+
},
|
|
3634
|
+
get children() {
|
|
3635
|
+
return createComponent(inlined_script_default, {
|
|
3636
|
+
get nonce() {
|
|
3637
|
+
return props.builderContext?.nonce || "";
|
|
3638
|
+
},
|
|
3639
|
+
get scriptStr() {
|
|
3640
|
+
return scriptStr();
|
|
3641
|
+
},
|
|
3642
|
+
get id() {
|
|
3643
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3644
|
+
}
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
})];
|
|
3581
3650
|
}
|
|
3582
3651
|
}), null);
|
|
3583
3652
|
return _el$;
|
|
@@ -3864,7 +3933,7 @@ var componentInfo10 = {
|
|
|
3864
3933
|
}
|
|
3865
3934
|
};
|
|
3866
3935
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
3867
|
-
var _tmpl$
|
|
3936
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
3868
3937
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
3869
3938
|
function Tabs(props) {
|
|
3870
3939
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -3879,7 +3948,7 @@ function Tabs(props) {
|
|
|
3879
3948
|
}
|
|
3880
3949
|
}
|
|
3881
3950
|
return (() => {
|
|
3882
|
-
const _el$ = _tmpl$
|
|
3951
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
3883
3952
|
_el$2.style.setProperty("display", "flex");
|
|
3884
3953
|
_el$2.style.setProperty("flex-direction", "row");
|
|
3885
3954
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4411,7 +4480,7 @@ function logFetch(url) {
|
|
|
4411
4480
|
|
|
4412
4481
|
// src/blocks/form/form/form.tsx
|
|
4413
4482
|
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
|
|
4414
|
-
var _tmpl$
|
|
4483
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4415
4484
|
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
|
|
4416
4485
|
padding: 10px;
|
|
4417
4486
|
color: red;
|
|
@@ -4604,7 +4673,7 @@ function FormComponent(props) {
|
|
|
4604
4673
|
}
|
|
4605
4674
|
let formRef;
|
|
4606
4675
|
return [(() => {
|
|
4607
|
-
const _el$ = _tmpl$
|
|
4676
|
+
const _el$ = _tmpl$26();
|
|
4608
4677
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4609
4678
|
const _ref$ = formRef;
|
|
4610
4679
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4816,7 +4885,7 @@ var componentInfo16 = {
|
|
|
4816
4885
|
noWrap: true
|
|
4817
4886
|
};
|
|
4818
4887
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4819
|
-
var _tmpl$
|
|
4888
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
4820
4889
|
function SelectComponent(props) {
|
|
4821
4890
|
return (() => {
|
|
4822
4891
|
const _el$ = _tmpl$17();
|
|
@@ -4844,7 +4913,7 @@ function SelectComponent(props) {
|
|
|
4844
4913
|
children: (option, _index) => {
|
|
4845
4914
|
const index = _index();
|
|
4846
4915
|
return (() => {
|
|
4847
|
-
const _el$2 = _tmpl$
|
|
4916
|
+
const _el$2 = _tmpl$27();
|
|
4848
4917
|
insert(_el$2, () => option.name || option.value);
|
|
4849
4918
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
4850
4919
|
effect(() => _el$2.value = option.value);
|
|
@@ -5088,7 +5157,7 @@ var componentInfo20 = {
|
|
|
5088
5157
|
}
|
|
5089
5158
|
};
|
|
5090
5159
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5091
|
-
var _tmpl$
|
|
5160
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5092
5161
|
function Video(props) {
|
|
5093
5162
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5094
5163
|
const videoProps = createMemo(() => {
|
|
@@ -5143,7 +5212,7 @@ function Video(props) {
|
|
|
5143
5212
|
}
|
|
5144
5213
|
});
|
|
5145
5214
|
return (() => {
|
|
5146
|
-
const _el$ = _tmpl$
|
|
5215
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5147
5216
|
_el$.style.setProperty("position", "relative");
|
|
5148
5217
|
const _ref$ = videoRef;
|
|
5149
5218
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5280,7 +5349,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5280
5349
|
}, {
|
|
5281
5350
|
component: text_default,
|
|
5282
5351
|
...componentInfo11
|
|
5283
|
-
}, ...TARGET
|
|
5352
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5284
5353
|
component: personalization_container_default,
|
|
5285
5354
|
...componentInfo6
|
|
5286
5355
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5317,7 +5386,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5317
5386
|
|
|
5318
5387
|
// src/components/content-variants/helpers.ts
|
|
5319
5388
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5320
|
-
var
|
|
5389
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5321
5390
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5322
5391
|
...variant,
|
|
5323
5392
|
testVariationId: variant.id,
|
|
@@ -5342,20 +5411,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5342
5411
|
};
|
|
5343
5412
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5344
5413
|
var isAngularSDK = TARGET === "angular";
|
|
5345
|
-
var
|
|
5414
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5346
5415
|
var getInitVariantsFnsScriptString = () => `
|
|
5347
5416
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5348
|
-
window.${
|
|
5417
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5349
5418
|
`;
|
|
5350
5419
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5351
5420
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5352
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5421
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5353
5422
|
)`;
|
|
5354
5423
|
var getUpdateVariantVisibilityScript = ({
|
|
5355
5424
|
contentId,
|
|
5356
5425
|
variationId
|
|
5357
|
-
}) => `window.${
|
|
5358
|
-
"${variationId}", "${contentId}", ${
|
|
5426
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5427
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5359
5428
|
)`;
|
|
5360
5429
|
|
|
5361
5430
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5364,7 +5433,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5364
5433
|
}
|
|
5365
5434
|
|
|
5366
5435
|
// src/constants/sdk-version.ts
|
|
5367
|
-
var SDK_VERSION = "4.0.
|
|
5436
|
+
var SDK_VERSION = "4.0.9";
|
|
5368
5437
|
|
|
5369
5438
|
// src/helpers/sdk-headers.ts
|
|
5370
5439
|
var getSdkHeaders = () => ({
|
|
@@ -6780,7 +6849,7 @@ function ContentVariants(props) {
|
|
|
6780
6849
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6781
6850
|
},
|
|
6782
6851
|
get children() {
|
|
6783
|
-
return createComponent(inlined_script_default, {
|
|
6852
|
+
return [createComponent(inlined_script_default, {
|
|
6784
6853
|
id: "builderio-init-variants-fns",
|
|
6785
6854
|
get scriptStr() {
|
|
6786
6855
|
return getInitVariantsFnsScriptString();
|
|
@@ -6788,7 +6857,22 @@ function ContentVariants(props) {
|
|
|
6788
6857
|
get nonce() {
|
|
6789
6858
|
return props.nonce || "";
|
|
6790
6859
|
}
|
|
6791
|
-
})
|
|
6860
|
+
}), createComponent(Show, {
|
|
6861
|
+
get when() {
|
|
6862
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
6863
|
+
},
|
|
6864
|
+
get children() {
|
|
6865
|
+
return createComponent(inlined_script_default, {
|
|
6866
|
+
id: "builderio-init-personalization-variants-fns",
|
|
6867
|
+
get nonce() {
|
|
6868
|
+
return props.nonce || "";
|
|
6869
|
+
},
|
|
6870
|
+
get scriptStr() {
|
|
6871
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
6872
|
+
}
|
|
6873
|
+
});
|
|
6874
|
+
}
|
|
6875
|
+
})];
|
|
6792
6876
|
}
|
|
6793
6877
|
}), createComponent(Show, {
|
|
6794
6878
|
get when() {
|
|
@@ -6976,9 +7060,10 @@ var fetchSymbolContent = async ({
|
|
|
6976
7060
|
};
|
|
6977
7061
|
|
|
6978
7062
|
// src/blocks/symbol/symbol.tsx
|
|
6979
|
-
var _tmpl$
|
|
7063
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
6980
7064
|
function Symbol(props) {
|
|
6981
7065
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7066
|
+
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
6982
7067
|
const blocksWrapper = createMemo(() => {
|
|
6983
7068
|
return "div";
|
|
6984
7069
|
});
|
|
@@ -6989,7 +7074,7 @@ function Symbol(props) {
|
|
|
6989
7074
|
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(" ");
|
|
6990
7075
|
});
|
|
6991
7076
|
function setContent() {
|
|
6992
|
-
if (contentToUse())
|
|
7077
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
6993
7078
|
return;
|
|
6994
7079
|
fetchSymbolContent({
|
|
6995
7080
|
symbol: props.symbol,
|
|
@@ -6997,6 +7082,7 @@ function Symbol(props) {
|
|
|
6997
7082
|
}).then((newContent) => {
|
|
6998
7083
|
if (newContent) {
|
|
6999
7084
|
setContentToUse(newContent);
|
|
7085
|
+
setSymbolEntry(props.symbol?.entry);
|
|
7000
7086
|
}
|
|
7001
7087
|
});
|
|
7002
7088
|
}
|
|
@@ -7008,7 +7094,7 @@ function Symbol(props) {
|
|
|
7008
7094
|
}
|
|
7009
7095
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7010
7096
|
return (() => {
|
|
7011
|
-
const _el$ = _tmpl$
|
|
7097
|
+
const _el$ = _tmpl$29();
|
|
7012
7098
|
spread(_el$, mergeProps({
|
|
7013
7099
|
get ["class"]() {
|
|
7014
7100
|
return className();
|