@builder.io/sdk-qwik 0.25.0 → 0.25.2

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.
Files changed (27) hide show
  1. package/lib/browser/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
  2. package/lib/browser/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
  3. package/lib/browser/components/content-variants/content-variants.qwik.cjs +37 -41
  4. package/lib/browser/components/content-variants/content-variants.qwik.mjs +38 -42
  5. package/lib/browser/components/content-variants/helpers.qwik.cjs +32 -0
  6. package/lib/browser/components/content-variants/helpers.qwik.mjs +33 -1
  7. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  8. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  9. package/lib/edge/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
  10. package/lib/edge/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
  11. package/lib/edge/components/content-variants/content-variants.qwik.cjs +37 -41
  12. package/lib/edge/components/content-variants/content-variants.qwik.mjs +38 -42
  13. package/lib/edge/components/content-variants/helpers.qwik.cjs +32 -0
  14. package/lib/edge/components/content-variants/helpers.qwik.mjs +33 -1
  15. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  17. package/lib/node/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
  18. package/lib/node/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
  19. package/lib/node/components/content-variants/content-variants.qwik.cjs +37 -41
  20. package/lib/node/components/content-variants/content-variants.qwik.mjs +38 -42
  21. package/lib/node/components/content-variants/helpers.qwik.cjs +32 -0
  22. package/lib/node/components/content-variants/helpers.qwik.mjs +33 -1
  23. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  24. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  25. package/package.json +1 -1
  26. package/types/src/components/content-variants/helpers.d.ts +1 -0
  27. package/types/src/constants/sdk-version.d.ts +1 -1
@@ -6,6 +6,12 @@ const block = require("../../block.qwik.cjs");
6
6
  const interactiveElement = require("../interactive-element.qwik.cjs");
7
7
  const componentRef_helpers = require("./component-ref.helpers.qwik.cjs");
8
8
  const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
9
+ const blockChildrenToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
10
+ const [props2] = qwik.useLexicalScope();
11
+ return props2.componentRef ? props2.blockChildren : [];
12
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
13
+ props
14
+ ]));
9
15
  const state = qwik.useStore({
10
16
  Wrapper: props.isInteractive ? interactiveElement.InteractiveElement : props.componentRef,
11
17
  shouldUpdate: false
@@ -22,7 +28,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
22
28
  isInteractive: props.isInteractive,
23
29
  contextValue: props.context
24
30
  }),
25
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
31
+ children: (blockChildrenToRender.value || []).map((child) => {
26
32
  return /* @__PURE__ */ qwik._jsxC(block.Block, {
27
33
  block: child,
28
34
  get context() {
@@ -46,7 +52,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
46
52
  ], "p0.registeredComponents")
47
53
  }
48
54
  }, 3, child.id);
49
- }) : null
55
+ })
50
56
  }, 0, "z6_0") : null
51
57
  }, 1, "z6_1");
52
58
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -1,9 +1,15 @@
1
- import { componentQrl, inlinedQrl, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
1
+ import { componentQrl, inlinedQrl, useComputedQrl, useLexicalScope, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
2
2
  import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
3
  import { Block } from "../../block.qwik.mjs";
4
4
  import { InteractiveElement } from "../interactive-element.qwik.mjs";
5
5
  import { getWrapperProps } from "./component-ref.helpers.qwik.mjs";
6
6
  const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
7
+ const blockChildrenToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
8
+ const [props2] = useLexicalScope();
9
+ return props2.componentRef ? props2.blockChildren : [];
10
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
11
+ props
12
+ ]));
7
13
  const state = useStore({
8
14
  Wrapper: props.isInteractive ? InteractiveElement : props.componentRef,
9
15
  shouldUpdate: false
@@ -20,7 +26,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
20
26
  isInteractive: props.isInteractive,
21
27
  contextValue: props.context
22
28
  }),
23
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
29
+ children: (blockChildrenToRender.value || []).map((child) => {
24
30
  return /* @__PURE__ */ _jsxC(Block, {
25
31
  block: child,
26
32
  get context() {
@@ -44,7 +50,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
44
50
  ], "p0.registeredComponents")
45
51
  }
46
52
  }, 3, child.id);
47
- }) : null
53
+ })
48
54
  }, 0, "z6_0") : null
49
55
  }, 1, "z6_1");
50
56
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -50,42 +50,38 @@ 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(jsxRuntime.Fragment, {
54
- children: [
55
- /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
56
- id: "builderio-init-variants-fns",
57
- get scriptStr() {
58
- return helpers.getInitVariantsFnsScriptString();
59
- },
60
- get nonce() {
61
- return props.nonce || "";
62
- },
63
- [qwik._IMMUTABLE]: {
64
- id: qwik._IMMUTABLE,
65
- nonce: qwik._fnSignal((p0) => p0.nonce || "", [
66
- props
67
- ], 'p0.nonce||""'),
68
- scriptStr: qwik._IMMUTABLE
69
- }
70
- }, 3, "XM_0"),
71
- helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
72
- id: "builderio-init-personalization-variants-fns",
73
- get nonce() {
74
- return props.nonce || "";
75
- },
76
- get scriptStr() {
77
- return helpers$1.getInitPersonalizationVariantsFnsScriptString();
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") : null
87
- ]
88
- }, 1, "XM_2") : null,
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, {
70
+ id: "builderio-init-personalization-variants-fns",
71
+ get nonce() {
72
+ return props.nonce || "";
73
+ },
74
+ get scriptStr() {
75
+ return helpers.removeDuplicateScript("builderio-init-personalization-variants-fns", helpers$1.getInitPersonalizationVariantsFnsScriptString());
76
+ },
77
+ [qwik._IMMUTABLE]: {
78
+ id: qwik._IMMUTABLE,
79
+ nonce: qwik._fnSignal((p0) => p0.nonce || "", [
80
+ props
81
+ ], 'p0.nonce||""'),
82
+ scriptStr: qwik._IMMUTABLE
83
+ }
84
+ }, 3, "XM_1") : null,
89
85
  state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
90
86
  children: [
91
87
  /* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
@@ -105,7 +101,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
105
101
  hideVariantsStyleString
106
102
  ], "p0.value")
107
103
  }
108
- }, 3, "XM_3"),
104
+ }, 3, "XM_2"),
109
105
  /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
110
106
  id: "builderio-variants-visibility",
111
107
  get scriptStr() {
@@ -123,7 +119,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
123
119
  updateCookieAndStylesScriptStr
124
120
  ], "p0.value")
125
121
  }
126
- }, 3, "XM_4"),
122
+ }, 3, "XM_3"),
127
123
  (helpers.getVariants(props.content) || []).map((variant) => {
128
124
  return /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
129
125
  get apiHost() {
@@ -248,7 +244,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
248
244
  }, 3, variant.testVariationId);
249
245
  })
250
246
  ]
251
- }, 1, "XM_5") : null,
247
+ }, 1, "XM_4") : null,
252
248
  /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
253
249
  get apiHost() {
254
250
  return props.apiHost;
@@ -374,9 +370,9 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
374
370
  props
375
371
  ], "p0.trustedHosts")
376
372
  }
377
- }, 3, "XM_6")
373
+ }, 3, "XM_5")
378
374
  ]
379
- }, 1, "XM_7");
375
+ }, 1, "XM_6");
380
376
  }, "ContentVariants_component_4tFRiQMMEfM"));
381
377
  exports.ContentVariants = ContentVariants;
382
378
  exports.default = ContentVariants;
@@ -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, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
10
+ import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, removeDuplicateScript, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
11
11
  const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
12
12
  _jsxBranch();
13
13
  const state = useStore({
@@ -48,42 +48,38 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
48
48
  ]));
49
49
  return /* @__PURE__ */ _jsxC(Fragment, {
50
50
  children: [
51
- !props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(Fragment$1, {
52
- children: [
53
- /* @__PURE__ */ _jsxC(InlinedScript, {
54
- id: "builderio-init-variants-fns",
55
- get scriptStr() {
56
- return getInitVariantsFnsScriptString();
57
- },
58
- get nonce() {
59
- return props.nonce || "";
60
- },
61
- [_IMMUTABLE]: {
62
- id: _IMMUTABLE,
63
- nonce: _fnSignal((p0) => p0.nonce || "", [
64
- props
65
- ], 'p0.nonce||""'),
66
- scriptStr: _IMMUTABLE
67
- }
68
- }, 3, "XM_0"),
69
- SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
70
- id: "builderio-init-personalization-variants-fns",
71
- get nonce() {
72
- return props.nonce || "";
73
- },
74
- get scriptStr() {
75
- return getInitPersonalizationVariantsFnsScriptString();
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") : null
85
- ]
86
- }, 1, "XM_2") : null,
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, {
68
+ id: "builderio-init-personalization-variants-fns",
69
+ get nonce() {
70
+ return props.nonce || "";
71
+ },
72
+ get scriptStr() {
73
+ return removeDuplicateScript("builderio-init-personalization-variants-fns", getInitPersonalizationVariantsFnsScriptString());
74
+ },
75
+ [_IMMUTABLE]: {
76
+ id: _IMMUTABLE,
77
+ nonce: _fnSignal((p0) => p0.nonce || "", [
78
+ props
79
+ ], 'p0.nonce||""'),
80
+ scriptStr: _IMMUTABLE
81
+ }
82
+ }, 3, "XM_1") : null,
87
83
  state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
88
84
  children: [
89
85
  /* @__PURE__ */ _jsxC(InlinedStyles, {
@@ -103,7 +99,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
103
99
  hideVariantsStyleString
104
100
  ], "p0.value")
105
101
  }
106
- }, 3, "XM_3"),
102
+ }, 3, "XM_2"),
107
103
  /* @__PURE__ */ _jsxC(InlinedScript, {
108
104
  id: "builderio-variants-visibility",
109
105
  get scriptStr() {
@@ -121,7 +117,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
121
117
  updateCookieAndStylesScriptStr
122
118
  ], "p0.value")
123
119
  }
124
- }, 3, "XM_4"),
120
+ }, 3, "XM_3"),
125
121
  (getVariants(props.content) || []).map((variant) => {
126
122
  return /* @__PURE__ */ _jsxC(ContentComponent, {
127
123
  get apiHost() {
@@ -246,7 +242,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
246
242
  }, 3, variant.testVariationId);
247
243
  })
248
244
  ]
249
- }, 1, "XM_5") : null,
245
+ }, 1, "XM_4") : null,
250
246
  /* @__PURE__ */ _jsxC(ContentComponent, {
251
247
  get apiHost() {
252
248
  return props.apiHost;
@@ -372,9 +368,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
372
368
  props
373
369
  ], "p0.trustedHosts")
374
370
  }
375
- }, 3, "XM_6")
371
+ }, 3, "XM_5")
376
372
  ]
377
- }, 1, "XM_7");
373
+ }, 1, "XM_6");
378
374
  }, "ContentVariants_component_4tFRiQMMEfM"));
379
375
  export {
380
376
  ContentVariants,
@@ -23,6 +23,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
27
+ (function() {
28
+ var selector = 'script[data-id="${id}"]';
29
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
54
+ }
55
+ })();
56
+ `;
26
57
  const getInitVariantsFnsScriptString = () => `
27
58
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
28
59
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -39,3 +70,4 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
39
70
  exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
40
71
  exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
41
72
  exports.getVariants = getVariants;
73
+ exports.removeDuplicateScript = removeDuplicateScript;
@@ -21,6 +21,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
25
+ (function() {
26
+ var selector = 'script[data-id="${id}"]';
27
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
52
+ }
53
+ })();
54
+ `;
24
55
  const getInitVariantsFnsScriptString = () => `
25
56
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
26
57
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -37,5 +68,6 @@ export {
37
68
  getInitVariantsFnsScriptString,
38
69
  getUpdateCookieAndStylesScript,
39
70
  getUpdateVariantVisibilityScript,
40
- getVariants
71
+ getVariants,
72
+ removeDuplicateScript
41
73
  };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.25.0";
3
+ const SDK_VERSION = "0.25.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.25.0";
1
+ const SDK_VERSION = "0.25.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -6,6 +6,12 @@ const block = require("../../block.qwik.cjs");
6
6
  const interactiveElement = require("../interactive-element.qwik.cjs");
7
7
  const componentRef_helpers = require("./component-ref.helpers.qwik.cjs");
8
8
  const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
9
+ const blockChildrenToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
10
+ const [props2] = qwik.useLexicalScope();
11
+ return props2.componentRef ? props2.blockChildren : [];
12
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
13
+ props
14
+ ]));
9
15
  const state = qwik.useStore({
10
16
  Wrapper: props.isInteractive ? interactiveElement.InteractiveElement : props.componentRef,
11
17
  shouldUpdate: false
@@ -22,7 +28,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
22
28
  isInteractive: props.isInteractive,
23
29
  contextValue: props.context
24
30
  }),
25
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
31
+ children: (blockChildrenToRender.value || []).map((child) => {
26
32
  return /* @__PURE__ */ qwik._jsxC(block.Block, {
27
33
  block: child,
28
34
  get context() {
@@ -46,7 +52,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
46
52
  ], "p0.registeredComponents")
47
53
  }
48
54
  }, 3, child.id);
49
- }) : null
55
+ })
50
56
  }, 0, "z6_0") : null
51
57
  }, 1, "z6_1");
52
58
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -1,9 +1,15 @@
1
- import { componentQrl, inlinedQrl, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
1
+ import { componentQrl, inlinedQrl, useComputedQrl, useLexicalScope, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
2
2
  import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
3
  import { Block } from "../../block.qwik.mjs";
4
4
  import { InteractiveElement } from "../interactive-element.qwik.mjs";
5
5
  import { getWrapperProps } from "./component-ref.helpers.qwik.mjs";
6
6
  const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
7
+ const blockChildrenToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
8
+ const [props2] = useLexicalScope();
9
+ return props2.componentRef ? props2.blockChildren : [];
10
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
11
+ props
12
+ ]));
7
13
  const state = useStore({
8
14
  Wrapper: props.isInteractive ? InteractiveElement : props.componentRef,
9
15
  shouldUpdate: false
@@ -20,7 +26,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
20
26
  isInteractive: props.isInteractive,
21
27
  contextValue: props.context
22
28
  }),
23
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
29
+ children: (blockChildrenToRender.value || []).map((child) => {
24
30
  return /* @__PURE__ */ _jsxC(Block, {
25
31
  block: child,
26
32
  get context() {
@@ -44,7 +50,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
44
50
  ], "p0.registeredComponents")
45
51
  }
46
52
  }, 3, child.id);
47
- }) : null
53
+ })
48
54
  }, 0, "z6_0") : null
49
55
  }, 1, "z6_1");
50
56
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -50,42 +50,38 @@ 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(jsxRuntime.Fragment, {
54
- children: [
55
- /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
56
- id: "builderio-init-variants-fns",
57
- get scriptStr() {
58
- return helpers.getInitVariantsFnsScriptString();
59
- },
60
- get nonce() {
61
- return props.nonce || "";
62
- },
63
- [qwik._IMMUTABLE]: {
64
- id: qwik._IMMUTABLE,
65
- nonce: qwik._fnSignal((p0) => p0.nonce || "", [
66
- props
67
- ], 'p0.nonce||""'),
68
- scriptStr: qwik._IMMUTABLE
69
- }
70
- }, 3, "XM_0"),
71
- helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
72
- id: "builderio-init-personalization-variants-fns",
73
- get nonce() {
74
- return props.nonce || "";
75
- },
76
- get scriptStr() {
77
- return helpers$1.getInitPersonalizationVariantsFnsScriptString();
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") : null
87
- ]
88
- }, 1, "XM_2") : null,
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, {
70
+ id: "builderio-init-personalization-variants-fns",
71
+ get nonce() {
72
+ return props.nonce || "";
73
+ },
74
+ get scriptStr() {
75
+ return helpers.removeDuplicateScript("builderio-init-personalization-variants-fns", helpers$1.getInitPersonalizationVariantsFnsScriptString());
76
+ },
77
+ [qwik._IMMUTABLE]: {
78
+ id: qwik._IMMUTABLE,
79
+ nonce: qwik._fnSignal((p0) => p0.nonce || "", [
80
+ props
81
+ ], 'p0.nonce||""'),
82
+ scriptStr: qwik._IMMUTABLE
83
+ }
84
+ }, 3, "XM_1") : null,
89
85
  state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
90
86
  children: [
91
87
  /* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
@@ -105,7 +101,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
105
101
  hideVariantsStyleString
106
102
  ], "p0.value")
107
103
  }
108
- }, 3, "XM_3"),
104
+ }, 3, "XM_2"),
109
105
  /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
110
106
  id: "builderio-variants-visibility",
111
107
  get scriptStr() {
@@ -123,7 +119,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
123
119
  updateCookieAndStylesScriptStr
124
120
  ], "p0.value")
125
121
  }
126
- }, 3, "XM_4"),
122
+ }, 3, "XM_3"),
127
123
  (helpers.getVariants(props.content) || []).map((variant) => {
128
124
  return /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
129
125
  get apiHost() {
@@ -248,7 +244,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
248
244
  }, 3, variant.testVariationId);
249
245
  })
250
246
  ]
251
- }, 1, "XM_5") : null,
247
+ }, 1, "XM_4") : null,
252
248
  /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
253
249
  get apiHost() {
254
250
  return props.apiHost;
@@ -374,9 +370,9 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
374
370
  props
375
371
  ], "p0.trustedHosts")
376
372
  }
377
- }, 3, "XM_6")
373
+ }, 3, "XM_5")
378
374
  ]
379
- }, 1, "XM_7");
375
+ }, 1, "XM_6");
380
376
  }, "ContentVariants_component_4tFRiQMMEfM"));
381
377
  exports.ContentVariants = ContentVariants;
382
378
  exports.default = ContentVariants;
@@ -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, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
10
+ import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, removeDuplicateScript, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
11
11
  const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
12
12
  _jsxBranch();
13
13
  const state = useStore({
@@ -48,42 +48,38 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
48
48
  ]));
49
49
  return /* @__PURE__ */ _jsxC(Fragment, {
50
50
  children: [
51
- !props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(Fragment$1, {
52
- children: [
53
- /* @__PURE__ */ _jsxC(InlinedScript, {
54
- id: "builderio-init-variants-fns",
55
- get scriptStr() {
56
- return getInitVariantsFnsScriptString();
57
- },
58
- get nonce() {
59
- return props.nonce || "";
60
- },
61
- [_IMMUTABLE]: {
62
- id: _IMMUTABLE,
63
- nonce: _fnSignal((p0) => p0.nonce || "", [
64
- props
65
- ], 'p0.nonce||""'),
66
- scriptStr: _IMMUTABLE
67
- }
68
- }, 3, "XM_0"),
69
- SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
70
- id: "builderio-init-personalization-variants-fns",
71
- get nonce() {
72
- return props.nonce || "";
73
- },
74
- get scriptStr() {
75
- return getInitPersonalizationVariantsFnsScriptString();
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") : null
85
- ]
86
- }, 1, "XM_2") : null,
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, {
68
+ id: "builderio-init-personalization-variants-fns",
69
+ get nonce() {
70
+ return props.nonce || "";
71
+ },
72
+ get scriptStr() {
73
+ return removeDuplicateScript("builderio-init-personalization-variants-fns", getInitPersonalizationVariantsFnsScriptString());
74
+ },
75
+ [_IMMUTABLE]: {
76
+ id: _IMMUTABLE,
77
+ nonce: _fnSignal((p0) => p0.nonce || "", [
78
+ props
79
+ ], 'p0.nonce||""'),
80
+ scriptStr: _IMMUTABLE
81
+ }
82
+ }, 3, "XM_1") : null,
87
83
  state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
88
84
  children: [
89
85
  /* @__PURE__ */ _jsxC(InlinedStyles, {
@@ -103,7 +99,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
103
99
  hideVariantsStyleString
104
100
  ], "p0.value")
105
101
  }
106
- }, 3, "XM_3"),
102
+ }, 3, "XM_2"),
107
103
  /* @__PURE__ */ _jsxC(InlinedScript, {
108
104
  id: "builderio-variants-visibility",
109
105
  get scriptStr() {
@@ -121,7 +117,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
121
117
  updateCookieAndStylesScriptStr
122
118
  ], "p0.value")
123
119
  }
124
- }, 3, "XM_4"),
120
+ }, 3, "XM_3"),
125
121
  (getVariants(props.content) || []).map((variant) => {
126
122
  return /* @__PURE__ */ _jsxC(ContentComponent, {
127
123
  get apiHost() {
@@ -246,7 +242,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
246
242
  }, 3, variant.testVariationId);
247
243
  })
248
244
  ]
249
- }, 1, "XM_5") : null,
245
+ }, 1, "XM_4") : null,
250
246
  /* @__PURE__ */ _jsxC(ContentComponent, {
251
247
  get apiHost() {
252
248
  return props.apiHost;
@@ -372,9 +368,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
372
368
  props
373
369
  ], "p0.trustedHosts")
374
370
  }
375
- }, 3, "XM_6")
371
+ }, 3, "XM_5")
376
372
  ]
377
- }, 1, "XM_7");
373
+ }, 1, "XM_6");
378
374
  }, "ContentVariants_component_4tFRiQMMEfM"));
379
375
  export {
380
376
  ContentVariants,
@@ -23,6 +23,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
27
+ (function() {
28
+ var selector = 'script[data-id="${id}"]';
29
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
54
+ }
55
+ })();
56
+ `;
26
57
  const getInitVariantsFnsScriptString = () => `
27
58
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
28
59
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -39,3 +70,4 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
39
70
  exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
40
71
  exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
41
72
  exports.getVariants = getVariants;
73
+ exports.removeDuplicateScript = removeDuplicateScript;
@@ -21,6 +21,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
25
+ (function() {
26
+ var selector = 'script[data-id="${id}"]';
27
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
52
+ }
53
+ })();
54
+ `;
24
55
  const getInitVariantsFnsScriptString = () => `
25
56
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
26
57
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -37,5 +68,6 @@ export {
37
68
  getInitVariantsFnsScriptString,
38
69
  getUpdateCookieAndStylesScript,
39
70
  getUpdateVariantVisibilityScript,
40
- getVariants
71
+ getVariants,
72
+ removeDuplicateScript
41
73
  };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.25.0";
3
+ const SDK_VERSION = "0.25.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.25.0";
1
+ const SDK_VERSION = "0.25.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -6,6 +6,12 @@ const block = require("../../block.qwik.cjs");
6
6
  const interactiveElement = require("../interactive-element.qwik.cjs");
7
7
  const componentRef_helpers = require("./component-ref.helpers.qwik.cjs");
8
8
  const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
9
+ const blockChildrenToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
10
+ const [props2] = qwik.useLexicalScope();
11
+ return props2.componentRef ? props2.blockChildren : [];
12
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
13
+ props
14
+ ]));
9
15
  const state = qwik.useStore({
10
16
  Wrapper: props.isInteractive ? interactiveElement.InteractiveElement : props.componentRef,
11
17
  shouldUpdate: false
@@ -22,7 +28,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
22
28
  isInteractive: props.isInteractive,
23
29
  contextValue: props.context
24
30
  }),
25
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
31
+ children: (blockChildrenToRender.value || []).map((child) => {
26
32
  return /* @__PURE__ */ qwik._jsxC(block.Block, {
27
33
  block: child,
28
34
  get context() {
@@ -46,7 +52,7 @@ const ComponentRef = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
46
52
  ], "p0.registeredComponents")
47
53
  }
48
54
  }, 3, child.id);
49
- }) : null
55
+ })
50
56
  }, 0, "z6_0") : null
51
57
  }, 1, "z6_1");
52
58
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -1,9 +1,15 @@
1
- import { componentQrl, inlinedQrl, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
1
+ import { componentQrl, inlinedQrl, useComputedQrl, useLexicalScope, useStore, _jsxC, _IMMUTABLE, _fnSignal } from "@builder.io/qwik";
2
2
  import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
3
  import { Block } from "../../block.qwik.mjs";
4
4
  import { InteractiveElement } from "../interactive-element.qwik.mjs";
5
5
  import { getWrapperProps } from "./component-ref.helpers.qwik.mjs";
6
6
  const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
7
+ const blockChildrenToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
8
+ const [props2] = useLexicalScope();
9
+ return props2.componentRef ? props2.blockChildren : [];
10
+ }, "ComponentRef_component_blockChildrenToRender_useComputed_HF18bwDAU0c", [
11
+ props
12
+ ]));
7
13
  const state = useStore({
8
14
  Wrapper: props.isInteractive ? InteractiveElement : props.componentRef,
9
15
  shouldUpdate: false
@@ -20,7 +26,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
20
26
  isInteractive: props.isInteractive,
21
27
  contextValue: props.context
22
28
  }),
23
- children: props.componentRef ? (props.blockChildren || []).map((child) => {
29
+ children: (blockChildrenToRender.value || []).map((child) => {
24
30
  return /* @__PURE__ */ _jsxC(Block, {
25
31
  block: child,
26
32
  get context() {
@@ -44,7 +50,7 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
44
50
  ], "p0.registeredComponents")
45
51
  }
46
52
  }, 3, child.id);
47
- }) : null
53
+ })
48
54
  }, 0, "z6_0") : null
49
55
  }, 1, "z6_1");
50
56
  }, "ComponentRef_component_tFQoBV6UFdc"));
@@ -50,42 +50,38 @@ 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(jsxRuntime.Fragment, {
54
- children: [
55
- /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
56
- id: "builderio-init-variants-fns",
57
- get scriptStr() {
58
- return helpers.getInitVariantsFnsScriptString();
59
- },
60
- get nonce() {
61
- return props.nonce || "";
62
- },
63
- [qwik._IMMUTABLE]: {
64
- id: qwik._IMMUTABLE,
65
- nonce: qwik._fnSignal((p0) => p0.nonce || "", [
66
- props
67
- ], 'p0.nonce||""'),
68
- scriptStr: qwik._IMMUTABLE
69
- }
70
- }, 3, "XM_0"),
71
- helpers$1.SDKS_SUPPORTING_PERSONALIZATION.includes(target.TARGET) ? /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
72
- id: "builderio-init-personalization-variants-fns",
73
- get nonce() {
74
- return props.nonce || "";
75
- },
76
- get scriptStr() {
77
- return helpers$1.getInitPersonalizationVariantsFnsScriptString();
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") : null
87
- ]
88
- }, 1, "XM_2") : null,
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, {
70
+ id: "builderio-init-personalization-variants-fns",
71
+ get nonce() {
72
+ return props.nonce || "";
73
+ },
74
+ get scriptStr() {
75
+ return helpers.removeDuplicateScript("builderio-init-personalization-variants-fns", helpers$1.getInitPersonalizationVariantsFnsScriptString());
76
+ },
77
+ [qwik._IMMUTABLE]: {
78
+ id: qwik._IMMUTABLE,
79
+ nonce: qwik._fnSignal((p0) => p0.nonce || "", [
80
+ props
81
+ ], 'p0.nonce||""'),
82
+ scriptStr: qwik._IMMUTABLE
83
+ }
84
+ }, 3, "XM_1") : null,
89
85
  state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
90
86
  children: [
91
87
  /* @__PURE__ */ qwik._jsxC(inlinedStyles.InlinedStyles, {
@@ -105,7 +101,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
105
101
  hideVariantsStyleString
106
102
  ], "p0.value")
107
103
  }
108
- }, 3, "XM_3"),
104
+ }, 3, "XM_2"),
109
105
  /* @__PURE__ */ qwik._jsxC(inlinedScript.InlinedScript, {
110
106
  id: "builderio-variants-visibility",
111
107
  get scriptStr() {
@@ -123,7 +119,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
123
119
  updateCookieAndStylesScriptStr
124
120
  ], "p0.value")
125
121
  }
126
- }, 3, "XM_4"),
122
+ }, 3, "XM_3"),
127
123
  (helpers.getVariants(props.content) || []).map((variant) => {
128
124
  return /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
129
125
  get apiHost() {
@@ -248,7 +244,7 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
248
244
  }, 3, variant.testVariationId);
249
245
  })
250
246
  ]
251
- }, 1, "XM_5") : null,
247
+ }, 1, "XM_4") : null,
252
248
  /* @__PURE__ */ qwik._jsxC(content.ContentComponent, {
253
249
  get apiHost() {
254
250
  return props.apiHost;
@@ -374,9 +370,9 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
374
370
  props
375
371
  ], "p0.trustedHosts")
376
372
  }
377
- }, 3, "XM_6")
373
+ }, 3, "XM_5")
378
374
  ]
379
- }, 1, "XM_7");
375
+ }, 1, "XM_6");
380
376
  }, "ContentVariants_component_4tFRiQMMEfM"));
381
377
  exports.ContentVariants = ContentVariants;
382
378
  exports.default = ContentVariants;
@@ -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, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
10
+ import { checkShouldRenderVariants, getUpdateCookieAndStylesScript, getVariants, removeDuplicateScript, getInitVariantsFnsScriptString } from "./helpers.qwik.mjs";
11
11
  const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
12
12
  _jsxBranch();
13
13
  const state = useStore({
@@ -48,42 +48,38 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
48
48
  ]));
49
49
  return /* @__PURE__ */ _jsxC(Fragment, {
50
50
  children: [
51
- !props.isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(Fragment$1, {
52
- children: [
53
- /* @__PURE__ */ _jsxC(InlinedScript, {
54
- id: "builderio-init-variants-fns",
55
- get scriptStr() {
56
- return getInitVariantsFnsScriptString();
57
- },
58
- get nonce() {
59
- return props.nonce || "";
60
- },
61
- [_IMMUTABLE]: {
62
- id: _IMMUTABLE,
63
- nonce: _fnSignal((p0) => p0.nonce || "", [
64
- props
65
- ], 'p0.nonce||""'),
66
- scriptStr: _IMMUTABLE
67
- }
68
- }, 3, "XM_0"),
69
- SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? /* @__PURE__ */ _jsxC(InlinedScript, {
70
- id: "builderio-init-personalization-variants-fns",
71
- get nonce() {
72
- return props.nonce || "";
73
- },
74
- get scriptStr() {
75
- return getInitPersonalizationVariantsFnsScriptString();
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") : null
85
- ]
86
- }, 1, "XM_2") : null,
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, {
68
+ id: "builderio-init-personalization-variants-fns",
69
+ get nonce() {
70
+ return props.nonce || "";
71
+ },
72
+ get scriptStr() {
73
+ return removeDuplicateScript("builderio-init-personalization-variants-fns", getInitPersonalizationVariantsFnsScriptString());
74
+ },
75
+ [_IMMUTABLE]: {
76
+ id: _IMMUTABLE,
77
+ nonce: _fnSignal((p0) => p0.nonce || "", [
78
+ props
79
+ ], 'p0.nonce||""'),
80
+ scriptStr: _IMMUTABLE
81
+ }
82
+ }, 3, "XM_1") : null,
87
83
  state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment$1, {
88
84
  children: [
89
85
  /* @__PURE__ */ _jsxC(InlinedStyles, {
@@ -103,7 +99,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
103
99
  hideVariantsStyleString
104
100
  ], "p0.value")
105
101
  }
106
- }, 3, "XM_3"),
102
+ }, 3, "XM_2"),
107
103
  /* @__PURE__ */ _jsxC(InlinedScript, {
108
104
  id: "builderio-variants-visibility",
109
105
  get scriptStr() {
@@ -121,7 +117,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
121
117
  updateCookieAndStylesScriptStr
122
118
  ], "p0.value")
123
119
  }
124
- }, 3, "XM_4"),
120
+ }, 3, "XM_3"),
125
121
  (getVariants(props.content) || []).map((variant) => {
126
122
  return /* @__PURE__ */ _jsxC(ContentComponent, {
127
123
  get apiHost() {
@@ -246,7 +242,7 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
246
242
  }, 3, variant.testVariationId);
247
243
  })
248
244
  ]
249
- }, 1, "XM_5") : null,
245
+ }, 1, "XM_4") : null,
250
246
  /* @__PURE__ */ _jsxC(ContentComponent, {
251
247
  get apiHost() {
252
248
  return props.apiHost;
@@ -372,9 +368,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
372
368
  props
373
369
  ], "p0.trustedHosts")
374
370
  }
375
- }, 3, "XM_6")
371
+ }, 3, "XM_5")
376
372
  ]
377
- }, 1, "XM_7");
373
+ }, 1, "XM_6");
378
374
  }, "ContentVariants_component_4tFRiQMMEfM"));
379
375
  export {
380
376
  ContentVariants,
@@ -23,6 +23,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
27
+ (function() {
28
+ var selector = 'script[data-id="${id}"]';
29
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
54
+ }
55
+ })();
56
+ `;
26
57
  const getInitVariantsFnsScriptString = () => `
27
58
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${inlinedFns.UPDATE_COOKIES_AND_STYLES_SCRIPT}
28
59
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${inlinedFns.UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -39,3 +70,4 @@ exports.getInitVariantsFnsScriptString = getInitVariantsFnsScriptString;
39
70
  exports.getUpdateCookieAndStylesScript = getUpdateCookieAndStylesScript;
40
71
  exports.getUpdateVariantVisibilityScript = getUpdateVariantVisibilityScript;
41
72
  exports.getVariants = getVariants;
73
+ exports.removeDuplicateScript = removeDuplicateScript;
@@ -21,6 +21,37 @@ 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 removeDuplicateScript = (id, scriptStr) => `
25
+ (function() {
26
+ var selector = 'script[data-id="${id}"]';
27
+ var scriptKey = '__builderioScriptInitialized_${id}';
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}
52
+ }
53
+ })();
54
+ `;
24
55
  const getInitVariantsFnsScriptString = () => `
25
56
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
26
57
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
@@ -37,5 +68,6 @@ export {
37
68
  getInitVariantsFnsScriptString,
38
69
  getUpdateCookieAndStylesScript,
39
70
  getUpdateVariantVisibilityScript,
40
- getVariants
71
+ getVariants,
72
+ removeDuplicateScript
41
73
  };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.25.0";
3
+ const SDK_VERSION = "0.25.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.25.0";
1
+ const SDK_VERSION = "0.25.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,6 +32,7 @@ type VariantData = {
32
32
  id: string;
33
33
  testRatio?: number;
34
34
  };
35
+ export declare const removeDuplicateScript: (id: string, scriptStr: string) => string;
35
36
  export declare const getInitVariantsFnsScriptString: () => string;
36
37
  export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
37
38
  export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.25.0";
1
+ export declare const SDK_VERSION = "0.25.2";