@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/dev.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
|
|
@@ -1218,6 +1218,7 @@ var awaiter_default = Awaiter;
|
|
|
1218
1218
|
|
|
1219
1219
|
// src/components/block/components/interactive-element.tsx
|
|
1220
1220
|
function InteractiveElement(props) {
|
|
1221
|
+
createSignal(0);
|
|
1221
1222
|
const attributes = createMemo(() => {
|
|
1222
1223
|
return props.includeBlockProps ? {
|
|
1223
1224
|
...getBlockProperties({
|
|
@@ -1236,6 +1237,11 @@ function InteractiveElement(props) {
|
|
|
1236
1237
|
const targetWrapperProps = createMemo(() => {
|
|
1237
1238
|
return props.wrapperProps;
|
|
1238
1239
|
});
|
|
1240
|
+
const onUpdateFn_0_props_wrapperProps = createMemo(() => props.wrapperProps);
|
|
1241
|
+
const onUpdateFn_0_props_block__component__options = createMemo(() => props.block?.component?.options);
|
|
1242
|
+
function onUpdateFn_0() {
|
|
1243
|
+
}
|
|
1244
|
+
createEffect(on(() => [onUpdateFn_0_props_wrapperProps(), onUpdateFn_0_props_block__component__options()], onUpdateFn_0));
|
|
1239
1245
|
return createComponent(Show, {
|
|
1240
1246
|
get fallback() {
|
|
1241
1247
|
return createComponent(Dynamic, mergeProps(targetWrapperProps, {
|
|
@@ -1662,7 +1668,7 @@ function Block(props) {
|
|
|
1662
1668
|
});
|
|
1663
1669
|
}
|
|
1664
1670
|
var block_default = Block;
|
|
1665
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1671
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1666
1672
|
display: flex;
|
|
1667
1673
|
flex-direction: column;
|
|
1668
1674
|
align-items: stretch;
|
|
@@ -1711,7 +1717,7 @@ function BlocksWrapper(props) {
|
|
|
1711
1717
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1712
1718
|
return [createComponent(Dynamic, mergeProps({
|
|
1713
1719
|
get ["class"]() {
|
|
1714
|
-
return className() + " dynamic-
|
|
1720
|
+
return className() + " dynamic-450facf4";
|
|
1715
1721
|
},
|
|
1716
1722
|
ref(r$) {
|
|
1717
1723
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1758,17 +1764,17 @@ function Blocks(props) {
|
|
|
1758
1764
|
get styleProp() {
|
|
1759
1765
|
return props.styleProp;
|
|
1760
1766
|
},
|
|
1767
|
+
get BlocksWrapperProps() {
|
|
1768
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1769
|
+
},
|
|
1761
1770
|
get classNameProp() {
|
|
1762
1771
|
return props.className;
|
|
1763
1772
|
},
|
|
1764
1773
|
get BlocksWrapper() {
|
|
1765
1774
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1766
1775
|
},
|
|
1767
|
-
get BlocksWrapperProps() {
|
|
1768
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1769
|
-
},
|
|
1770
1776
|
get children() {
|
|
1771
|
-
return createComponent(Show, {
|
|
1777
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1772
1778
|
get when() {
|
|
1773
1779
|
return props.blocks;
|
|
1774
1780
|
},
|
|
@@ -1797,7 +1803,7 @@ function Blocks(props) {
|
|
|
1797
1803
|
}
|
|
1798
1804
|
});
|
|
1799
1805
|
}
|
|
1800
|
-
});
|
|
1806
|
+
})];
|
|
1801
1807
|
}
|
|
1802
1808
|
});
|
|
1803
1809
|
}
|
|
@@ -2222,6 +2228,166 @@ function SectionComponent(props) {
|
|
|
2222
2228
|
}
|
|
2223
2229
|
var section_default = SectionComponent;
|
|
2224
2230
|
|
|
2231
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2232
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2233
|
+
function isString(val) {
|
|
2234
|
+
return typeof val === "string";
|
|
2235
|
+
}
|
|
2236
|
+
function isNumber(val) {
|
|
2237
|
+
return typeof val === "number";
|
|
2238
|
+
}
|
|
2239
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2240
|
+
const result = (() => {
|
|
2241
|
+
const property = query2.property;
|
|
2242
|
+
const operator = query2.operator;
|
|
2243
|
+
let testValue = query2.value;
|
|
2244
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2245
|
+
testValue = query2.value.slice(0, -1);
|
|
2246
|
+
}
|
|
2247
|
+
if (!(property && operator)) {
|
|
2248
|
+
return true;
|
|
2249
|
+
}
|
|
2250
|
+
if (Array.isArray(testValue)) {
|
|
2251
|
+
if (operator === "isNot") {
|
|
2252
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2253
|
+
property,
|
|
2254
|
+
operator,
|
|
2255
|
+
value: val
|
|
2256
|
+
}));
|
|
2257
|
+
}
|
|
2258
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2259
|
+
property,
|
|
2260
|
+
operator,
|
|
2261
|
+
value: val
|
|
2262
|
+
}));
|
|
2263
|
+
}
|
|
2264
|
+
const value = userattr[property];
|
|
2265
|
+
if (Array.isArray(value)) {
|
|
2266
|
+
return value.includes(testValue);
|
|
2267
|
+
}
|
|
2268
|
+
switch (operator) {
|
|
2269
|
+
case "is":
|
|
2270
|
+
return value === testValue;
|
|
2271
|
+
case "isNot":
|
|
2272
|
+
return value !== testValue;
|
|
2273
|
+
case "contains":
|
|
2274
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2275
|
+
case "startsWith":
|
|
2276
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2277
|
+
case "endsWith":
|
|
2278
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2279
|
+
case "greaterThan":
|
|
2280
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2281
|
+
case "lessThan":
|
|
2282
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2283
|
+
case "greaterThanOrEqualTo":
|
|
2284
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2285
|
+
case "lessThanOrEqualTo":
|
|
2286
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2287
|
+
default:
|
|
2288
|
+
return false;
|
|
2289
|
+
}
|
|
2290
|
+
})();
|
|
2291
|
+
return result;
|
|
2292
|
+
}
|
|
2293
|
+
const item = {
|
|
2294
|
+
query,
|
|
2295
|
+
startDate,
|
|
2296
|
+
endDate
|
|
2297
|
+
};
|
|
2298
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2299
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2300
|
+
return false;
|
|
2301
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2302
|
+
return false;
|
|
2303
|
+
}
|
|
2304
|
+
if (!item.query || !item.query.length) {
|
|
2305
|
+
return true;
|
|
2306
|
+
}
|
|
2307
|
+
return item.query.every((filter) => {
|
|
2308
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
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}";
|
|
2312
|
+
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}";
|
|
2313
|
+
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}";
|
|
2314
|
+
|
|
2315
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2316
|
+
var DEFAULT_INDEX = "default";
|
|
2317
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2318
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2319
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2320
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2321
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2322
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2323
|
+
const hasVariants = variants && variants.length > 0;
|
|
2324
|
+
if (TARGET === "reactNative")
|
|
2325
|
+
return false;
|
|
2326
|
+
if (!hasVariants)
|
|
2327
|
+
return false;
|
|
2328
|
+
if (!canTrack)
|
|
2329
|
+
return false;
|
|
2330
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2331
|
+
return true;
|
|
2332
|
+
if (isBrowser())
|
|
2333
|
+
return false;
|
|
2334
|
+
return true;
|
|
2335
|
+
}
|
|
2336
|
+
function getBlocksToRender({
|
|
2337
|
+
variants,
|
|
2338
|
+
previewingIndex,
|
|
2339
|
+
isHydrated,
|
|
2340
|
+
filteredVariants,
|
|
2341
|
+
fallbackBlocks
|
|
2342
|
+
}) {
|
|
2343
|
+
const fallback = {
|
|
2344
|
+
blocks: fallbackBlocks ?? [],
|
|
2345
|
+
path: "this.children",
|
|
2346
|
+
index: DEFAULT_INDEX
|
|
2347
|
+
};
|
|
2348
|
+
if (isHydrated && isEditing()) {
|
|
2349
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2350
|
+
const variant = variants?.[previewingIndex];
|
|
2351
|
+
if (variant) {
|
|
2352
|
+
return {
|
|
2353
|
+
blocks: variant.blocks,
|
|
2354
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2355
|
+
index: previewingIndex
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
return fallback;
|
|
2360
|
+
}
|
|
2361
|
+
if (isBrowser()) {
|
|
2362
|
+
const winningVariant = filteredVariants?.[0];
|
|
2363
|
+
if (winningVariant && variants) {
|
|
2364
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2365
|
+
if (variantIndex !== -1) {
|
|
2366
|
+
return {
|
|
2367
|
+
blocks: winningVariant.blocks,
|
|
2368
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2369
|
+
index: variantIndex
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return fallback;
|
|
2375
|
+
}
|
|
2376
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2377
|
+
return `
|
|
2378
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2379
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2380
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2381
|
+
`;
|
|
2382
|
+
};
|
|
2383
|
+
var isHydrationTarget = TARGET === "react";
|
|
2384
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2385
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2386
|
+
};
|
|
2387
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2388
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2225
2391
|
// src/helpers/url.ts
|
|
2226
2392
|
var getTopLevelDomain = (host) => {
|
|
2227
2393
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -3201,7 +3367,8 @@ var componentInfo6 = {
|
|
|
3201
3367
|
name: "PersonalizationContainer",
|
|
3202
3368
|
shouldReceiveBuilderProps: {
|
|
3203
3369
|
builderBlock: true,
|
|
3204
|
-
builderContext: true
|
|
3370
|
+
builderContext: true,
|
|
3371
|
+
builderComponents: true
|
|
3205
3372
|
},
|
|
3206
3373
|
noWrap: true,
|
|
3207
3374
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3263,208 +3430,22 @@ function isPreviewing(_search) {
|
|
|
3263
3430
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3264
3431
|
}
|
|
3265
3432
|
|
|
3266
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3267
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3268
|
-
function isString(val) {
|
|
3269
|
-
return typeof val === "string";
|
|
3270
|
-
}
|
|
3271
|
-
function isNumber(val) {
|
|
3272
|
-
return typeof val === "number";
|
|
3273
|
-
}
|
|
3274
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3275
|
-
const result = (() => {
|
|
3276
|
-
const property = query2.property;
|
|
3277
|
-
const operator = query2.operator;
|
|
3278
|
-
let testValue = query2.value;
|
|
3279
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3280
|
-
testValue = query2.value.slice(0, -1);
|
|
3281
|
-
}
|
|
3282
|
-
if (!(property && operator)) {
|
|
3283
|
-
return true;
|
|
3284
|
-
}
|
|
3285
|
-
if (Array.isArray(testValue)) {
|
|
3286
|
-
if (operator === "isNot") {
|
|
3287
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3288
|
-
property,
|
|
3289
|
-
operator,
|
|
3290
|
-
value: val
|
|
3291
|
-
}));
|
|
3292
|
-
}
|
|
3293
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3294
|
-
property,
|
|
3295
|
-
operator,
|
|
3296
|
-
value: val
|
|
3297
|
-
}));
|
|
3298
|
-
}
|
|
3299
|
-
const value = userattr[property];
|
|
3300
|
-
if (Array.isArray(value)) {
|
|
3301
|
-
return value.includes(testValue);
|
|
3302
|
-
}
|
|
3303
|
-
switch (operator) {
|
|
3304
|
-
case "is":
|
|
3305
|
-
return value === testValue;
|
|
3306
|
-
case "isNot":
|
|
3307
|
-
return value !== testValue;
|
|
3308
|
-
case "contains":
|
|
3309
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3310
|
-
case "startsWith":
|
|
3311
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3312
|
-
case "endsWith":
|
|
3313
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3314
|
-
case "greaterThan":
|
|
3315
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3316
|
-
case "lessThan":
|
|
3317
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3318
|
-
case "greaterThanOrEqualTo":
|
|
3319
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3320
|
-
case "lessThanOrEqualTo":
|
|
3321
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3322
|
-
default:
|
|
3323
|
-
return false;
|
|
3324
|
-
}
|
|
3325
|
-
})();
|
|
3326
|
-
return result;
|
|
3327
|
-
}
|
|
3328
|
-
const item = {
|
|
3329
|
-
query,
|
|
3330
|
-
startDate,
|
|
3331
|
-
endDate
|
|
3332
|
-
};
|
|
3333
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3334
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3335
|
-
return false;
|
|
3336
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3337
|
-
return false;
|
|
3338
|
-
}
|
|
3339
|
-
if (!item.query || !item.query.length) {
|
|
3340
|
-
return true;
|
|
3341
|
-
}
|
|
3342
|
-
return item.query.every((filter) => {
|
|
3343
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3344
|
-
});
|
|
3345
|
-
}
|
|
3346
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3347
|
-
if (!navigator.cookieEnabled) {
|
|
3348
|
-
return;
|
|
3349
|
-
}
|
|
3350
|
-
function getCookie(name) {
|
|
3351
|
-
const nameEQ = name + '=';
|
|
3352
|
-
const ca = document.cookie.split(';');
|
|
3353
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3354
|
-
let c = ca[i];
|
|
3355
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3356
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3357
|
-
}
|
|
3358
|
-
return null;
|
|
3359
|
-
}
|
|
3360
|
-
function removeVariants() {
|
|
3361
|
-
variants?.forEach(function (_, index) {
|
|
3362
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3363
|
-
});
|
|
3364
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3365
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3366
|
-
}
|
|
3367
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3368
|
-
if (locale) {
|
|
3369
|
-
attributes.locale = locale;
|
|
3370
|
-
}
|
|
3371
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3372
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3373
|
-
});
|
|
3374
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3375
|
-
if (isDebug) {
|
|
3376
|
-
console.debug('PersonalizationContainer', {
|
|
3377
|
-
attributes,
|
|
3378
|
-
variants,
|
|
3379
|
-
winningVariantIndex
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
if (winningVariantIndex !== -1) {
|
|
3383
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3384
|
-
if (winningVariant) {
|
|
3385
|
-
const parentNode = winningVariant.parentNode;
|
|
3386
|
-
if (parentNode) {
|
|
3387
|
-
const newParent = parentNode.cloneNode(false);
|
|
3388
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3389
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3390
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3391
|
-
}
|
|
3392
|
-
if (isDebug) {
|
|
3393
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
} else if (variants && variants.length > 0) {
|
|
3397
|
-
removeVariants();
|
|
3398
|
-
}
|
|
3399
|
-
}`;
|
|
3400
|
-
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}";
|
|
3401
|
-
|
|
3402
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3403
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3404
|
-
const hasVariants = variants && variants.length > 0;
|
|
3405
|
-
if (TARGET === "reactNative")
|
|
3406
|
-
return false;
|
|
3407
|
-
if (!hasVariants)
|
|
3408
|
-
return false;
|
|
3409
|
-
if (!canTrack)
|
|
3410
|
-
return false;
|
|
3411
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3412
|
-
return true;
|
|
3413
|
-
if (isBrowser())
|
|
3414
|
-
return false;
|
|
3415
|
-
return true;
|
|
3416
|
-
}
|
|
3417
|
-
function getBlocksToRender({
|
|
3418
|
-
variants,
|
|
3419
|
-
previewingIndex,
|
|
3420
|
-
isHydrated,
|
|
3421
|
-
filteredVariants,
|
|
3422
|
-
fallbackBlocks
|
|
3423
|
-
}) {
|
|
3424
|
-
const fallback = {
|
|
3425
|
-
blocks: fallbackBlocks ?? [],
|
|
3426
|
-
path: "this.children"
|
|
3427
|
-
};
|
|
3428
|
-
if (isHydrated && isEditing()) {
|
|
3429
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3430
|
-
const variant = variants[previewingIndex];
|
|
3431
|
-
return {
|
|
3432
|
-
blocks: variant.blocks,
|
|
3433
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3434
|
-
};
|
|
3435
|
-
}
|
|
3436
|
-
return fallback;
|
|
3437
|
-
}
|
|
3438
|
-
if (isBrowser()) {
|
|
3439
|
-
const winningVariant = filteredVariants?.[0];
|
|
3440
|
-
if (winningVariant) {
|
|
3441
|
-
return {
|
|
3442
|
-
blocks: winningVariant.blocks,
|
|
3443
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3444
|
-
};
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
return fallback;
|
|
3448
|
-
}
|
|
3449
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3450
|
-
return `
|
|
3451
|
-
(function() {
|
|
3452
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3453
|
-
${PERSONALIZATION_SCRIPT}
|
|
3454
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3455
|
-
})();
|
|
3456
|
-
`;
|
|
3457
|
-
};
|
|
3458
|
-
|
|
3459
3433
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3460
3434
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3461
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3462
3435
|
function PersonalizationContainer(props) {
|
|
3463
3436
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3464
3437
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3438
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3465
3439
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3466
3440
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3467
|
-
const [
|
|
3441
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3442
|
+
const attrs = createMemo(() => {
|
|
3443
|
+
return {
|
|
3444
|
+
...props.attributes,
|
|
3445
|
+
...{},
|
|
3446
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3447
|
+
};
|
|
3448
|
+
});
|
|
3468
3449
|
const filteredVariants = createMemo(() => {
|
|
3469
3450
|
return (props.variants || []).filter((variant) => {
|
|
3470
3451
|
return filterWithCustomTargeting({
|
|
@@ -3479,26 +3460,26 @@ function PersonalizationContainer(props) {
|
|
|
3479
3460
|
return getBlocksToRender({
|
|
3480
3461
|
variants: props.variants,
|
|
3481
3462
|
fallbackBlocks: props.builderBlock?.children,
|
|
3482
|
-
isHydrated:
|
|
3463
|
+
isHydrated: shouldResetVariants(),
|
|
3483
3464
|
filteredVariants: filteredVariants(),
|
|
3484
3465
|
previewingIndex: props.previewingIndex
|
|
3485
3466
|
});
|
|
3486
3467
|
});
|
|
3487
3468
|
const hideVariantsStyleString = createMemo(() => {
|
|
3488
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3469
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3489
3470
|
});
|
|
3490
3471
|
let rootRef;
|
|
3491
3472
|
onMount(() => {
|
|
3492
|
-
|
|
3493
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3494
|
-
setUserAttributes(
|
|
3473
|
+
setShouldResetVariants(true);
|
|
3474
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3475
|
+
setUserAttributes(attrs2);
|
|
3495
3476
|
});
|
|
3496
3477
|
if (!(isEditing() || isPreviewing())) {
|
|
3497
3478
|
const variant = filteredVariants()[0];
|
|
3498
3479
|
if (rootRef) {
|
|
3499
3480
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3500
3481
|
detail: {
|
|
3501
|
-
variant: variant ||
|
|
3482
|
+
variant: variant || DEFAULT_INDEX,
|
|
3502
3483
|
content: props.builderContext?.content
|
|
3503
3484
|
},
|
|
3504
3485
|
bubbles: true
|
|
@@ -3508,7 +3489,7 @@ function PersonalizationContainer(props) {
|
|
|
3508
3489
|
if (entry.isIntersecting && rootRef) {
|
|
3509
3490
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3510
3491
|
detail: {
|
|
3511
|
-
variant: variant ||
|
|
3492
|
+
variant: variant || DEFAULT_INDEX,
|
|
3512
3493
|
content: props.builderContext?.content
|
|
3513
3494
|
},
|
|
3514
3495
|
bubbles: true
|
|
@@ -3525,70 +3506,158 @@ function PersonalizationContainer(props) {
|
|
|
3525
3506
|
const _el$ = _tmpl$9();
|
|
3526
3507
|
const _ref$ = rootRef;
|
|
3527
3508
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3528
|
-
spread(_el$, mergeProps(
|
|
3529
|
-
get ["class"]() {
|
|
3530
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3531
|
-
}
|
|
3532
|
-
}, () => props.attributes), false, true);
|
|
3509
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3533
3510
|
insert(_el$, createComponent(Show, {
|
|
3534
3511
|
get when() {
|
|
3535
|
-
return
|
|
3512
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3536
3513
|
},
|
|
3537
3514
|
get children() {
|
|
3538
|
-
return
|
|
3539
|
-
get
|
|
3540
|
-
return
|
|
3515
|
+
return createComponent(blocks_default, {
|
|
3516
|
+
get blocks() {
|
|
3517
|
+
return blocksToRender().blocks;
|
|
3541
3518
|
},
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
return (() => {
|
|
3545
|
-
const _el$2 = _tmpl$25();
|
|
3546
|
-
setAttribute(_el$2, "key", index);
|
|
3547
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3548
|
-
get blocks() {
|
|
3549
|
-
return variant.blocks;
|
|
3550
|
-
},
|
|
3551
|
-
get parent() {
|
|
3552
|
-
return props.builderBlock?.id;
|
|
3553
|
-
},
|
|
3554
|
-
path: `component.options.variants.${index}.blocks`
|
|
3555
|
-
}));
|
|
3556
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3557
|
-
return _el$2;
|
|
3558
|
-
})();
|
|
3559
|
-
}
|
|
3560
|
-
}), createComponent(inlined_styles_default, {
|
|
3561
|
-
get nonce() {
|
|
3562
|
-
return props.builderContext?.nonce || "";
|
|
3519
|
+
get parent() {
|
|
3520
|
+
return props.builderBlock?.id;
|
|
3563
3521
|
},
|
|
3564
|
-
get
|
|
3565
|
-
return
|
|
3522
|
+
get path() {
|
|
3523
|
+
return blocksToRender().path;
|
|
3566
3524
|
},
|
|
3567
|
-
get
|
|
3568
|
-
return
|
|
3569
|
-
}
|
|
3570
|
-
}), createComponent(inlined_script_default, {
|
|
3571
|
-
get nonce() {
|
|
3572
|
-
return props.builderContext?.nonce || "";
|
|
3525
|
+
get context() {
|
|
3526
|
+
return props.builderContext;
|
|
3573
3527
|
},
|
|
3574
|
-
get
|
|
3575
|
-
return
|
|
3528
|
+
get registeredComponents() {
|
|
3529
|
+
return props.builderComponents;
|
|
3576
3530
|
},
|
|
3577
|
-
get
|
|
3578
|
-
return
|
|
3531
|
+
get BlocksWrapperProps() {
|
|
3532
|
+
return {
|
|
3533
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3534
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3535
|
+
};
|
|
3579
3536
|
}
|
|
3580
|
-
})
|
|
3537
|
+
});
|
|
3581
3538
|
}
|
|
3582
3539
|
}), null);
|
|
3583
|
-
insert(_el$, createComponent(
|
|
3584
|
-
get
|
|
3585
|
-
return
|
|
3586
|
-
},
|
|
3587
|
-
get parent() {
|
|
3588
|
-
return props.builderBlock?.id;
|
|
3540
|
+
insert(_el$, createComponent(Show, {
|
|
3541
|
+
get when() {
|
|
3542
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3589
3543
|
},
|
|
3590
|
-
get
|
|
3591
|
-
return
|
|
3544
|
+
get children() {
|
|
3545
|
+
return [createComponent(Show, {
|
|
3546
|
+
get when() {
|
|
3547
|
+
return shouldRenderVariants();
|
|
3548
|
+
},
|
|
3549
|
+
get children() {
|
|
3550
|
+
return [createComponent(inlined_styles_default, {
|
|
3551
|
+
get nonce() {
|
|
3552
|
+
return props.builderContext?.nonce || "";
|
|
3553
|
+
},
|
|
3554
|
+
get styles() {
|
|
3555
|
+
return hideVariantsStyleString();
|
|
3556
|
+
},
|
|
3557
|
+
get id() {
|
|
3558
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3559
|
+
}
|
|
3560
|
+
}), createComponent(inlined_script_default, {
|
|
3561
|
+
get nonce() {
|
|
3562
|
+
return props.builderContext?.nonce || "";
|
|
3563
|
+
},
|
|
3564
|
+
get scriptStr() {
|
|
3565
|
+
return updateVisibilityStylesScript();
|
|
3566
|
+
},
|
|
3567
|
+
get id() {
|
|
3568
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3569
|
+
}
|
|
3570
|
+
}), createComponent(For, {
|
|
3571
|
+
get each() {
|
|
3572
|
+
return props.variants;
|
|
3573
|
+
},
|
|
3574
|
+
children: (variant, _index) => {
|
|
3575
|
+
const index = _index();
|
|
3576
|
+
return createComponent(blocks_default, {
|
|
3577
|
+
get key() {
|
|
3578
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3579
|
+
},
|
|
3580
|
+
get BlocksWrapperProps() {
|
|
3581
|
+
return {
|
|
3582
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3583
|
+
"aria-hidden": true,
|
|
3584
|
+
hidden: true,
|
|
3585
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3586
|
+
};
|
|
3587
|
+
},
|
|
3588
|
+
get blocks() {
|
|
3589
|
+
return variant.blocks;
|
|
3590
|
+
},
|
|
3591
|
+
get parent() {
|
|
3592
|
+
return props.builderBlock?.id;
|
|
3593
|
+
},
|
|
3594
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3595
|
+
get context() {
|
|
3596
|
+
return props.builderContext;
|
|
3597
|
+
},
|
|
3598
|
+
get registeredComponents() {
|
|
3599
|
+
return props.builderComponents;
|
|
3600
|
+
},
|
|
3601
|
+
get children() {
|
|
3602
|
+
return createComponent(inlined_script_default, {
|
|
3603
|
+
get nonce() {
|
|
3604
|
+
return props.builderContext?.nonce || "";
|
|
3605
|
+
},
|
|
3606
|
+
get scriptStr() {
|
|
3607
|
+
return scriptStr();
|
|
3608
|
+
},
|
|
3609
|
+
get id() {
|
|
3610
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3611
|
+
}
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
})];
|
|
3617
|
+
}
|
|
3618
|
+
}), createComponent(blocks_default, {
|
|
3619
|
+
get blocks() {
|
|
3620
|
+
return blocksToRender().blocks;
|
|
3621
|
+
},
|
|
3622
|
+
get parent() {
|
|
3623
|
+
return props.builderBlock?.id;
|
|
3624
|
+
},
|
|
3625
|
+
get path() {
|
|
3626
|
+
return blocksToRender().path;
|
|
3627
|
+
},
|
|
3628
|
+
get context() {
|
|
3629
|
+
return props.builderContext;
|
|
3630
|
+
},
|
|
3631
|
+
get registeredComponents() {
|
|
3632
|
+
return props.builderComponents;
|
|
3633
|
+
},
|
|
3634
|
+
get BlocksWrapperProps() {
|
|
3635
|
+
return {
|
|
3636
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3637
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3638
|
+
};
|
|
3639
|
+
},
|
|
3640
|
+
get children() {
|
|
3641
|
+
return createComponent(Show, {
|
|
3642
|
+
get when() {
|
|
3643
|
+
return shouldRenderVariants();
|
|
3644
|
+
},
|
|
3645
|
+
get children() {
|
|
3646
|
+
return createComponent(inlined_script_default, {
|
|
3647
|
+
get nonce() {
|
|
3648
|
+
return props.builderContext?.nonce || "";
|
|
3649
|
+
},
|
|
3650
|
+
get scriptStr() {
|
|
3651
|
+
return scriptStr();
|
|
3652
|
+
},
|
|
3653
|
+
get id() {
|
|
3654
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3655
|
+
}
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
})];
|
|
3592
3661
|
}
|
|
3593
3662
|
}), null);
|
|
3594
3663
|
return _el$;
|
|
@@ -3875,7 +3944,7 @@ var componentInfo10 = {
|
|
|
3875
3944
|
}
|
|
3876
3945
|
};
|
|
3877
3946
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
3878
|
-
var _tmpl$
|
|
3947
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
3879
3948
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
3880
3949
|
function Tabs(props) {
|
|
3881
3950
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -3890,7 +3959,7 @@ function Tabs(props) {
|
|
|
3890
3959
|
}
|
|
3891
3960
|
}
|
|
3892
3961
|
return (() => {
|
|
3893
|
-
const _el$ = _tmpl$
|
|
3962
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
3894
3963
|
_el$2.style.setProperty("display", "flex");
|
|
3895
3964
|
_el$2.style.setProperty("flex-direction", "row");
|
|
3896
3965
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4422,7 +4491,7 @@ function logFetch(url) {
|
|
|
4422
4491
|
|
|
4423
4492
|
// src/blocks/form/form/form.tsx
|
|
4424
4493
|
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
|
|
4425
|
-
var _tmpl$
|
|
4494
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4426
4495
|
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
|
|
4427
4496
|
padding: 10px;
|
|
4428
4497
|
color: red;
|
|
@@ -4615,7 +4684,7 @@ function FormComponent(props) {
|
|
|
4615
4684
|
}
|
|
4616
4685
|
let formRef;
|
|
4617
4686
|
return [(() => {
|
|
4618
|
-
const _el$ = _tmpl$
|
|
4687
|
+
const _el$ = _tmpl$26();
|
|
4619
4688
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4620
4689
|
const _ref$ = formRef;
|
|
4621
4690
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4827,7 +4896,7 @@ var componentInfo16 = {
|
|
|
4827
4896
|
noWrap: true
|
|
4828
4897
|
};
|
|
4829
4898
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4830
|
-
var _tmpl$
|
|
4899
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
4831
4900
|
function SelectComponent(props) {
|
|
4832
4901
|
return (() => {
|
|
4833
4902
|
const _el$ = _tmpl$17();
|
|
@@ -4855,7 +4924,7 @@ function SelectComponent(props) {
|
|
|
4855
4924
|
children: (option, _index) => {
|
|
4856
4925
|
const index = _index();
|
|
4857
4926
|
return (() => {
|
|
4858
|
-
const _el$2 = _tmpl$
|
|
4927
|
+
const _el$2 = _tmpl$27();
|
|
4859
4928
|
insert(_el$2, () => option.name || option.value);
|
|
4860
4929
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
4861
4930
|
effect(() => _el$2.value = option.value);
|
|
@@ -5099,7 +5168,7 @@ var componentInfo20 = {
|
|
|
5099
5168
|
}
|
|
5100
5169
|
};
|
|
5101
5170
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5102
|
-
var _tmpl$
|
|
5171
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5103
5172
|
function Video(props) {
|
|
5104
5173
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5105
5174
|
const videoProps = createMemo(() => {
|
|
@@ -5155,7 +5224,7 @@ function Video(props) {
|
|
|
5155
5224
|
}
|
|
5156
5225
|
});
|
|
5157
5226
|
return (() => {
|
|
5158
|
-
const _el$ = _tmpl$
|
|
5227
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5159
5228
|
_el$.style.setProperty("position", "relative");
|
|
5160
5229
|
const _ref$ = videoRef;
|
|
5161
5230
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5292,7 +5361,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5292
5361
|
}, {
|
|
5293
5362
|
component: text_default,
|
|
5294
5363
|
...componentInfo11
|
|
5295
|
-
}, ...TARGET
|
|
5364
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5296
5365
|
component: personalization_container_default,
|
|
5297
5366
|
...componentInfo6
|
|
5298
5367
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5329,7 +5398,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5329
5398
|
|
|
5330
5399
|
// src/components/content-variants/helpers.ts
|
|
5331
5400
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5332
|
-
var
|
|
5401
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5333
5402
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5334
5403
|
...variant,
|
|
5335
5404
|
testVariationId: variant.id,
|
|
@@ -5354,20 +5423,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5354
5423
|
};
|
|
5355
5424
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5356
5425
|
var isAngularSDK = TARGET === "angular";
|
|
5357
|
-
var
|
|
5426
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5358
5427
|
var getInitVariantsFnsScriptString = () => `
|
|
5359
5428
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5360
|
-
window.${
|
|
5429
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5361
5430
|
`;
|
|
5362
5431
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5363
5432
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5364
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5433
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5365
5434
|
)`;
|
|
5366
5435
|
var getUpdateVariantVisibilityScript = ({
|
|
5367
5436
|
contentId,
|
|
5368
5437
|
variationId
|
|
5369
|
-
}) => `window.${
|
|
5370
|
-
"${variationId}", "${contentId}", ${
|
|
5438
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5439
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5371
5440
|
)`;
|
|
5372
5441
|
|
|
5373
5442
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5376,7 +5445,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5376
5445
|
}
|
|
5377
5446
|
|
|
5378
5447
|
// src/constants/sdk-version.ts
|
|
5379
|
-
var SDK_VERSION = "4.0.
|
|
5448
|
+
var SDK_VERSION = "4.0.9";
|
|
5380
5449
|
|
|
5381
5450
|
// src/helpers/sdk-headers.ts
|
|
5382
5451
|
var getSdkHeaders = () => ({
|
|
@@ -6799,7 +6868,7 @@ function ContentVariants(props) {
|
|
|
6799
6868
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6800
6869
|
},
|
|
6801
6870
|
get children() {
|
|
6802
|
-
return createComponent(inlined_script_default, {
|
|
6871
|
+
return [createComponent(inlined_script_default, {
|
|
6803
6872
|
id: "builderio-init-variants-fns",
|
|
6804
6873
|
get scriptStr() {
|
|
6805
6874
|
return getInitVariantsFnsScriptString();
|
|
@@ -6807,7 +6876,22 @@ function ContentVariants(props) {
|
|
|
6807
6876
|
get nonce() {
|
|
6808
6877
|
return props.nonce || "";
|
|
6809
6878
|
}
|
|
6810
|
-
})
|
|
6879
|
+
}), createComponent(Show, {
|
|
6880
|
+
get when() {
|
|
6881
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
6882
|
+
},
|
|
6883
|
+
get children() {
|
|
6884
|
+
return createComponent(inlined_script_default, {
|
|
6885
|
+
id: "builderio-init-personalization-variants-fns",
|
|
6886
|
+
get nonce() {
|
|
6887
|
+
return props.nonce || "";
|
|
6888
|
+
},
|
|
6889
|
+
get scriptStr() {
|
|
6890
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
6891
|
+
}
|
|
6892
|
+
});
|
|
6893
|
+
}
|
|
6894
|
+
})];
|
|
6811
6895
|
}
|
|
6812
6896
|
}), createComponent(Show, {
|
|
6813
6897
|
get when() {
|
|
@@ -6995,9 +7079,10 @@ var fetchSymbolContent = async ({
|
|
|
6995
7079
|
};
|
|
6996
7080
|
|
|
6997
7081
|
// src/blocks/symbol/symbol.tsx
|
|
6998
|
-
var _tmpl$
|
|
7082
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
6999
7083
|
function Symbol(props) {
|
|
7000
7084
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7085
|
+
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
7001
7086
|
const blocksWrapper = createMemo(() => {
|
|
7002
7087
|
return "div";
|
|
7003
7088
|
});
|
|
@@ -7008,7 +7093,7 @@ function Symbol(props) {
|
|
|
7008
7093
|
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(" ");
|
|
7009
7094
|
});
|
|
7010
7095
|
function setContent() {
|
|
7011
|
-
if (contentToUse())
|
|
7096
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
7012
7097
|
return;
|
|
7013
7098
|
fetchSymbolContent({
|
|
7014
7099
|
symbol: props.symbol,
|
|
@@ -7016,6 +7101,7 @@ function Symbol(props) {
|
|
|
7016
7101
|
}).then((newContent) => {
|
|
7017
7102
|
if (newContent) {
|
|
7018
7103
|
setContentToUse(newContent);
|
|
7104
|
+
setSymbolEntry(props.symbol?.entry);
|
|
7019
7105
|
}
|
|
7020
7106
|
});
|
|
7021
7107
|
}
|
|
@@ -7027,7 +7113,7 @@ function Symbol(props) {
|
|
|
7027
7113
|
}
|
|
7028
7114
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7029
7115
|
return (() => {
|
|
7030
|
-
const _el$ = _tmpl$
|
|
7116
|
+
const _el$ = _tmpl$29();
|
|
7031
7117
|
spread(_el$, mergeProps({
|
|
7032
7118
|
get ["class"]() {
|
|
7033
7119
|
return className();
|