@builder.io/sdk-qwik 0.24.1 → 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.
- package/lib/browser/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
- package/lib/browser/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
- package/lib/browser/blocks/symbol/symbol.qwik.cjs +7 -3
- package/lib/browser/blocks/symbol/symbol.qwik.mjs +7 -3
- package/lib/browser/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
- package/lib/browser/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
- package/lib/browser/components/content-variants/content-variants.qwik.cjs +37 -41
- package/lib/browser/components/content-variants/content-variants.qwik.mjs +38 -42
- package/lib/browser/components/content-variants/helpers.qwik.cjs +32 -0
- package/lib/browser/components/content-variants/helpers.qwik.mjs +33 -1
- package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
- package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
- package/lib/edge/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
- package/lib/edge/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
- package/lib/edge/blocks/symbol/symbol.qwik.cjs +7 -3
- package/lib/edge/blocks/symbol/symbol.qwik.mjs +7 -3
- package/lib/edge/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
- package/lib/edge/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
- package/lib/edge/components/content-variants/content-variants.qwik.cjs +37 -41
- package/lib/edge/components/content-variants/content-variants.qwik.mjs +38 -42
- package/lib/edge/components/content-variants/helpers.qwik.cjs +32 -0
- package/lib/edge/components/content-variants/helpers.qwik.mjs +33 -1
- package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
- package/lib/node/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
- package/lib/node/blocks/symbol/symbol.qwik.cjs +7 -3
- package/lib/node/blocks/symbol/symbol.qwik.mjs +7 -3
- package/lib/node/components/block/components/component-ref/component-ref.qwik.cjs +8 -2
- package/lib/node/components/block/components/component-ref/component-ref.qwik.mjs +9 -3
- package/lib/node/components/content-variants/content-variants.qwik.cjs +37 -41
- package/lib/node/components/content-variants/content-variants.qwik.mjs +38 -42
- package/lib/node/components/content-variants/helpers.qwik.cjs +32 -0
- package/lib/node/components/content-variants/helpers.qwik.mjs +33 -1
- 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/blocks/symbol/symbol.helpers.d.ts +2 -0
- package/types/src/blocks/symbol/symbol.types.d.ts +2 -0
- package/types/src/components/content-variants/helpers.d.ts +1 -0
- package/types/src/constants/sdk-version.d.ts +1 -1
|
@@ -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(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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, "
|
|
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, "
|
|
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, "
|
|
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, "
|
|
371
|
+
}, 3, "XM_5")
|
|
376
372
|
]
|
|
377
|
-
}, 1, "
|
|
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
|
};
|
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ export interface SymbolInfo {
|
|
|
7
7
|
content?: BuilderContent;
|
|
8
8
|
inline?: boolean;
|
|
9
9
|
dynamic?: boolean;
|
|
10
|
+
ownerId?: string;
|
|
11
|
+
global?: boolean;
|
|
10
12
|
}
|
|
11
13
|
export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp {
|
|
12
14
|
symbol?: SymbolInfo;
|
|
@@ -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.
|
|
1
|
+
export declare const SDK_VERSION = "0.25.2";
|