@builder.io/sdk-qwik 0.25.2 → 0.25.5
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.qwik.cjs +19 -19
- package/lib/browser/components/content-variants/content-variants.qwik.mjs +20 -20
- package/lib/browser/components/content-variants/helpers.qwik.cjs +8 -32
- package/lib/browser/components/content-variants/helpers.qwik.mjs +9 -33
- package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
- package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
- package/lib/edge/components/content-variants/content-variants.qwik.cjs +19 -19
- package/lib/edge/components/content-variants/content-variants.qwik.mjs +20 -20
- package/lib/edge/components/content-variants/helpers.qwik.cjs +8 -32
- package/lib/edge/components/content-variants/helpers.qwik.mjs +9 -33
- package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/components/content-variants/content-variants.qwik.cjs +19 -19
- package/lib/node/components/content-variants/content-variants.qwik.mjs +20 -20
- package/lib/node/components/content-variants/helpers.qwik.cjs +8 -32
- package/lib/node/components/content-variants/helpers.qwik.mjs +9 -33
- package/lib/node/constants/sdk-version.qwik.cjs +1 -1
- package/lib/node/constants/sdk-version.qwik.mjs +1 -1
- package/package.json +1 -1
- package/types/src/components/content-variants/helpers.d.ts +0 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
|
@@ -50,29 +50,13 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
50
50
|
]));
|
|
51
51
|
return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
|
|
52
52
|
children: [
|
|
53
|
-
!props.isNestedRender && target.TARGET !== "reactNative" ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
54
|
-
id: "builderio-init-variants-fns",
|
|
55
|
-
get scriptStr() {
|
|
56
|
-
return helpers.removeDuplicateScript("builderio-init-variants-fns", helpers.getInitVariantsFnsScriptString());
|
|
57
|
-
},
|
|
58
|
-
get nonce() {
|
|
59
|
-
return props.nonce || "";
|
|
60
|
-
},
|
|
61
|
-
[qwik._IMMUTABLE]: {
|
|
62
|
-
id: qwik._IMMUTABLE,
|
|
63
|
-
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
64
|
-
props
|
|
65
|
-
], 'p0.nonce||""'),
|
|
66
|
-
scriptStr: qwik._IMMUTABLE
|
|
67
|
-
}
|
|
68
|
-
}, 3, "XM_0") : null,
|
|
69
|
-
!props.isNestedRender && target.TARGET !== "reactNative" && helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
53
|
+
!props.isNestedRender && target.TARGET !== "reactNative" ? helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
70
54
|
id: "builderio-init-personalization-variants-fns",
|
|
71
55
|
get nonce() {
|
|
72
56
|
return props.nonce || "";
|
|
73
57
|
},
|
|
74
58
|
get scriptStr() {
|
|
75
|
-
return helpers
|
|
59
|
+
return helpers$1.getInitPersonalizationVariantsFnsScriptString();
|
|
76
60
|
},
|
|
77
61
|
[qwik._IMMUTABLE]: {
|
|
78
62
|
id: qwik._IMMUTABLE,
|
|
@@ -81,9 +65,25 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
81
65
|
], 'p0.nonce||""'),
|
|
82
66
|
scriptStr: qwik._IMMUTABLE
|
|
83
67
|
}
|
|
84
|
-
}, 3, "
|
|
68
|
+
}, 3, "XM_0") : null : null,
|
|
85
69
|
state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
86
70
|
children: [
|
|
71
|
+
/* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
72
|
+
id: "builderio-init-variants-fns",
|
|
73
|
+
get scriptStr() {
|
|
74
|
+
return helpers.getInitVariantsFnsScriptString();
|
|
75
|
+
},
|
|
76
|
+
get nonce() {
|
|
77
|
+
return props.nonce || "";
|
|
78
|
+
},
|
|
79
|
+
[qwik._IMMUTABLE]: {
|
|
80
|
+
id: qwik._IMMUTABLE,
|
|
81
|
+
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
82
|
+
props
|
|
83
|
+
], 'p0.nonce||""'),
|
|
84
|
+
scriptStr: qwik._IMMUTABLE
|
|
85
|
+
}
|
|
86
|
+
}, 3, "XM_1"),
|
|
87
87
|
/* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
|
|
88
88
|
id: "builderio-variants",
|
|
89
89
|
get styles() {
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
|
7
7
|
import { ContentComponent } from "../content/content.qwik.mjs";
|
|
8
8
|
import { InlinedScript } from "../inlined-script.qwik.mjs";
|
|
9
9
|
import { InlinedStyles } from "../inlined-styles.qwik.mjs";
|
|
10
|
-
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
|
|
11
11
|
const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
12
12
|
_jsxBranch();
|
|
13
13
|
const state = useStore({
|
|
@@ -48,29 +48,13 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
48
48
|
]));
|
|
49
49
|
return /* @__PURE__ */ _jsxC(Fragment, {
|
|
50
50
|
children: [
|
|
51
|
-
!props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
52
|
-
id: "builderio-init-variants-fns",
|
|
53
|
-
get scriptStr() {
|
|
54
|
-
return removeDuplicateScript("builderio-init-variants-fns", getInitVariantsFnsScriptString());
|
|
55
|
-
},
|
|
56
|
-
get nonce() {
|
|
57
|
-
return props.nonce || "";
|
|
58
|
-
},
|
|
59
|
-
[_IMMUTABLE]: {
|
|
60
|
-
id: _IMMUTABLE,
|
|
61
|
-
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
62
|
-
props
|
|
63
|
-
], 'p0.nonce||""'),
|
|
64
|
-
scriptStr: _IMMUTABLE
|
|
65
|
-
}
|
|
66
|
-
}, 3, "XM_0") : null,
|
|
67
|
-
!props.isNestedRender && TARGET !== "reactNative" && SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
51
|
+
!props.isNestedRender && TARGET !== "reactNative" ? SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
68
52
|
id: "builderio-init-personalization-variants-fns",
|
|
69
53
|
get nonce() {
|
|
70
54
|
return props.nonce || "";
|
|
71
55
|
},
|
|
72
56
|
get scriptStr() {
|
|
73
|
-
return
|
|
57
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
74
58
|
},
|
|
75
59
|
[_IMMUTABLE]: {
|
|
76
60
|
id: _IMMUTABLE,
|
|
@@ -79,9 +63,25 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
79
63
|
], 'p0.nonce||""'),
|
|
80
64
|
scriptStr: _IMMUTABLE
|
|
81
65
|
}
|
|
82
|
-
}, 3, "
|
|
66
|
+
}, 3, "XM_0") : null : null,
|
|
83
67
|
state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
|
|
84
68
|
children: [
|
|
69
|
+
/* @__PURE__ */ _jsxC(InlinedScript, {
|
|
70
|
+
id: "builderio-init-variants-fns",
|
|
71
|
+
get scriptStr() {
|
|
72
|
+
return getInitVariantsFnsScriptString();
|
|
73
|
+
},
|
|
74
|
+
get nonce() {
|
|
75
|
+
return props.nonce || "";
|
|
76
|
+
},
|
|
77
|
+
[_IMMUTABLE]: {
|
|
78
|
+
id: _IMMUTABLE,
|
|
79
|
+
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
80
|
+
props
|
|
81
|
+
], 'p0.nonce||""'),
|
|
82
|
+
scriptStr: _IMMUTABLE
|
|
83
|
+
}
|
|
84
|
+
}, 3, "XM_1"),
|
|
85
85
|
/* @__PURE__ */ _jsxC(InlinedStyles, {
|
|
86
86
|
id: "builderio-variants",
|
|
87
87
|
get styles() {
|
|
@@ -23,40 +23,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
23
23
|
const getIsHydrationTarget = (target2) => target2 === "react" || target2 === "reactNative";
|
|
24
24
|
const isAngularSDK = target.TARGET === "angular";
|
|
25
25
|
const isHydrationTarget = getIsHydrationTarget(target.TARGET);
|
|
26
|
-
const
|
|
26
|
+
const getInitVariantsFnsScriptString = () => `
|
|
27
27
|
(function() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
31
|
-
|
|
32
|
-
// Synchronously remove any duplicates already in the DOM
|
|
33
|
-
var existing = document.querySelectorAll(selector);
|
|
34
|
-
existing.forEach(function(script, index) {
|
|
35
|
-
if (index > 0) {
|
|
36
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
41
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
42
|
-
window[observerKey] = new MutationObserver(function() {
|
|
43
|
-
var all = document.querySelectorAll(selector);
|
|
44
|
-
for (var i = 1; i < all.length; i++) {
|
|
45
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!window[scriptKey]) {
|
|
52
|
-
window[scriptKey] = true;
|
|
53
|
-
${scriptStr}
|
|
28
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
29
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
54
30
|
}
|
|
31
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
32
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
33
|
+
}${isHydrationTarget ? `
|
|
34
|
+
var thisScriptEl = document.currentScript;
|
|
35
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
55
36
|
})();
|
|
56
|
-
`;
|
|
57
|
-
const getInitVariantsFnsScriptString = () => `
|
|
58
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
59
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
60
37
|
`;
|
|
61
38
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
62
39
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -70,4 +47,3 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
|
|
|
70
47
|
exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
|
|
71
48
|
exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
|
|
72
49
|
exports.getVariants = getVariants;
|
|
73
|
-
exports.removeDuplicateScript = removeDuplicateScript;
|
|
@@ -21,40 +21,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
21
21
|
const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
22
22
|
const isAngularSDK = TARGET === "angular";
|
|
23
23
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
24
|
-
const
|
|
24
|
+
const getInitVariantsFnsScriptString = () => `
|
|
25
25
|
(function() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
29
|
-
|
|
30
|
-
// Synchronously remove any duplicates already in the DOM
|
|
31
|
-
var existing = document.querySelectorAll(selector);
|
|
32
|
-
existing.forEach(function(script, index) {
|
|
33
|
-
if (index > 0) {
|
|
34
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
39
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
40
|
-
window[observerKey] = new MutationObserver(function() {
|
|
41
|
-
var all = document.querySelectorAll(selector);
|
|
42
|
-
for (var i = 1; i < all.length; i++) {
|
|
43
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!window[scriptKey]) {
|
|
50
|
-
window[scriptKey] = true;
|
|
51
|
-
${scriptStr}
|
|
26
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
27
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
52
28
|
}
|
|
29
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
30
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
31
|
+
}${isHydrationTarget ? `
|
|
32
|
+
var thisScriptEl = document.currentScript;
|
|
33
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
53
34
|
})();
|
|
54
|
-
`;
|
|
55
|
-
const getInitVariantsFnsScriptString = () => `
|
|
56
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
57
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
58
35
|
`;
|
|
59
36
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
60
37
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -68,6 +45,5 @@ export {
|
|
|
68
45
|
getInitVariantsFnsScriptString,
|
|
69
46
|
getUpdateCookieAndStylesScript,
|
|
70
47
|
getUpdateVariantVisibilityScript,
|
|
71
|
-
getVariants
|
|
72
|
-
removeDuplicateScript
|
|
48
|
+
getVariants
|
|
73
49
|
};
|
|
@@ -50,29 +50,13 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
50
50
|
]));
|
|
51
51
|
return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
|
|
52
52
|
children: [
|
|
53
|
-
!props.isNestedRender && target.TARGET !== "reactNative" ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
54
|
-
id: "builderio-init-variants-fns",
|
|
55
|
-
get scriptStr() {
|
|
56
|
-
return helpers.removeDuplicateScript("builderio-init-variants-fns", helpers.getInitVariantsFnsScriptString());
|
|
57
|
-
},
|
|
58
|
-
get nonce() {
|
|
59
|
-
return props.nonce || "";
|
|
60
|
-
},
|
|
61
|
-
[qwik._IMMUTABLE]: {
|
|
62
|
-
id: qwik._IMMUTABLE,
|
|
63
|
-
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
64
|
-
props
|
|
65
|
-
], 'p0.nonce||""'),
|
|
66
|
-
scriptStr: qwik._IMMUTABLE
|
|
67
|
-
}
|
|
68
|
-
}, 3, "XM_0") : null,
|
|
69
|
-
!props.isNestedRender && target.TARGET !== "reactNative" && helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
53
|
+
!props.isNestedRender && target.TARGET !== "reactNative" ? helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
70
54
|
id: "builderio-init-personalization-variants-fns",
|
|
71
55
|
get nonce() {
|
|
72
56
|
return props.nonce || "";
|
|
73
57
|
},
|
|
74
58
|
get scriptStr() {
|
|
75
|
-
return helpers
|
|
59
|
+
return helpers$1.getInitPersonalizationVariantsFnsScriptString();
|
|
76
60
|
},
|
|
77
61
|
[qwik._IMMUTABLE]: {
|
|
78
62
|
id: qwik._IMMUTABLE,
|
|
@@ -81,9 +65,25 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
81
65
|
], 'p0.nonce||""'),
|
|
82
66
|
scriptStr: qwik._IMMUTABLE
|
|
83
67
|
}
|
|
84
|
-
}, 3, "
|
|
68
|
+
}, 3, "XM_0") : null : null,
|
|
85
69
|
state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
86
70
|
children: [
|
|
71
|
+
/* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
72
|
+
id: "builderio-init-variants-fns",
|
|
73
|
+
get scriptStr() {
|
|
74
|
+
return helpers.getInitVariantsFnsScriptString();
|
|
75
|
+
},
|
|
76
|
+
get nonce() {
|
|
77
|
+
return props.nonce || "";
|
|
78
|
+
},
|
|
79
|
+
[qwik._IMMUTABLE]: {
|
|
80
|
+
id: qwik._IMMUTABLE,
|
|
81
|
+
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
82
|
+
props
|
|
83
|
+
], 'p0.nonce||""'),
|
|
84
|
+
scriptStr: qwik._IMMUTABLE
|
|
85
|
+
}
|
|
86
|
+
}, 3, "XM_1"),
|
|
87
87
|
/* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
|
|
88
88
|
id: "builderio-variants",
|
|
89
89
|
get styles() {
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
|
7
7
|
import { ContentComponent } from "../content/content.qwik.mjs";
|
|
8
8
|
import { InlinedScript } from "../inlined-script.qwik.mjs";
|
|
9
9
|
import { InlinedStyles } from "../inlined-styles.qwik.mjs";
|
|
10
|
-
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
|
|
11
11
|
const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
12
12
|
_jsxBranch();
|
|
13
13
|
const state = useStore({
|
|
@@ -48,29 +48,13 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
48
48
|
]));
|
|
49
49
|
return /* @__PURE__ */ _jsxC(Fragment, {
|
|
50
50
|
children: [
|
|
51
|
-
!props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
52
|
-
id: "builderio-init-variants-fns",
|
|
53
|
-
get scriptStr() {
|
|
54
|
-
return removeDuplicateScript("builderio-init-variants-fns", getInitVariantsFnsScriptString());
|
|
55
|
-
},
|
|
56
|
-
get nonce() {
|
|
57
|
-
return props.nonce || "";
|
|
58
|
-
},
|
|
59
|
-
[_IMMUTABLE]: {
|
|
60
|
-
id: _IMMUTABLE,
|
|
61
|
-
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
62
|
-
props
|
|
63
|
-
], 'p0.nonce||""'),
|
|
64
|
-
scriptStr: _IMMUTABLE
|
|
65
|
-
}
|
|
66
|
-
}, 3, "XM_0") : null,
|
|
67
|
-
!props.isNestedRender && TARGET !== "reactNative" && SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
51
|
+
!props.isNestedRender && TARGET !== "reactNative" ? SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
68
52
|
id: "builderio-init-personalization-variants-fns",
|
|
69
53
|
get nonce() {
|
|
70
54
|
return props.nonce || "";
|
|
71
55
|
},
|
|
72
56
|
get scriptStr() {
|
|
73
|
-
return
|
|
57
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
74
58
|
},
|
|
75
59
|
[_IMMUTABLE]: {
|
|
76
60
|
id: _IMMUTABLE,
|
|
@@ -79,9 +63,25 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
79
63
|
], 'p0.nonce||""'),
|
|
80
64
|
scriptStr: _IMMUTABLE
|
|
81
65
|
}
|
|
82
|
-
}, 3, "
|
|
66
|
+
}, 3, "XM_0") : null : null,
|
|
83
67
|
state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
|
|
84
68
|
children: [
|
|
69
|
+
/* @__PURE__ */ _jsxC(InlinedScript, {
|
|
70
|
+
id: "builderio-init-variants-fns",
|
|
71
|
+
get scriptStr() {
|
|
72
|
+
return getInitVariantsFnsScriptString();
|
|
73
|
+
},
|
|
74
|
+
get nonce() {
|
|
75
|
+
return props.nonce || "";
|
|
76
|
+
},
|
|
77
|
+
[_IMMUTABLE]: {
|
|
78
|
+
id: _IMMUTABLE,
|
|
79
|
+
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
80
|
+
props
|
|
81
|
+
], 'p0.nonce||""'),
|
|
82
|
+
scriptStr: _IMMUTABLE
|
|
83
|
+
}
|
|
84
|
+
}, 3, "XM_1"),
|
|
85
85
|
/* @__PURE__ */ _jsxC(InlinedStyles, {
|
|
86
86
|
id: "builderio-variants",
|
|
87
87
|
get styles() {
|
|
@@ -23,40 +23,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
23
23
|
const getIsHydrationTarget = (target2) => target2 === "react" || target2 === "reactNative";
|
|
24
24
|
const isAngularSDK = target.TARGET === "angular";
|
|
25
25
|
const isHydrationTarget = getIsHydrationTarget(target.TARGET);
|
|
26
|
-
const
|
|
26
|
+
const getInitVariantsFnsScriptString = () => `
|
|
27
27
|
(function() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
31
|
-
|
|
32
|
-
// Synchronously remove any duplicates already in the DOM
|
|
33
|
-
var existing = document.querySelectorAll(selector);
|
|
34
|
-
existing.forEach(function(script, index) {
|
|
35
|
-
if (index > 0) {
|
|
36
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
41
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
42
|
-
window[observerKey] = new MutationObserver(function() {
|
|
43
|
-
var all = document.querySelectorAll(selector);
|
|
44
|
-
for (var i = 1; i < all.length; i++) {
|
|
45
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!window[scriptKey]) {
|
|
52
|
-
window[scriptKey] = true;
|
|
53
|
-
${scriptStr}
|
|
28
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
29
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
54
30
|
}
|
|
31
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
32
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
33
|
+
}${isHydrationTarget ? `
|
|
34
|
+
var thisScriptEl = document.currentScript;
|
|
35
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
55
36
|
})();
|
|
56
|
-
`;
|
|
57
|
-
const getInitVariantsFnsScriptString = () => `
|
|
58
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
59
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
60
37
|
`;
|
|
61
38
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
62
39
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -70,4 +47,3 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
|
|
|
70
47
|
exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
|
|
71
48
|
exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
|
|
72
49
|
exports.getVariants = getVariants;
|
|
73
|
-
exports.removeDuplicateScript = removeDuplicateScript;
|
|
@@ -21,40 +21,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
21
21
|
const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
22
22
|
const isAngularSDK = TARGET === "angular";
|
|
23
23
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
24
|
-
const
|
|
24
|
+
const getInitVariantsFnsScriptString = () => `
|
|
25
25
|
(function() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
29
|
-
|
|
30
|
-
// Synchronously remove any duplicates already in the DOM
|
|
31
|
-
var existing = document.querySelectorAll(selector);
|
|
32
|
-
existing.forEach(function(script, index) {
|
|
33
|
-
if (index > 0) {
|
|
34
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
39
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
40
|
-
window[observerKey] = new MutationObserver(function() {
|
|
41
|
-
var all = document.querySelectorAll(selector);
|
|
42
|
-
for (var i = 1; i < all.length; i++) {
|
|
43
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!window[scriptKey]) {
|
|
50
|
-
window[scriptKey] = true;
|
|
51
|
-
${scriptStr}
|
|
26
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
27
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
52
28
|
}
|
|
29
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
30
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
31
|
+
}${isHydrationTarget ? `
|
|
32
|
+
var thisScriptEl = document.currentScript;
|
|
33
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
53
34
|
})();
|
|
54
|
-
`;
|
|
55
|
-
const getInitVariantsFnsScriptString = () => `
|
|
56
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
57
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
58
35
|
`;
|
|
59
36
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
60
37
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -68,6 +45,5 @@ export {
|
|
|
68
45
|
getInitVariantsFnsScriptString,
|
|
69
46
|
getUpdateCookieAndStylesScript,
|
|
70
47
|
getUpdateVariantVisibilityScript,
|
|
71
|
-
getVariants
|
|
72
|
-
removeDuplicateScript
|
|
48
|
+
getVariants
|
|
73
49
|
};
|
|
@@ -50,29 +50,13 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
50
50
|
]));
|
|
51
51
|
return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
|
|
52
52
|
children: [
|
|
53
|
-
!props.isNestedRender && target.TARGET !== "reactNative" ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
54
|
-
id: "builderio-init-variants-fns",
|
|
55
|
-
get scriptStr() {
|
|
56
|
-
return helpers.removeDuplicateScript("builderio-init-variants-fns", helpers.getInitVariantsFnsScriptString());
|
|
57
|
-
},
|
|
58
|
-
get nonce() {
|
|
59
|
-
return props.nonce || "";
|
|
60
|
-
},
|
|
61
|
-
[qwik._IMMUTABLE]: {
|
|
62
|
-
id: qwik._IMMUTABLE,
|
|
63
|
-
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
64
|
-
props
|
|
65
|
-
], 'p0.nonce||""'),
|
|
66
|
-
scriptStr: qwik._IMMUTABLE
|
|
67
|
-
}
|
|
68
|
-
}, 3, "XM_0") : null,
|
|
69
|
-
!props.isNestedRender && target.TARGET !== "reactNative" && helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
53
|
+
!props.isNestedRender && target.TARGET !== "reactNative" ? helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
70
54
|
id: "builderio-init-personalization-variants-fns",
|
|
71
55
|
get nonce() {
|
|
72
56
|
return props.nonce || "";
|
|
73
57
|
},
|
|
74
58
|
get scriptStr() {
|
|
75
|
-
return helpers
|
|
59
|
+
return helpers$1.getInitPersonalizationVariantsFnsScriptString();
|
|
76
60
|
},
|
|
77
61
|
[qwik._IMMUTABLE]: {
|
|
78
62
|
id: qwik._IMMUTABLE,
|
|
@@ -81,9 +65,25 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
|
|
|
81
65
|
], 'p0.nonce||""'),
|
|
82
66
|
scriptStr: qwik._IMMUTABLE
|
|
83
67
|
}
|
|
84
|
-
}, 3, "
|
|
68
|
+
}, 3, "XM_0") : null : null,
|
|
85
69
|
state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
86
70
|
children: [
|
|
71
|
+
/* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
|
|
72
|
+
id: "builderio-init-variants-fns",
|
|
73
|
+
get scriptStr() {
|
|
74
|
+
return helpers.getInitVariantsFnsScriptString();
|
|
75
|
+
},
|
|
76
|
+
get nonce() {
|
|
77
|
+
return props.nonce || "";
|
|
78
|
+
},
|
|
79
|
+
[qwik._IMMUTABLE]: {
|
|
80
|
+
id: qwik._IMMUTABLE,
|
|
81
|
+
nonce: qwik._fnSignal((p0) => p0.nonce || "", [
|
|
82
|
+
props
|
|
83
|
+
], 'p0.nonce||""'),
|
|
84
|
+
scriptStr: qwik._IMMUTABLE
|
|
85
|
+
}
|
|
86
|
+
}, 3, "XM_1"),
|
|
87
87
|
/* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
|
|
88
88
|
id: "builderio-variants",
|
|
89
89
|
get styles() {
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
|
7
7
|
import { ContentComponent } from "../content/content.qwik.mjs";
|
|
8
8
|
import { InlinedScript } from "../inlined-script.qwik.mjs";
|
|
9
9
|
import { InlinedStyles } from "../inlined-styles.qwik.mjs";
|
|
10
|
-
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
|
|
11
11
|
const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
12
12
|
_jsxBranch();
|
|
13
13
|
const state = useStore({
|
|
@@ -48,29 +48,13 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
48
48
|
]));
|
|
49
49
|
return /* @__PURE__ */ _jsxC(Fragment, {
|
|
50
50
|
children: [
|
|
51
|
-
!props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
52
|
-
id: "builderio-init-variants-fns",
|
|
53
|
-
get scriptStr() {
|
|
54
|
-
return removeDuplicateScript("builderio-init-variants-fns", getInitVariantsFnsScriptString());
|
|
55
|
-
},
|
|
56
|
-
get nonce() {
|
|
57
|
-
return props.nonce || "";
|
|
58
|
-
},
|
|
59
|
-
[_IMMUTABLE]: {
|
|
60
|
-
id: _IMMUTABLE,
|
|
61
|
-
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
62
|
-
props
|
|
63
|
-
], 'p0.nonce||""'),
|
|
64
|
-
scriptStr: _IMMUTABLE
|
|
65
|
-
}
|
|
66
|
-
}, 3, "XM_0") : null,
|
|
67
|
-
!props.isNestedRender && TARGET !== "reactNative" && SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
51
|
+
!props.isNestedRender && TARGET !== "reactNative" ? SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
|
|
68
52
|
id: "builderio-init-personalization-variants-fns",
|
|
69
53
|
get nonce() {
|
|
70
54
|
return props.nonce || "";
|
|
71
55
|
},
|
|
72
56
|
get scriptStr() {
|
|
73
|
-
return
|
|
57
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
74
58
|
},
|
|
75
59
|
[_IMMUTABLE]: {
|
|
76
60
|
id: _IMMUTABLE,
|
|
@@ -79,9 +63,25 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
79
63
|
], 'p0.nonce||""'),
|
|
80
64
|
scriptStr: _IMMUTABLE
|
|
81
65
|
}
|
|
82
|
-
}, 3, "
|
|
66
|
+
}, 3, "XM_0") : null : null,
|
|
83
67
|
state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
|
|
84
68
|
children: [
|
|
69
|
+
/* @__PURE__ */ _jsxC(InlinedScript, {
|
|
70
|
+
id: "builderio-init-variants-fns",
|
|
71
|
+
get scriptStr() {
|
|
72
|
+
return getInitVariantsFnsScriptString();
|
|
73
|
+
},
|
|
74
|
+
get nonce() {
|
|
75
|
+
return props.nonce || "";
|
|
76
|
+
},
|
|
77
|
+
[_IMMUTABLE]: {
|
|
78
|
+
id: _IMMUTABLE,
|
|
79
|
+
nonce: _fnSignal((p0) => p0.nonce || "", [
|
|
80
|
+
props
|
|
81
|
+
], 'p0.nonce||""'),
|
|
82
|
+
scriptStr: _IMMUTABLE
|
|
83
|
+
}
|
|
84
|
+
}, 3, "XM_1"),
|
|
85
85
|
/* @__PURE__ */ _jsxC(InlinedStyles, {
|
|
86
86
|
id: "builderio-variants",
|
|
87
87
|
get styles() {
|
|
@@ -23,40 +23,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
23
23
|
const getIsHydrationTarget = (target2) => target2 === "react" || target2 === "reactNative";
|
|
24
24
|
const isAngularSDK = target.TARGET === "angular";
|
|
25
25
|
const isHydrationTarget = getIsHydrationTarget(target.TARGET);
|
|
26
|
-
const
|
|
26
|
+
const getInitVariantsFnsScriptString = () => `
|
|
27
27
|
(function() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
31
|
-
|
|
32
|
-
// Synchronously remove any duplicates already in the DOM
|
|
33
|
-
var existing = document.querySelectorAll(selector);
|
|
34
|
-
existing.forEach(function(script, index) {
|
|
35
|
-
if (index > 0) {
|
|
36
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
41
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
42
|
-
window[observerKey] = new MutationObserver(function() {
|
|
43
|
-
var all = document.querySelectorAll(selector);
|
|
44
|
-
for (var i = 1; i < all.length; i++) {
|
|
45
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!window[scriptKey]) {
|
|
52
|
-
window[scriptKey] = true;
|
|
53
|
-
${scriptStr}
|
|
28
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
29
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
54
30
|
}
|
|
31
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
32
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
33
|
+
}${isHydrationTarget ? `
|
|
34
|
+
var thisScriptEl = document.currentScript;
|
|
35
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
55
36
|
})();
|
|
56
|
-
`;
|
|
57
|
-
const getInitVariantsFnsScriptString = () => `
|
|
58
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
59
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
60
37
|
`;
|
|
61
38
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
62
39
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -70,4 +47,3 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
|
|
|
70
47
|
exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
|
|
71
48
|
exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
|
|
72
49
|
exports.getVariants = getVariants;
|
|
73
|
-
exports.removeDuplicateScript = removeDuplicateScript;
|
|
@@ -21,40 +21,17 @@ const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
21
21
|
const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
22
22
|
const isAngularSDK = TARGET === "angular";
|
|
23
23
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
24
|
-
const
|
|
24
|
+
const getInitVariantsFnsScriptString = () => `
|
|
25
25
|
(function() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var observerKey = '__builderioScriptObserver_${id}';
|
|
29
|
-
|
|
30
|
-
// Synchronously remove any duplicates already in the DOM
|
|
31
|
-
var existing = document.querySelectorAll(selector);
|
|
32
|
-
existing.forEach(function(script, index) {
|
|
33
|
-
if (index > 0) {
|
|
34
|
-
script.parentNode && script.parentNode.removeChild(script);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Watch for duplicates added later (e.g. RSC streaming chunks)
|
|
39
|
-
if (!window[observerKey] && typeof MutationObserver !== 'undefined') {
|
|
40
|
-
window[observerKey] = new MutationObserver(function() {
|
|
41
|
-
var all = document.querySelectorAll(selector);
|
|
42
|
-
for (var i = 1; i < all.length; i++) {
|
|
43
|
-
all[i].parentNode && all[i].parentNode.removeChild(all[i]);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
window[observerKey].observe(document.documentElement, { childList: true, subtree: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!window[scriptKey]) {
|
|
50
|
-
window[scriptKey] = true;
|
|
51
|
-
${scriptStr}
|
|
26
|
+
if (!window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}) {
|
|
27
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT};
|
|
52
28
|
}
|
|
29
|
+
if (!window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}) {
|
|
30
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT};
|
|
31
|
+
}${isHydrationTarget ? `
|
|
32
|
+
var thisScriptEl = document.currentScript;
|
|
33
|
+
if (thisScriptEl) { thisScriptEl.remove(); }` : ""}
|
|
53
34
|
})();
|
|
54
|
-
`;
|
|
55
|
-
const getInitVariantsFnsScriptString = () => `
|
|
56
|
-
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
57
|
-
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
58
35
|
`;
|
|
59
36
|
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
60
37
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
@@ -68,6 +45,5 @@ export {
|
|
|
68
45
|
getInitVariantsFnsScriptString,
|
|
69
46
|
getUpdateCookieAndStylesScript,
|
|
70
47
|
getUpdateVariantVisibilityScript,
|
|
71
|
-
getVariants
|
|
72
|
-
removeDuplicateScript
|
|
48
|
+
getVariants
|
|
73
49
|
};
|
package/package.json
CHANGED
|
@@ -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 }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.25.
|
|
1
|
+
export declare const SDK_VERSION = "0.25.5";
|