@builder.io/sdk-svelte 5.2.2 → 5.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/components/content-variants/content-variants.svelte +11 -18
- package/lib/browser/components/content-variants/helpers.d.ts +0 -1
- package/lib/browser/components/content-variants/helpers.js +8 -31
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/edge/components/content-variants/content-variants.svelte +11 -18
- package/lib/edge/components/content-variants/helpers.d.ts +0 -1
- package/lib/edge/components/content-variants/helpers.js +8 -31
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/node/components/content-variants/content-variants.svelte +11 -18
- package/lib/node/components/content-variants/helpers.d.ts +0 -1
- package/lib/node/components/content-variants/helpers.js +8 -31
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/package.json +1 -1
- package/src/components/content-variants/content-variants.svelte +10 -18
- package/src/components/content-variants/helpers.ts +8 -31
- package/src/constants/sdk-version.ts +1 -1
|
@@ -8,7 +8,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
|
8
8
|
import ContentComponent from "../content/content.svelte";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
10
10
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
11
|
-
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants,
|
|
11
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers";
|
|
12
12
|
export let canTrack = undefined;
|
|
13
13
|
export let content;
|
|
14
14
|
export let isNestedRender = undefined;
|
|
@@ -63,28 +63,21 @@ onMount(() => {
|
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/>
|
|
66
|
+
{#if SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}
|
|
67
|
+
<InlinedScript
|
|
68
|
+
id="builderio-init-personalization-variants-fns"
|
|
69
|
+
nonce={nonce || ""}
|
|
70
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
71
|
+
/>
|
|
72
|
+
{/if}
|
|
74
73
|
{/if}
|
|
75
74
|
|
|
76
|
-
{#if
|
|
75
|
+
{#if shouldRenderVariants}
|
|
77
76
|
<InlinedScript
|
|
78
|
-
id="builderio-init-
|
|
77
|
+
id="builderio-init-variants-fns"
|
|
78
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
79
79
|
nonce={nonce || ""}
|
|
80
|
-
scriptStr={removeDuplicateScript(
|
|
81
|
-
"builderio-init-personalization-variants-fns",
|
|
82
|
-
getInitPersonalizationVariantsFnsScriptString()
|
|
83
|
-
)}
|
|
84
80
|
/>
|
|
85
|
-
{/if}
|
|
86
|
-
|
|
87
|
-
{#if shouldRenderVariants}
|
|
88
81
|
<InlinedStyles
|
|
89
82
|
id="builderio-variants"
|
|
90
83
|
styles={hideVariantsStyleString()}
|
|
@@ -32,7 +32,6 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const removeDuplicateScript: (id: string, scriptStr: string) => string;
|
|
36
35
|
export declare const getInitVariantsFnsScriptString: () => string;
|
|
37
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
38
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
@@ -43,40 +43,17 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
43
43
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
44
44
|
const isAngularSDK = TARGET === 'angular';
|
|
45
45
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
46
|
-
export const
|
|
46
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
47
47
|
(function() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
51
|
-
|
|
52
|
-
// Synchronously remove any duplicates already in the DOM
|
|
53
|
-
var existing = document.querySelectorAll(selector);
|
|
54
|
-
existing.forEach(function(script, index) {
|
|
55
|
-
if (index > 0) {
|
|
56
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
61
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
62
|
-
window[observerKey] = new MutationObserver(function() {
|
|
63
|
-
var all = document.querySelectorAll(selector);
|
|
64
|
-
for (var i = 1; i < all.length; i++) {
|
|
65
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!window[scriptKey]) {
|
|
72
|
-
window[scriptKey] = true;
|
|
73
|
-
${scriptStr}
|
|
48
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
49
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
74
50
|
}
|
|
51
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
52
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
53
|
+
}${isHydrationTarget ? `
|
|
54
|
+
var thisScriptEl = document.currentScript;
|
|
55
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ''}
|
|
75
56
|
})();
|
|
76
|
-
`;
|
|
77
|
-
export const getInitVariantsFnsScriptString = () => `
|
|
78
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
79
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
80
57
|
`;
|
|
81
58
|
export const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
82
59
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "5.2.
|
|
1
|
+
export declare const SDK_VERSION = "5.2.4";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "5.2.
|
|
1
|
+
export const SDK_VERSION = "5.2.4";
|
|
@@ -8,7 +8,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
|
8
8
|
import ContentComponent from "../content/content.svelte";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
10
10
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
11
|
-
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants,
|
|
11
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers";
|
|
12
12
|
export let canTrack = undefined;
|
|
13
13
|
export let content;
|
|
14
14
|
export let isNestedRender = undefined;
|
|
@@ -63,28 +63,21 @@ onMount(() => {
|
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/>
|
|
66
|
+
{#if SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}
|
|
67
|
+
<InlinedScript
|
|
68
|
+
id="builderio-init-personalization-variants-fns"
|
|
69
|
+
nonce={nonce || ""}
|
|
70
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
71
|
+
/>
|
|
72
|
+
{/if}
|
|
74
73
|
{/if}
|
|
75
74
|
|
|
76
|
-
{#if
|
|
75
|
+
{#if shouldRenderVariants}
|
|
77
76
|
<InlinedScript
|
|
78
|
-
id="builderio-init-
|
|
77
|
+
id="builderio-init-variants-fns"
|
|
78
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
79
79
|
nonce={nonce || ""}
|
|
80
|
-
scriptStr={removeDuplicateScript(
|
|
81
|
-
"builderio-init-personalization-variants-fns",
|
|
82
|
-
getInitPersonalizationVariantsFnsScriptString()
|
|
83
|
-
)}
|
|
84
80
|
/>
|
|
85
|
-
{/if}
|
|
86
|
-
|
|
87
|
-
{#if shouldRenderVariants}
|
|
88
81
|
<InlinedStyles
|
|
89
82
|
id="builderio-variants"
|
|
90
83
|
styles={hideVariantsStyleString()}
|
|
@@ -32,7 +32,6 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const removeDuplicateScript: (id: string, scriptStr: string) => string;
|
|
36
35
|
export declare const getInitVariantsFnsScriptString: () => string;
|
|
37
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
38
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
@@ -43,40 +43,17 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
43
43
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
44
44
|
const isAngularSDK = TARGET === 'angular';
|
|
45
45
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
46
|
-
export const
|
|
46
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
47
47
|
(function() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
51
|
-
|
|
52
|
-
// Synchronously remove any duplicates already in the DOM
|
|
53
|
-
var existing = document.querySelectorAll(selector);
|
|
54
|
-
existing.forEach(function(script, index) {
|
|
55
|
-
if (index > 0) {
|
|
56
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
61
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
62
|
-
window[observerKey] = new MutationObserver(function() {
|
|
63
|
-
var all = document.querySelectorAll(selector);
|
|
64
|
-
for (var i = 1; i < all.length; i++) {
|
|
65
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!window[scriptKey]) {
|
|
72
|
-
window[scriptKey] = true;
|
|
73
|
-
${scriptStr}
|
|
48
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
49
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
74
50
|
}
|
|
51
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
52
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
53
|
+
}${isHydrationTarget ? `
|
|
54
|
+
var thisScriptEl = document.currentScript;
|
|
55
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ''}
|
|
75
56
|
})();
|
|
76
|
-
`;
|
|
77
|
-
export const getInitVariantsFnsScriptString = () => `
|
|
78
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
79
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
80
57
|
`;
|
|
81
58
|
export const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
82
59
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "5.2.
|
|
1
|
+
export declare const SDK_VERSION = "5.2.4";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "5.2.
|
|
1
|
+
export const SDK_VERSION = "5.2.4";
|
|
@@ -8,7 +8,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
|
8
8
|
import ContentComponent from "../content/content.svelte";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
10
10
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
11
|
-
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants,
|
|
11
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers";
|
|
12
12
|
export let canTrack = undefined;
|
|
13
13
|
export let content;
|
|
14
14
|
export let isNestedRender = undefined;
|
|
@@ -63,28 +63,21 @@ onMount(() => {
|
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/>
|
|
66
|
+
{#if SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}
|
|
67
|
+
<InlinedScript
|
|
68
|
+
id="builderio-init-personalization-variants-fns"
|
|
69
|
+
nonce={nonce || ""}
|
|
70
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
71
|
+
/>
|
|
72
|
+
{/if}
|
|
74
73
|
{/if}
|
|
75
74
|
|
|
76
|
-
{#if
|
|
75
|
+
{#if shouldRenderVariants}
|
|
77
76
|
<InlinedScript
|
|
78
|
-
id="builderio-init-
|
|
77
|
+
id="builderio-init-variants-fns"
|
|
78
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
79
79
|
nonce={nonce || ""}
|
|
80
|
-
scriptStr={removeDuplicateScript(
|
|
81
|
-
"builderio-init-personalization-variants-fns",
|
|
82
|
-
getInitPersonalizationVariantsFnsScriptString()
|
|
83
|
-
)}
|
|
84
80
|
/>
|
|
85
|
-
{/if}
|
|
86
|
-
|
|
87
|
-
{#if shouldRenderVariants}
|
|
88
81
|
<InlinedStyles
|
|
89
82
|
id="builderio-variants"
|
|
90
83
|
styles={hideVariantsStyleString()}
|
|
@@ -32,7 +32,6 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const removeDuplicateScript: (id: string, scriptStr: string) => string;
|
|
36
35
|
export declare const getInitVariantsFnsScriptString: () => string;
|
|
37
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
38
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
@@ -43,40 +43,17 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
43
43
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
44
44
|
const isAngularSDK = TARGET === 'angular';
|
|
45
45
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
46
|
-
export const
|
|
46
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
47
47
|
(function() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
51
|
-
|
|
52
|
-
// Synchronously remove any duplicates already in the DOM
|
|
53
|
-
var existing = document.querySelectorAll(selector);
|
|
54
|
-
existing.forEach(function(script, index) {
|
|
55
|
-
if (index > 0) {
|
|
56
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
61
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
62
|
-
window[observerKey] = new MutationObserver(function() {
|
|
63
|
-
var all = document.querySelectorAll(selector);
|
|
64
|
-
for (var i = 1; i < all.length; i++) {
|
|
65
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!window[scriptKey]) {
|
|
72
|
-
window[scriptKey] = true;
|
|
73
|
-
${scriptStr}
|
|
48
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
49
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
74
50
|
}
|
|
51
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
52
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
53
|
+
}${isHydrationTarget ? `
|
|
54
|
+
var thisScriptEl = document.currentScript;
|
|
55
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ''}
|
|
75
56
|
})();
|
|
76
|
-
`;
|
|
77
|
-
export const getInitVariantsFnsScriptString = () => `
|
|
78
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
79
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
80
57
|
`;
|
|
81
58
|
export const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
82
59
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "5.2.
|
|
1
|
+
export declare const SDK_VERSION = "5.2.4";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "5.2.
|
|
1
|
+
export const SDK_VERSION = "5.2.4";
|
package/package.json
CHANGED
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
getInitVariantsFnsScriptString,
|
|
27
27
|
getUpdateCookieAndStylesScript,
|
|
28
28
|
getVariants,
|
|
29
|
-
removeDuplicateScript,
|
|
30
29
|
} from "./helpers";
|
|
31
30
|
|
|
32
31
|
export let canTrack: VariantsProviderProps["canTrack"] = undefined;
|
|
@@ -94,28 +93,21 @@
|
|
|
94
93
|
</script>
|
|
95
94
|
|
|
96
95
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/>
|
|
96
|
+
{#if SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}
|
|
97
|
+
<InlinedScript
|
|
98
|
+
id="builderio-init-personalization-variants-fns"
|
|
99
|
+
nonce={nonce || ""}
|
|
100
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
101
|
+
/>
|
|
102
|
+
{/if}
|
|
105
103
|
{/if}
|
|
106
104
|
|
|
107
|
-
{#if
|
|
105
|
+
{#if shouldRenderVariants}
|
|
108
106
|
<InlinedScript
|
|
109
|
-
id="builderio-init-
|
|
107
|
+
id="builderio-init-variants-fns"
|
|
108
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
110
109
|
nonce={nonce || ""}
|
|
111
|
-
scriptStr={removeDuplicateScript(
|
|
112
|
-
"builderio-init-personalization-variants-fns",
|
|
113
|
-
getInitPersonalizationVariantsFnsScriptString()
|
|
114
|
-
)}
|
|
115
110
|
/>
|
|
116
|
-
{/if}
|
|
117
|
-
|
|
118
|
-
{#if shouldRenderVariants}
|
|
119
111
|
<InlinedStyles
|
|
120
112
|
id="builderio-variants"
|
|
121
113
|
styles={hideVariantsStyleString()}
|
|
@@ -54,40 +54,17 @@ type VariantData = {
|
|
|
54
54
|
const getIsHydrationTarget = (target: Target) => target === 'react' || target === 'reactNative';
|
|
55
55
|
const isAngularSDK = TARGET === 'angular';
|
|
56
56
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
57
|
-
export const
|
|
57
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
58
58
|
(function() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
62
|
-
|
|
63
|
-
// Synchronously remove any duplicates already in the DOM
|
|
64
|
-
var existing = document.querySelectorAll(selector);
|
|
65
|
-
existing.forEach(function(script, index) {
|
|
66
|
-
if (index > 0) {
|
|
67
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
72
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
73
|
-
window[observerKey] = new MutationObserver(function() {
|
|
74
|
-
var all = document.querySelectorAll(selector);
|
|
75
|
-
for (var i = 1; i < all.length; i++) {
|
|
76
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!window[scriptKey]) {
|
|
83
|
-
window[scriptKey] = true;
|
|
84
|
-
${scriptStr}
|
|
59
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
60
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
85
61
|
}
|
|
62
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
63
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
64
|
+
}${isHydrationTarget ? `
|
|
65
|
+
var thisScriptEl = document.currentScript;
|
|
66
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ''}
|
|
86
67
|
})();
|
|
87
|
-
`;
|
|
88
|
-
export const getInitVariantsFnsScriptString = () => `
|
|
89
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
90
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
91
68
|
`;
|
|
92
69
|
export const getUpdateCookieAndStylesScript = (variants: VariantData[], contentId: string) => `
|
|
93
70
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "5.2.
|
|
1
|
+
export const SDK_VERSION = "5.2.4"
|