@builder.io/sdk-solid 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -2
- package/lib/browser/dev.js +369 -283
- package/lib/browser/dev.jsx +325 -282
- package/lib/browser/index.js +369 -283
- package/lib/browser/index.jsx +325 -282
- package/lib/edge/dev.js +369 -283
- package/lib/edge/dev.jsx +325 -282
- package/lib/edge/index.js +369 -283
- package/lib/edge/index.jsx +325 -282
- package/lib/node/dev.js +369 -283
- package/lib/node/dev.jsx +325 -282
- package/lib/node/index.js +369 -283
- package/lib/node/index.jsx +325 -282
- package/package.json +1 -1
package/lib/edge/index.jsx
CHANGED
|
@@ -4378,15 +4378,15 @@ var Block_wrapper_default = BlockWrapper;
|
|
|
4378
4378
|
import {
|
|
4379
4379
|
Show as Show4,
|
|
4380
4380
|
For,
|
|
4381
|
-
on,
|
|
4382
|
-
createEffect,
|
|
4381
|
+
on as on2,
|
|
4382
|
+
createEffect as createEffect2,
|
|
4383
4383
|
createMemo as createMemo3,
|
|
4384
4384
|
createSignal as createSignal3
|
|
4385
4385
|
} from "solid-js";
|
|
4386
4386
|
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
4387
4387
|
|
|
4388
4388
|
// src/components/block/components/interactive-element.tsx
|
|
4389
|
-
import { Show as Show3, createMemo as createMemo2 } from "solid-js";
|
|
4389
|
+
import { Show as Show3, on, createEffect, createMemo as createMemo2, createSignal as createSignal2 } from "solid-js";
|
|
4390
4390
|
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
4391
4391
|
|
|
4392
4392
|
// src/components/awaiter.tsx
|
|
@@ -4400,6 +4400,7 @@ var Awaiter_default = Awaiter;
|
|
|
4400
4400
|
|
|
4401
4401
|
// src/components/block/components/interactive-element.tsx
|
|
4402
4402
|
function InteractiveElement(props) {
|
|
4403
|
+
const [forceRenderCount, setForceRenderCount] = createSignal2(0);
|
|
4403
4404
|
const attributes = createMemo2(() => {
|
|
4404
4405
|
return props.includeBlockProps ? {
|
|
4405
4406
|
...getBlockProperties({
|
|
@@ -4418,6 +4419,21 @@ function InteractiveElement(props) {
|
|
|
4418
4419
|
const targetWrapperProps = createMemo2(() => {
|
|
4419
4420
|
return props.wrapperProps;
|
|
4420
4421
|
});
|
|
4422
|
+
const onUpdateFn_0_props_wrapperProps = createMemo2(() => props.wrapperProps);
|
|
4423
|
+
const onUpdateFn_0_props_block__component__options = createMemo2(
|
|
4424
|
+
() => props.block?.component?.options
|
|
4425
|
+
);
|
|
4426
|
+
function onUpdateFn_0() {
|
|
4427
|
+
}
|
|
4428
|
+
createEffect(
|
|
4429
|
+
on(
|
|
4430
|
+
() => [
|
|
4431
|
+
onUpdateFn_0_props_wrapperProps(),
|
|
4432
|
+
onUpdateFn_0_props_block__component__options()
|
|
4433
|
+
],
|
|
4434
|
+
onUpdateFn_0
|
|
4435
|
+
)
|
|
4436
|
+
);
|
|
4421
4437
|
return <><Show3
|
|
4422
4438
|
fallback={<Dynamic2
|
|
4423
4439
|
{...targetWrapperProps()}
|
|
@@ -4481,8 +4497,8 @@ function ComponentRef(props) {
|
|
|
4481
4497
|
);
|
|
4482
4498
|
function onUpdateFn_0() {
|
|
4483
4499
|
}
|
|
4484
|
-
|
|
4485
|
-
|
|
4500
|
+
createEffect2(
|
|
4501
|
+
on2(
|
|
4486
4502
|
() => [
|
|
4487
4503
|
onUpdateFn_0_props_componentOptions(),
|
|
4488
4504
|
onUpdateFn_0_props_blockChildren()
|
|
@@ -4516,7 +4532,7 @@ function ComponentRef(props) {
|
|
|
4516
4532
|
var Component_ref_default = ComponentRef;
|
|
4517
4533
|
|
|
4518
4534
|
// src/components/block/components/repeated-block.tsx
|
|
4519
|
-
import { on as
|
|
4535
|
+
import { on as on3, createEffect as createEffect3, createMemo as createMemo4, createSignal as createSignal4 } from "solid-js";
|
|
4520
4536
|
function RepeatedBlock(props) {
|
|
4521
4537
|
const [store, setStore] = createSignal4(props.repeatContext);
|
|
4522
4538
|
const onUpdateFn_0_props_repeatContext = createMemo4(
|
|
@@ -4525,7 +4541,7 @@ function RepeatedBlock(props) {
|
|
|
4525
4541
|
function onUpdateFn_0() {
|
|
4526
4542
|
setStore(props.repeatContext);
|
|
4527
4543
|
}
|
|
4528
|
-
|
|
4544
|
+
createEffect3(on3(() => [onUpdateFn_0_props_repeatContext()], onUpdateFn_0));
|
|
4529
4545
|
return <><builder_context_default.Provider value={store()}><Block_default
|
|
4530
4546
|
block={props.block}
|
|
4531
4547
|
context={store()}
|
|
@@ -4694,7 +4710,7 @@ function Block(props) {
|
|
|
4694
4710
|
var Block_default = Block;
|
|
4695
4711
|
|
|
4696
4712
|
// src/components/blocks/blocks-wrapper.tsx
|
|
4697
|
-
import { onMount as onMount3, on as
|
|
4713
|
+
import { onMount as onMount3, on as on5, createEffect as createEffect5, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
|
|
4698
4714
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
4699
4715
|
function BlocksWrapper(props) {
|
|
4700
4716
|
const [shouldUpdate, setShouldUpdate] = createSignal6(false);
|
|
@@ -4747,10 +4763,10 @@ function BlocksWrapper(props) {
|
|
|
4747
4763
|
const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
|
|
4748
4764
|
function onUpdateFn_0() {
|
|
4749
4765
|
}
|
|
4750
|
-
|
|
4766
|
+
createEffect5(on5(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
4751
4767
|
return <>
|
|
4752
4768
|
<Dynamic4
|
|
4753
|
-
class={className() + " dynamic-
|
|
4769
|
+
class={className() + " dynamic-450facf4"}
|
|
4754
4770
|
ref={blocksWrapperRef}
|
|
4755
4771
|
builder-path={dataPath()}
|
|
4756
4772
|
builder-parent-id={props.parent}
|
|
@@ -4762,7 +4778,7 @@ function BlocksWrapper(props) {
|
|
|
4762
4778
|
{...props.BlocksWrapperProps}
|
|
4763
4779
|
component={props.BlocksWrapper}
|
|
4764
4780
|
>{props.children}</Dynamic4>
|
|
4765
|
-
<style>{`.dynamic-
|
|
4781
|
+
<style>{`.dynamic-450facf4 {
|
|
4766
4782
|
display: flex;
|
|
4767
4783
|
flex-direction: column;
|
|
4768
4784
|
align-items: stretch;
|
|
@@ -4780,19 +4796,22 @@ function Blocks(props) {
|
|
|
4780
4796
|
parent={props.parent}
|
|
4781
4797
|
path={props.path}
|
|
4782
4798
|
styleProp={props.styleProp}
|
|
4799
|
+
BlocksWrapperProps={props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
4783
4800
|
classNameProp={props.className}
|
|
4784
4801
|
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4802
|
+
>
|
|
4803
|
+
{props.children}
|
|
4804
|
+
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
4805
|
+
const index = _index();
|
|
4806
|
+
return <Block_default
|
|
4807
|
+
key={block.id}
|
|
4808
|
+
block={block}
|
|
4809
|
+
linkComponent={props.linkComponent}
|
|
4810
|
+
context={props.context || builderContext}
|
|
4811
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
4812
|
+
/>;
|
|
4813
|
+
}}</For3></Show6>
|
|
4814
|
+
</Blocks_wrapper_default></>;
|
|
4796
4815
|
}
|
|
4797
4816
|
var Blocks_default = Blocks;
|
|
4798
4817
|
|
|
@@ -5138,11 +5157,171 @@ function SectionComponent(props) {
|
|
|
5138
5157
|
var section_default = SectionComponent;
|
|
5139
5158
|
|
|
5140
5159
|
// src/blocks/symbol/symbol.tsx
|
|
5141
|
-
import { onMount as onMount10, on as
|
|
5160
|
+
import { onMount as onMount10, on as on9, createEffect as createEffect9, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
5142
5161
|
|
|
5143
5162
|
// src/components/content-variants/content-variants.tsx
|
|
5144
5163
|
import { Show as Show16, For as For9, onMount as onMount9, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
5145
5164
|
|
|
5165
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
5166
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
5167
|
+
function isString(val) {
|
|
5168
|
+
return typeof val === "string";
|
|
5169
|
+
}
|
|
5170
|
+
function isNumber(val) {
|
|
5171
|
+
return typeof val === "number";
|
|
5172
|
+
}
|
|
5173
|
+
function objectMatchesQuery(userattr, query2) {
|
|
5174
|
+
const result = (() => {
|
|
5175
|
+
const property = query2.property;
|
|
5176
|
+
const operator = query2.operator;
|
|
5177
|
+
let testValue = query2.value;
|
|
5178
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
5179
|
+
testValue = query2.value.slice(0, -1);
|
|
5180
|
+
}
|
|
5181
|
+
if (!(property && operator)) {
|
|
5182
|
+
return true;
|
|
5183
|
+
}
|
|
5184
|
+
if (Array.isArray(testValue)) {
|
|
5185
|
+
if (operator === "isNot") {
|
|
5186
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
5187
|
+
property,
|
|
5188
|
+
operator,
|
|
5189
|
+
value: val
|
|
5190
|
+
}));
|
|
5191
|
+
}
|
|
5192
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
5193
|
+
property,
|
|
5194
|
+
operator,
|
|
5195
|
+
value: val
|
|
5196
|
+
}));
|
|
5197
|
+
}
|
|
5198
|
+
const value = userattr[property];
|
|
5199
|
+
if (Array.isArray(value)) {
|
|
5200
|
+
return value.includes(testValue);
|
|
5201
|
+
}
|
|
5202
|
+
switch (operator) {
|
|
5203
|
+
case "is":
|
|
5204
|
+
return value === testValue;
|
|
5205
|
+
case "isNot":
|
|
5206
|
+
return value !== testValue;
|
|
5207
|
+
case "contains":
|
|
5208
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
5209
|
+
case "startsWith":
|
|
5210
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
5211
|
+
case "endsWith":
|
|
5212
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
5213
|
+
case "greaterThan":
|
|
5214
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
5215
|
+
case "lessThan":
|
|
5216
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
5217
|
+
case "greaterThanOrEqualTo":
|
|
5218
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
5219
|
+
case "lessThanOrEqualTo":
|
|
5220
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
5221
|
+
default:
|
|
5222
|
+
return false;
|
|
5223
|
+
}
|
|
5224
|
+
})();
|
|
5225
|
+
return result;
|
|
5226
|
+
}
|
|
5227
|
+
const item = {
|
|
5228
|
+
query,
|
|
5229
|
+
startDate,
|
|
5230
|
+
endDate
|
|
5231
|
+
};
|
|
5232
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
5233
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
5234
|
+
return false;
|
|
5235
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
5236
|
+
return false;
|
|
5237
|
+
}
|
|
5238
|
+
if (!item.query || !item.query.length) {
|
|
5239
|
+
return true;
|
|
5240
|
+
}
|
|
5241
|
+
return item.query.every((filter) => {
|
|
5242
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
5243
|
+
});
|
|
5244
|
+
}
|
|
5245
|
+
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}";
|
|
5246
|
+
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}";
|
|
5247
|
+
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}";
|
|
5248
|
+
|
|
5249
|
+
// src/blocks/personalization-container/helpers.ts
|
|
5250
|
+
var DEFAULT_INDEX = "default";
|
|
5251
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
5252
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
5253
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
5254
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
5255
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
5256
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
5257
|
+
const hasVariants = variants && variants.length > 0;
|
|
5258
|
+
if (TARGET === "reactNative")
|
|
5259
|
+
return false;
|
|
5260
|
+
if (!hasVariants)
|
|
5261
|
+
return false;
|
|
5262
|
+
if (!canTrack)
|
|
5263
|
+
return false;
|
|
5264
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
5265
|
+
return true;
|
|
5266
|
+
if (isBrowser())
|
|
5267
|
+
return false;
|
|
5268
|
+
return true;
|
|
5269
|
+
}
|
|
5270
|
+
function getBlocksToRender({
|
|
5271
|
+
variants,
|
|
5272
|
+
previewingIndex,
|
|
5273
|
+
isHydrated,
|
|
5274
|
+
filteredVariants,
|
|
5275
|
+
fallbackBlocks
|
|
5276
|
+
}) {
|
|
5277
|
+
const fallback = {
|
|
5278
|
+
blocks: fallbackBlocks ?? [],
|
|
5279
|
+
path: "this.children",
|
|
5280
|
+
index: DEFAULT_INDEX
|
|
5281
|
+
};
|
|
5282
|
+
if (isHydrated && isEditing()) {
|
|
5283
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
5284
|
+
const variant = variants?.[previewingIndex];
|
|
5285
|
+
if (variant) {
|
|
5286
|
+
return {
|
|
5287
|
+
blocks: variant.blocks,
|
|
5288
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
5289
|
+
index: previewingIndex
|
|
5290
|
+
};
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
return fallback;
|
|
5294
|
+
}
|
|
5295
|
+
if (isBrowser()) {
|
|
5296
|
+
const winningVariant = filteredVariants?.[0];
|
|
5297
|
+
if (winningVariant && variants) {
|
|
5298
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
5299
|
+
if (variantIndex !== -1) {
|
|
5300
|
+
return {
|
|
5301
|
+
blocks: winningVariant.blocks,
|
|
5302
|
+
path: `variants.${variantIndex}.blocks`,
|
|
5303
|
+
index: variantIndex
|
|
5304
|
+
};
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
return fallback;
|
|
5309
|
+
}
|
|
5310
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
5311
|
+
return `
|
|
5312
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
5313
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
5314
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
5315
|
+
`;
|
|
5316
|
+
};
|
|
5317
|
+
var isHydrationTarget = TARGET === "react";
|
|
5318
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
5319
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5320
|
+
};
|
|
5321
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
5322
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
5323
|
+
};
|
|
5324
|
+
|
|
5146
5325
|
// src/helpers/url.ts
|
|
5147
5326
|
var getTopLevelDomain = (host) => {
|
|
5148
5327
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -6088,7 +6267,8 @@ var componentInfo6 = {
|
|
|
6088
6267
|
name: "PersonalizationContainer",
|
|
6089
6268
|
shouldReceiveBuilderProps: {
|
|
6090
6269
|
builderBlock: true,
|
|
6091
|
-
builderContext: true
|
|
6270
|
+
builderContext: true,
|
|
6271
|
+
builderComponents: true
|
|
6092
6272
|
},
|
|
6093
6273
|
noWrap: true,
|
|
6094
6274
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -6144,199 +6324,6 @@ function isPreviewing(_search) {
|
|
|
6144
6324
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
6145
6325
|
}
|
|
6146
6326
|
|
|
6147
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
6148
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
6149
|
-
function isString(val) {
|
|
6150
|
-
return typeof val === "string";
|
|
6151
|
-
}
|
|
6152
|
-
function isNumber(val) {
|
|
6153
|
-
return typeof val === "number";
|
|
6154
|
-
}
|
|
6155
|
-
function objectMatchesQuery(userattr, query2) {
|
|
6156
|
-
const result = (() => {
|
|
6157
|
-
const property = query2.property;
|
|
6158
|
-
const operator = query2.operator;
|
|
6159
|
-
let testValue = query2.value;
|
|
6160
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
6161
|
-
testValue = query2.value.slice(0, -1);
|
|
6162
|
-
}
|
|
6163
|
-
if (!(property && operator)) {
|
|
6164
|
-
return true;
|
|
6165
|
-
}
|
|
6166
|
-
if (Array.isArray(testValue)) {
|
|
6167
|
-
if (operator === "isNot") {
|
|
6168
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
6169
|
-
property,
|
|
6170
|
-
operator,
|
|
6171
|
-
value: val
|
|
6172
|
-
}));
|
|
6173
|
-
}
|
|
6174
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
6175
|
-
property,
|
|
6176
|
-
operator,
|
|
6177
|
-
value: val
|
|
6178
|
-
}));
|
|
6179
|
-
}
|
|
6180
|
-
const value = userattr[property];
|
|
6181
|
-
if (Array.isArray(value)) {
|
|
6182
|
-
return value.includes(testValue);
|
|
6183
|
-
}
|
|
6184
|
-
switch (operator) {
|
|
6185
|
-
case "is":
|
|
6186
|
-
return value === testValue;
|
|
6187
|
-
case "isNot":
|
|
6188
|
-
return value !== testValue;
|
|
6189
|
-
case "contains":
|
|
6190
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
6191
|
-
case "startsWith":
|
|
6192
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
6193
|
-
case "endsWith":
|
|
6194
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
6195
|
-
case "greaterThan":
|
|
6196
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
6197
|
-
case "lessThan":
|
|
6198
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
6199
|
-
case "greaterThanOrEqualTo":
|
|
6200
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
6201
|
-
case "lessThanOrEqualTo":
|
|
6202
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
6203
|
-
default:
|
|
6204
|
-
return false;
|
|
6205
|
-
}
|
|
6206
|
-
})();
|
|
6207
|
-
return result;
|
|
6208
|
-
}
|
|
6209
|
-
const item = {
|
|
6210
|
-
query,
|
|
6211
|
-
startDate,
|
|
6212
|
-
endDate
|
|
6213
|
-
};
|
|
6214
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
6215
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
6216
|
-
return false;
|
|
6217
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
6218
|
-
return false;
|
|
6219
|
-
}
|
|
6220
|
-
if (!item.query || !item.query.length) {
|
|
6221
|
-
return true;
|
|
6222
|
-
}
|
|
6223
|
-
return item.query.every((filter) => {
|
|
6224
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
6225
|
-
});
|
|
6226
|
-
}
|
|
6227
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
6228
|
-
if (!navigator.cookieEnabled) {
|
|
6229
|
-
return;
|
|
6230
|
-
}
|
|
6231
|
-
function getCookie(name) {
|
|
6232
|
-
const nameEQ = name + '=';
|
|
6233
|
-
const ca = document.cookie.split(';');
|
|
6234
|
-
for (let i = 0; i < ca.length; i++) {
|
|
6235
|
-
let c = ca[i];
|
|
6236
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
6237
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
6238
|
-
}
|
|
6239
|
-
return null;
|
|
6240
|
-
}
|
|
6241
|
-
function removeVariants() {
|
|
6242
|
-
variants?.forEach(function (_, index) {
|
|
6243
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
6244
|
-
});
|
|
6245
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
6246
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
6247
|
-
}
|
|
6248
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
6249
|
-
if (locale) {
|
|
6250
|
-
attributes.locale = locale;
|
|
6251
|
-
}
|
|
6252
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
6253
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
6254
|
-
});
|
|
6255
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
6256
|
-
if (isDebug) {
|
|
6257
|
-
console.debug('PersonalizationContainer', {
|
|
6258
|
-
attributes,
|
|
6259
|
-
variants,
|
|
6260
|
-
winningVariantIndex
|
|
6261
|
-
});
|
|
6262
|
-
}
|
|
6263
|
-
if (winningVariantIndex !== -1) {
|
|
6264
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
6265
|
-
if (winningVariant) {
|
|
6266
|
-
const parentNode = winningVariant.parentNode;
|
|
6267
|
-
if (parentNode) {
|
|
6268
|
-
const newParent = parentNode.cloneNode(false);
|
|
6269
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
6270
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
6271
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
6272
|
-
}
|
|
6273
|
-
if (isDebug) {
|
|
6274
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
6275
|
-
}
|
|
6276
|
-
}
|
|
6277
|
-
} else if (variants && variants.length > 0) {
|
|
6278
|
-
removeVariants();
|
|
6279
|
-
}
|
|
6280
|
-
}`;
|
|
6281
|
-
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}";
|
|
6282
|
-
|
|
6283
|
-
// src/blocks/personalization-container/helpers.ts
|
|
6284
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
6285
|
-
const hasVariants = variants && variants.length > 0;
|
|
6286
|
-
if (TARGET === "reactNative")
|
|
6287
|
-
return false;
|
|
6288
|
-
if (!hasVariants)
|
|
6289
|
-
return false;
|
|
6290
|
-
if (!canTrack)
|
|
6291
|
-
return false;
|
|
6292
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
6293
|
-
return true;
|
|
6294
|
-
if (isBrowser())
|
|
6295
|
-
return false;
|
|
6296
|
-
return true;
|
|
6297
|
-
}
|
|
6298
|
-
function getBlocksToRender({
|
|
6299
|
-
variants,
|
|
6300
|
-
previewingIndex,
|
|
6301
|
-
isHydrated,
|
|
6302
|
-
filteredVariants,
|
|
6303
|
-
fallbackBlocks
|
|
6304
|
-
}) {
|
|
6305
|
-
const fallback = {
|
|
6306
|
-
blocks: fallbackBlocks ?? [],
|
|
6307
|
-
path: "this.children"
|
|
6308
|
-
};
|
|
6309
|
-
if (isHydrated && isEditing()) {
|
|
6310
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
6311
|
-
const variant = variants[previewingIndex];
|
|
6312
|
-
return {
|
|
6313
|
-
blocks: variant.blocks,
|
|
6314
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
6315
|
-
};
|
|
6316
|
-
}
|
|
6317
|
-
return fallback;
|
|
6318
|
-
}
|
|
6319
|
-
if (isBrowser()) {
|
|
6320
|
-
const winningVariant = filteredVariants?.[0];
|
|
6321
|
-
if (winningVariant) {
|
|
6322
|
-
return {
|
|
6323
|
-
blocks: winningVariant.blocks,
|
|
6324
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
6325
|
-
};
|
|
6326
|
-
}
|
|
6327
|
-
}
|
|
6328
|
-
return fallback;
|
|
6329
|
-
}
|
|
6330
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
6331
|
-
return `
|
|
6332
|
-
(function() {
|
|
6333
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
6334
|
-
${PERSONALIZATION_SCRIPT}
|
|
6335
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
6336
|
-
})();
|
|
6337
|
-
`;
|
|
6338
|
-
};
|
|
6339
|
-
|
|
6340
6327
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
6341
6328
|
function PersonalizationContainer(props) {
|
|
6342
6329
|
const [userAttributes, setUserAttributes] = createSignal10(
|
|
@@ -6349,6 +6336,13 @@ function PersonalizationContainer(props) {
|
|
|
6349
6336
|
props.builderContext?.rootState?.locale
|
|
6350
6337
|
)
|
|
6351
6338
|
);
|
|
6339
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal10(
|
|
6340
|
+
getUpdateVisibilityStylesScript(
|
|
6341
|
+
props.variants,
|
|
6342
|
+
props.builderBlock?.id || "none",
|
|
6343
|
+
props.builderContext?.rootState?.locale
|
|
6344
|
+
)
|
|
6345
|
+
);
|
|
6352
6346
|
const [unsubscribers, setUnsubscribers] = createSignal10([]);
|
|
6353
6347
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal10(
|
|
6354
6348
|
checkShouldRenderVariants(
|
|
@@ -6356,7 +6350,14 @@ function PersonalizationContainer(props) {
|
|
|
6356
6350
|
getDefaultCanTrack(props.builderContext?.canTrack)
|
|
6357
6351
|
)
|
|
6358
6352
|
);
|
|
6359
|
-
const [
|
|
6353
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal10(false);
|
|
6354
|
+
const attrs = createMemo10(() => {
|
|
6355
|
+
return {
|
|
6356
|
+
...props.attributes,
|
|
6357
|
+
...{},
|
|
6358
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
6359
|
+
};
|
|
6360
|
+
});
|
|
6360
6361
|
const filteredVariants = createMemo10(() => {
|
|
6361
6362
|
return (props.variants || []).filter((variant) => {
|
|
6362
6363
|
return filterWithCustomTargeting(
|
|
@@ -6376,22 +6377,22 @@ function PersonalizationContainer(props) {
|
|
|
6376
6377
|
return getBlocksToRender({
|
|
6377
6378
|
variants: props.variants,
|
|
6378
6379
|
fallbackBlocks: props.builderBlock?.children,
|
|
6379
|
-
isHydrated:
|
|
6380
|
+
isHydrated: shouldResetVariants(),
|
|
6380
6381
|
filteredVariants: filteredVariants(),
|
|
6381
6382
|
previewingIndex: props.previewingIndex
|
|
6382
6383
|
});
|
|
6383
6384
|
});
|
|
6384
6385
|
const hideVariantsStyleString = createMemo10(() => {
|
|
6385
6386
|
return (props.variants || []).map(
|
|
6386
|
-
(_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `
|
|
6387
|
+
(_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `
|
|
6387
6388
|
).join("");
|
|
6388
6389
|
});
|
|
6389
6390
|
let rootRef;
|
|
6390
6391
|
onMount5(() => {
|
|
6391
|
-
|
|
6392
|
+
setShouldResetVariants(true);
|
|
6392
6393
|
const unsub = userAttributesService.subscribeOnUserAttributesChange(
|
|
6393
|
-
(
|
|
6394
|
-
setUserAttributes(
|
|
6394
|
+
(attrs2) => {
|
|
6395
|
+
setUserAttributes(attrs2);
|
|
6395
6396
|
}
|
|
6396
6397
|
);
|
|
6397
6398
|
if (!(isEditing() || isPreviewing())) {
|
|
@@ -6400,7 +6401,7 @@ function PersonalizationContainer(props) {
|
|
|
6400
6401
|
rootRef.dispatchEvent(
|
|
6401
6402
|
new CustomEvent("builder.variantLoaded", {
|
|
6402
6403
|
detail: {
|
|
6403
|
-
variant: variant ||
|
|
6404
|
+
variant: variant || DEFAULT_INDEX,
|
|
6404
6405
|
content: props.builderContext?.content
|
|
6405
6406
|
},
|
|
6406
6407
|
bubbles: true
|
|
@@ -6412,7 +6413,7 @@ function PersonalizationContainer(props) {
|
|
|
6412
6413
|
rootRef.dispatchEvent(
|
|
6413
6414
|
new CustomEvent("builder.variantDisplayed", {
|
|
6414
6415
|
detail: {
|
|
6415
|
-
variant: variant ||
|
|
6416
|
+
variant: variant || DEFAULT_INDEX,
|
|
6416
6417
|
content: props.builderContext?.content
|
|
6417
6418
|
},
|
|
6418
6419
|
bubbles: true
|
|
@@ -6426,39 +6427,72 @@ function PersonalizationContainer(props) {
|
|
|
6426
6427
|
}
|
|
6427
6428
|
unsubscribers().push(unsub);
|
|
6428
6429
|
});
|
|
6429
|
-
return <><div
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
>
|
|
6434
|
-
<Show10 when={shouldRenderVariants()}>
|
|
6435
|
-
<For6 each={props.variants}>{(variant, _index) => {
|
|
6436
|
-
const index = _index();
|
|
6437
|
-
return <template
|
|
6438
|
-
key={index}
|
|
6439
|
-
data-variant-id={`${props.builderBlock?.id}-${index}`}
|
|
6440
|
-
><Blocks_default
|
|
6441
|
-
blocks={variant.blocks}
|
|
6442
|
-
parent={props.builderBlock?.id}
|
|
6443
|
-
path={`component.options.variants.${index}.blocks`}
|
|
6444
|
-
/></template>;
|
|
6445
|
-
}}</For6>
|
|
6446
|
-
<Inlined_styles_default
|
|
6447
|
-
nonce={props.builderContext?.nonce || ""}
|
|
6448
|
-
styles={hideVariantsStyleString()}
|
|
6449
|
-
id={`variants-styles-${props.builderBlock?.id}`}
|
|
6450
|
-
/>
|
|
6451
|
-
<Inlined_script_default
|
|
6452
|
-
nonce={props.builderContext?.nonce || ""}
|
|
6453
|
-
scriptStr={scriptStr()}
|
|
6454
|
-
id={`variants-script-${props.builderBlock?.id}`}
|
|
6455
|
-
/>
|
|
6456
|
-
</Show10>
|
|
6457
|
-
<Blocks_default
|
|
6430
|
+
return <><div ref={rootRef} {...attrs()}>
|
|
6431
|
+
<Show10
|
|
6432
|
+
when={shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
6433
|
+
><Blocks_default
|
|
6458
6434
|
blocks={blocksToRender().blocks}
|
|
6459
6435
|
parent={props.builderBlock?.id}
|
|
6460
6436
|
path={blocksToRender().path}
|
|
6461
|
-
|
|
6437
|
+
context={props.builderContext}
|
|
6438
|
+
registeredComponents={props.builderComponents}
|
|
6439
|
+
BlocksWrapperProps={{
|
|
6440
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6441
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6442
|
+
}}
|
|
6443
|
+
/></Show10>
|
|
6444
|
+
<Show10
|
|
6445
|
+
when={!shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
6446
|
+
>
|
|
6447
|
+
<Show10 when={shouldRenderVariants()}>
|
|
6448
|
+
<Inlined_styles_default
|
|
6449
|
+
nonce={props.builderContext?.nonce || ""}
|
|
6450
|
+
styles={hideVariantsStyleString()}
|
|
6451
|
+
id={`variants-styles-${props.builderBlock?.id}`}
|
|
6452
|
+
/>
|
|
6453
|
+
<Inlined_script_default
|
|
6454
|
+
nonce={props.builderContext?.nonce || ""}
|
|
6455
|
+
scriptStr={updateVisibilityStylesScript()}
|
|
6456
|
+
id={`variants-visibility-script-${props.builderBlock?.id}`}
|
|
6457
|
+
/>
|
|
6458
|
+
<For6 each={props.variants}>{(variant, _index) => {
|
|
6459
|
+
const index = _index();
|
|
6460
|
+
return <Blocks_default
|
|
6461
|
+
key={`${props.builderBlock?.id}-${index}`}
|
|
6462
|
+
BlocksWrapperProps={{
|
|
6463
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6464
|
+
"aria-hidden": true,
|
|
6465
|
+
hidden: true,
|
|
6466
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
6467
|
+
}}
|
|
6468
|
+
blocks={variant.blocks}
|
|
6469
|
+
parent={props.builderBlock?.id}
|
|
6470
|
+
path={`component.options.variants.${index}.blocks`}
|
|
6471
|
+
context={props.builderContext}
|
|
6472
|
+
registeredComponents={props.builderComponents}
|
|
6473
|
+
><Inlined_script_default
|
|
6474
|
+
nonce={props.builderContext?.nonce || ""}
|
|
6475
|
+
scriptStr={scriptStr()}
|
|
6476
|
+
id={`variants-script-${props.builderBlock?.id}-${index}`}
|
|
6477
|
+
/></Blocks_default>;
|
|
6478
|
+
}}</For6>
|
|
6479
|
+
</Show10>
|
|
6480
|
+
<Blocks_default
|
|
6481
|
+
blocks={blocksToRender().blocks}
|
|
6482
|
+
parent={props.builderBlock?.id}
|
|
6483
|
+
path={blocksToRender().path}
|
|
6484
|
+
context={props.builderContext}
|
|
6485
|
+
registeredComponents={props.builderComponents}
|
|
6486
|
+
BlocksWrapperProps={{
|
|
6487
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
6488
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
6489
|
+
}}
|
|
6490
|
+
><Show10 when={shouldRenderVariants()}><Inlined_script_default
|
|
6491
|
+
nonce={props.builderContext?.nonce || ""}
|
|
6492
|
+
scriptStr={scriptStr()}
|
|
6493
|
+
id={`variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`}
|
|
6494
|
+
/></Show10></Blocks_default>
|
|
6495
|
+
</Show10>
|
|
6462
6496
|
</div></>;
|
|
6463
6497
|
}
|
|
6464
6498
|
var personalization_container_default = PersonalizationContainer;
|
|
@@ -6850,7 +6884,7 @@ var componentInfo12 = {
|
|
|
6850
6884
|
};
|
|
6851
6885
|
|
|
6852
6886
|
// src/blocks/custom-code/custom-code.tsx
|
|
6853
|
-
import { onMount as onMount6, on as
|
|
6887
|
+
import { onMount as onMount6, on as on6, createEffect as createEffect6, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
6854
6888
|
function CustomCode(props) {
|
|
6855
6889
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
6856
6890
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
@@ -6900,7 +6934,7 @@ function CustomCode(props) {
|
|
|
6900
6934
|
runScripts();
|
|
6901
6935
|
}
|
|
6902
6936
|
}
|
|
6903
|
-
|
|
6937
|
+
createEffect6(on6(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
6904
6938
|
return <><div
|
|
6905
6939
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
6906
6940
|
ref={elementRef}
|
|
@@ -6928,7 +6962,7 @@ var componentInfo13 = {
|
|
|
6928
6962
|
};
|
|
6929
6963
|
|
|
6930
6964
|
// src/blocks/embed/embed.tsx
|
|
6931
|
-
import { on as
|
|
6965
|
+
import { on as on7, createEffect as createEffect7, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
6932
6966
|
|
|
6933
6967
|
// src/blocks/embed/helpers.ts
|
|
6934
6968
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -6970,8 +7004,8 @@ function Embed(props) {
|
|
|
6970
7004
|
findAndRunScripts();
|
|
6971
7005
|
}
|
|
6972
7006
|
}
|
|
6973
|
-
|
|
6974
|
-
|
|
7007
|
+
createEffect7(
|
|
7008
|
+
on7(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
6975
7009
|
);
|
|
6976
7010
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
6977
7011
|
}
|
|
@@ -7980,7 +8014,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
7980
8014
|
}, {
|
|
7981
8015
|
component: text_default,
|
|
7982
8016
|
...componentInfo11
|
|
7983
|
-
}, ...TARGET
|
|
8017
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
7984
8018
|
component: personalization_container_default,
|
|
7985
8019
|
...componentInfo6
|
|
7986
8020
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -8017,7 +8051,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
8017
8051
|
|
|
8018
8052
|
// src/components/content-variants/helpers.ts
|
|
8019
8053
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
8020
|
-
var
|
|
8054
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
8021
8055
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
8022
8056
|
...variant,
|
|
8023
8057
|
testVariationId: variant.id,
|
|
@@ -8042,28 +8076,28 @@ var checkShouldRenderVariants2 = ({
|
|
|
8042
8076
|
};
|
|
8043
8077
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8044
8078
|
var isAngularSDK = TARGET === "angular";
|
|
8045
|
-
var
|
|
8079
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
8046
8080
|
var getInitVariantsFnsScriptString = () => `
|
|
8047
8081
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
8048
|
-
window.${
|
|
8082
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
8049
8083
|
`;
|
|
8050
8084
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
8051
8085
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
8052
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
8086
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
8053
8087
|
)`;
|
|
8054
8088
|
var getUpdateVariantVisibilityScript = ({
|
|
8055
8089
|
contentId,
|
|
8056
8090
|
variationId
|
|
8057
|
-
}) => `window.${
|
|
8058
|
-
"${variationId}", "${contentId}", ${
|
|
8091
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
8092
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
8059
8093
|
)`;
|
|
8060
8094
|
|
|
8061
8095
|
// src/components/content/components/enable-editor.tsx
|
|
8062
8096
|
import {
|
|
8063
8097
|
Show as Show14,
|
|
8064
8098
|
onMount as onMount8,
|
|
8065
|
-
on as
|
|
8066
|
-
createEffect as
|
|
8099
|
+
on as on8,
|
|
8100
|
+
createEffect as createEffect8,
|
|
8067
8101
|
createMemo as createMemo16,
|
|
8068
8102
|
createSignal as createSignal16
|
|
8069
8103
|
} from "solid-js";
|
|
@@ -8075,7 +8109,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8075
8109
|
}
|
|
8076
8110
|
|
|
8077
8111
|
// src/constants/sdk-version.ts
|
|
8078
|
-
var SDK_VERSION = "4.0.
|
|
8112
|
+
var SDK_VERSION = "4.0.9";
|
|
8079
8113
|
|
|
8080
8114
|
// src/helpers/sdk-headers.ts
|
|
8081
8115
|
var getSdkHeaders = () => ({
|
|
@@ -9160,15 +9194,15 @@ function EnableEditor(props) {
|
|
|
9160
9194
|
mergeNewContent(props.content);
|
|
9161
9195
|
}
|
|
9162
9196
|
}
|
|
9163
|
-
|
|
9197
|
+
createEffect8(on8(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
9164
9198
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
9165
9199
|
() => props.builderContextSignal.rootState
|
|
9166
9200
|
);
|
|
9167
9201
|
function onUpdateFn_1() {
|
|
9168
9202
|
emitStateUpdate();
|
|
9169
9203
|
}
|
|
9170
|
-
|
|
9171
|
-
|
|
9204
|
+
createEffect8(
|
|
9205
|
+
on8(
|
|
9172
9206
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
9173
9207
|
onUpdateFn_1
|
|
9174
9208
|
)
|
|
@@ -9179,7 +9213,7 @@ function EnableEditor(props) {
|
|
|
9179
9213
|
mergeNewRootState(props.data);
|
|
9180
9214
|
}
|
|
9181
9215
|
}
|
|
9182
|
-
|
|
9216
|
+
createEffect8(on8(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
9183
9217
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
9184
9218
|
function onUpdateFn_3() {
|
|
9185
9219
|
if (props.locale) {
|
|
@@ -9188,7 +9222,7 @@ function EnableEditor(props) {
|
|
|
9188
9222
|
});
|
|
9189
9223
|
}
|
|
9190
9224
|
}
|
|
9191
|
-
|
|
9225
|
+
createEffect8(on8(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
9192
9226
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
9193
9227
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
9194
9228
|
><Dynamic5
|
|
@@ -9434,11 +9468,18 @@ function ContentVariants(props) {
|
|
|
9434
9468
|
setShouldRenderVariants(false);
|
|
9435
9469
|
});
|
|
9436
9470
|
return <><>
|
|
9437
|
-
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9471
|
+
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}>
|
|
9472
|
+
<Inlined_script_default
|
|
9473
|
+
id="builderio-init-variants-fns"
|
|
9474
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
9475
|
+
nonce={props.nonce || ""}
|
|
9476
|
+
/>
|
|
9477
|
+
<Show16 when={SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}><Inlined_script_default
|
|
9478
|
+
id="builderio-init-personalization-variants-fns"
|
|
9479
|
+
nonce={props.nonce || ""}
|
|
9480
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
9481
|
+
/></Show16>
|
|
9482
|
+
</Show16>
|
|
9442
9483
|
<Show16 when={shouldRenderVariants()}>
|
|
9443
9484
|
<Inlined_styles_default
|
|
9444
9485
|
id="builderio-variants"
|
|
@@ -9534,6 +9575,7 @@ var fetchSymbolContent = async ({
|
|
|
9534
9575
|
// src/blocks/symbol/symbol.tsx
|
|
9535
9576
|
function Symbol2(props) {
|
|
9536
9577
|
const [contentToUse, setContentToUse] = createSignal20(props.symbol?.content);
|
|
9578
|
+
const [symbolEntry, setSymbolEntry] = createSignal20(props.symbol?.entry);
|
|
9537
9579
|
const blocksWrapper = createMemo20(() => {
|
|
9538
9580
|
return "div";
|
|
9539
9581
|
});
|
|
@@ -9549,7 +9591,7 @@ function Symbol2(props) {
|
|
|
9549
9591
|
].filter(Boolean).join(" ");
|
|
9550
9592
|
});
|
|
9551
9593
|
function setContent() {
|
|
9552
|
-
if (contentToUse())
|
|
9594
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
9553
9595
|
return;
|
|
9554
9596
|
fetchSymbolContent({
|
|
9555
9597
|
symbol: props.symbol,
|
|
@@ -9557,6 +9599,7 @@ function Symbol2(props) {
|
|
|
9557
9599
|
}).then((newContent) => {
|
|
9558
9600
|
if (newContent) {
|
|
9559
9601
|
setContentToUse(newContent);
|
|
9602
|
+
setSymbolEntry(props.symbol?.entry);
|
|
9560
9603
|
}
|
|
9561
9604
|
});
|
|
9562
9605
|
}
|
|
@@ -9566,7 +9609,7 @@ function Symbol2(props) {
|
|
|
9566
9609
|
function onUpdateFn_0() {
|
|
9567
9610
|
setContent();
|
|
9568
9611
|
}
|
|
9569
|
-
|
|
9612
|
+
createEffect9(on9(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
9570
9613
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
9571
9614
|
nonce={props.builderContext.nonce}
|
|
9572
9615
|
isNestedRender={true}
|