@builder.io/sdk-qwik 0.18.13 → 0.18.14
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/personalization-container/helpers.qwik.cjs +4 -2
- package/lib/browser/blocks/personalization-container/helpers.qwik.mjs +4 -2
- package/lib/browser/blocks/personalization-container/personalization-container.qwik.cjs +18 -14
- package/lib/browser/blocks/personalization-container/personalization-container.qwik.mjs +20 -16
- package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
- package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
- package/lib/browser/helpers/no-serialize-wrapper.qwik.cjs +7 -0
- package/lib/browser/helpers/no-serialize-wrapper.qwik.mjs +7 -0
- package/lib/browser/helpers/user-attributes.qwik.cjs +15 -4
- package/lib/browser/helpers/user-attributes.qwik.mjs +15 -4
- package/lib/edge/blocks/personalization-container/helpers.qwik.cjs +4 -2
- package/lib/edge/blocks/personalization-container/helpers.qwik.mjs +4 -2
- package/lib/edge/blocks/personalization-container/personalization-container.qwik.cjs +18 -14
- package/lib/edge/blocks/personalization-container/personalization-container.qwik.mjs +20 -16
- package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
- package/lib/edge/helpers/no-serialize-wrapper.qwik.cjs +7 -0
- package/lib/edge/helpers/no-serialize-wrapper.qwik.mjs +7 -0
- package/lib/edge/helpers/user-attributes.qwik.cjs +15 -4
- package/lib/edge/helpers/user-attributes.qwik.mjs +15 -4
- package/lib/node/blocks/personalization-container/helpers.qwik.cjs +4 -2
- package/lib/node/blocks/personalization-container/helpers.qwik.mjs +4 -2
- package/lib/node/blocks/personalization-container/personalization-container.qwik.cjs +18 -14
- package/lib/node/blocks/personalization-container/personalization-container.qwik.mjs +20 -16
- package/lib/node/constants/sdk-version.qwik.cjs +1 -1
- package/lib/node/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/helpers/no-serialize-wrapper.qwik.cjs +7 -0
- package/lib/node/helpers/no-serialize-wrapper.qwik.mjs +7 -0
- package/lib/node/helpers/user-attributes.qwik.cjs +15 -4
- package/lib/node/helpers/user-attributes.qwik.mjs +15 -4
- package/package.json +1 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/helpers/no-serialize-wrapper.d.ts +1 -0
- package/types/src/helpers/user-attributes.d.ts +6 -2
|
@@ -11,11 +11,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
11
11
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
12
12
|
"react",
|
|
13
13
|
"vue",
|
|
14
|
-
"svelte"
|
|
14
|
+
"svelte",
|
|
15
|
+
"qwik"
|
|
15
16
|
];
|
|
16
17
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
17
18
|
"vue",
|
|
18
|
-
"svelte"
|
|
19
|
+
"svelte",
|
|
20
|
+
"qwik"
|
|
19
21
|
];
|
|
20
22
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
21
23
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -10,11 +10,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
10
10
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
11
11
|
"react",
|
|
12
12
|
"vue",
|
|
13
|
-
"svelte"
|
|
13
|
+
"svelte",
|
|
14
|
+
"qwik"
|
|
14
15
|
];
|
|
15
16
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
16
17
|
"vue",
|
|
17
|
-
"svelte"
|
|
18
|
+
"svelte",
|
|
19
|
+
"qwik"
|
|
18
20
|
];
|
|
19
21
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
20
22
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -16,6 +16,14 @@ const inlinedFns = require("./helpers/inlined-fns.qwik.cjs");
|
|
|
16
16
|
const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
18
|
qwik._jsxBranch();
|
|
19
|
+
const state = qwik.useStore({
|
|
20
|
+
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
21
|
+
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
22
|
+
shouldResetVariants: false,
|
|
23
|
+
unsubscribers: [],
|
|
24
|
+
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
25
|
+
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
26
|
+
});
|
|
19
27
|
const attrs = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
20
28
|
const [props2] = qwik.useLexicalScope();
|
|
21
29
|
return {
|
|
@@ -26,32 +34,34 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
26
34
|
props
|
|
27
35
|
]));
|
|
28
36
|
const filteredVariants = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
29
|
-
const [props2] = qwik.useLexicalScope();
|
|
37
|
+
const [props2, state2] = qwik.useLexicalScope();
|
|
30
38
|
return (props2.variants || []).filter((variant) => {
|
|
31
39
|
var _a2, _b2, _c2, _d2;
|
|
32
40
|
return inlinedFns.filterWithCustomTargeting({
|
|
33
41
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
34
42
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
35
43
|
} : {},
|
|
36
|
-
...
|
|
44
|
+
...state2.userAttributes
|
|
37
45
|
}, variant.query, variant.startDate, variant.endDate);
|
|
38
46
|
});
|
|
39
47
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
40
|
-
props
|
|
48
|
+
props,
|
|
49
|
+
state
|
|
41
50
|
]));
|
|
42
51
|
const blocksToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
43
52
|
var _a2;
|
|
44
|
-
const [filteredVariants2, props2] = qwik.useLexicalScope();
|
|
53
|
+
const [filteredVariants2, props2, state2] = qwik.useLexicalScope();
|
|
45
54
|
return helpers.getBlocksToRender({
|
|
46
55
|
variants: props2.variants,
|
|
47
56
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
48
|
-
isHydrated:
|
|
57
|
+
isHydrated: state2.shouldResetVariants,
|
|
49
58
|
filteredVariants: filteredVariants2.value,
|
|
50
59
|
previewingIndex: props2.previewingIndex
|
|
51
60
|
});
|
|
52
61
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
53
62
|
filteredVariants,
|
|
54
|
-
props
|
|
63
|
+
props,
|
|
64
|
+
state
|
|
55
65
|
]));
|
|
56
66
|
const hideVariantsStyleString = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
57
67
|
const [props2] = qwik.useLexicalScope();
|
|
@@ -63,20 +73,14 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
63
73
|
props
|
|
64
74
|
]));
|
|
65
75
|
const rootRef = qwik.useSignal();
|
|
66
|
-
const state = qwik.useStore({
|
|
67
|
-
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
68
|
-
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
69
|
-
shouldResetVariants: false,
|
|
70
|
-
unsubscribers: [],
|
|
71
|
-
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
72
|
-
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
73
|
-
});
|
|
74
76
|
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
75
77
|
var _a2;
|
|
76
78
|
const [filteredVariants2, props2, rootRef2, state2] = qwik.useLexicalScope();
|
|
77
79
|
state2.shouldResetVariants = true;
|
|
78
80
|
const unsub = userAttributes.userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
79
81
|
state2.userAttributes = attrs2;
|
|
82
|
+
}, {
|
|
83
|
+
fireImmediately: target.TARGET === "qwik"
|
|
80
84
|
});
|
|
81
85
|
if (!(isEditing.isEditing() || isPreviewing.isPreviewing())) {
|
|
82
86
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, _jsxBranch, useComputedQrl, useLexicalScope, useSignal,
|
|
1
|
+
import { componentQrl, inlinedQrl, _jsxBranch, useStore, useComputedQrl, useLexicalScope, useSignal, useVisibleTaskQrl, _jsxS, _jsxC, _IMMUTABLE, _fnSignal, _wrapProp } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
import { Blocks } from "../../components/blocks/blocks.qwik.mjs";
|
|
4
4
|
import { InlinedScript } from "../../components/inlined-script.qwik.mjs";
|
|
@@ -9,11 +9,19 @@ import { isEditing } from "../../functions/is-editing.qwik.mjs";
|
|
|
9
9
|
import { isPreviewing } from "../../functions/is-previewing.qwik.mjs";
|
|
10
10
|
import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
11
11
|
import { userAttributesService } from "../../helpers/user-attributes.qwik.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { getPersonalizationScript, checkShouldRenderVariants, getUpdateVisibilityStylesScript, getBlocksToRender, DEFAULT_INDEX, SDKS_REQUIRING_RESET_APPROACH } from "./helpers.qwik.mjs";
|
|
13
13
|
import { filterWithCustomTargeting } from "./helpers/inlined-fns.qwik.mjs";
|
|
14
14
|
const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
15
15
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
16
|
_jsxBranch();
|
|
17
|
+
const state = useStore({
|
|
18
|
+
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
19
|
+
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
20
|
+
shouldResetVariants: false,
|
|
21
|
+
unsubscribers: [],
|
|
22
|
+
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
23
|
+
userAttributes: userAttributesService.getUserAttributes()
|
|
24
|
+
});
|
|
17
25
|
const attrs = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
18
26
|
const [props2] = useLexicalScope();
|
|
19
27
|
return {
|
|
@@ -24,32 +32,34 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
24
32
|
props
|
|
25
33
|
]));
|
|
26
34
|
const filteredVariants = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
27
|
-
const [props2] = useLexicalScope();
|
|
35
|
+
const [props2, state2] = useLexicalScope();
|
|
28
36
|
return (props2.variants || []).filter((variant) => {
|
|
29
37
|
var _a2, _b2, _c2, _d2;
|
|
30
38
|
return filterWithCustomTargeting({
|
|
31
39
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
32
40
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
33
41
|
} : {},
|
|
34
|
-
...
|
|
42
|
+
...state2.userAttributes
|
|
35
43
|
}, variant.query, variant.startDate, variant.endDate);
|
|
36
44
|
});
|
|
37
45
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
38
|
-
props
|
|
46
|
+
props,
|
|
47
|
+
state
|
|
39
48
|
]));
|
|
40
49
|
const blocksToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
41
50
|
var _a2;
|
|
42
|
-
const [filteredVariants2, props2] = useLexicalScope();
|
|
51
|
+
const [filteredVariants2, props2, state2] = useLexicalScope();
|
|
43
52
|
return getBlocksToRender({
|
|
44
53
|
variants: props2.variants,
|
|
45
54
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
46
|
-
isHydrated:
|
|
55
|
+
isHydrated: state2.shouldResetVariants,
|
|
47
56
|
filteredVariants: filteredVariants2.value,
|
|
48
57
|
previewingIndex: props2.previewingIndex
|
|
49
58
|
});
|
|
50
59
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
51
60
|
filteredVariants,
|
|
52
|
-
props
|
|
61
|
+
props,
|
|
62
|
+
state
|
|
53
63
|
]));
|
|
54
64
|
const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
55
65
|
const [props2] = useLexicalScope();
|
|
@@ -61,20 +71,14 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
61
71
|
props
|
|
62
72
|
]));
|
|
63
73
|
const rootRef = useSignal();
|
|
64
|
-
const state = useStore({
|
|
65
|
-
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
66
|
-
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
67
|
-
shouldResetVariants: false,
|
|
68
|
-
unsubscribers: [],
|
|
69
|
-
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
70
|
-
userAttributes: userAttributesService.getUserAttributes()
|
|
71
|
-
});
|
|
72
74
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
73
75
|
var _a2;
|
|
74
76
|
const [filteredVariants2, props2, rootRef2, state2] = useLexicalScope();
|
|
75
77
|
state2.shouldResetVariants = true;
|
|
76
78
|
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
77
79
|
state2.userAttributes = attrs2;
|
|
80
|
+
}, {
|
|
81
|
+
fireImmediately: TARGET === "qwik"
|
|
78
82
|
});
|
|
79
83
|
if (!(isEditing() || isPreviewing())) {
|
|
80
84
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const target = require("../constants/target.qwik.cjs");
|
|
3
4
|
const isBrowser = require("../functions/is-browser.qwik.cjs");
|
|
4
5
|
const cookie = require("./cookie.qwik.cjs");
|
|
6
|
+
const noSerializeWrapper = require("./no-serialize-wrapper.qwik.cjs");
|
|
5
7
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
6
8
|
function createUserAttributesService() {
|
|
7
9
|
let canTrack = true;
|
|
@@ -29,18 +31,27 @@ function createUserAttributesService() {
|
|
|
29
31
|
canTrack
|
|
30
32
|
}) || "{}");
|
|
31
33
|
},
|
|
32
|
-
subscribeOnUserAttributesChange(callback) {
|
|
34
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
33
35
|
subscribers.add(callback);
|
|
34
|
-
|
|
36
|
+
if (fireImmediately)
|
|
37
|
+
callback(this.getUserAttributes());
|
|
38
|
+
return noSerializeWrapper.noSerializeWrapper(function() {
|
|
35
39
|
subscribers.delete(callback);
|
|
36
|
-
};
|
|
40
|
+
});
|
|
37
41
|
},
|
|
38
42
|
setCanTrack(value) {
|
|
39
43
|
canTrack = value;
|
|
40
44
|
}
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
let _userAttributesService;
|
|
48
|
+
if (isBrowser.isBrowser() && target.TARGET === "qwik") {
|
|
49
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
50
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
51
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
52
|
+
} else
|
|
53
|
+
_userAttributesService = createUserAttributesService();
|
|
54
|
+
const userAttributesService = _userAttributesService;
|
|
44
55
|
const setClientUserAttributes = (attributes) => {
|
|
45
56
|
userAttributesService.setUserAttributes(attributes);
|
|
46
57
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TARGET } from "../constants/target.qwik.mjs";
|
|
1
2
|
import { isBrowser } from "../functions/is-browser.qwik.mjs";
|
|
2
3
|
import { setCookie, getCookieSync } from "./cookie.qwik.mjs";
|
|
4
|
+
import { noSerializeWrapper } from "./no-serialize-wrapper.qwik.mjs";
|
|
3
5
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
4
6
|
function createUserAttributesService() {
|
|
5
7
|
let canTrack = true;
|
|
@@ -27,18 +29,27 @@ function createUserAttributesService() {
|
|
|
27
29
|
canTrack
|
|
28
30
|
}) || "{}");
|
|
29
31
|
},
|
|
30
|
-
subscribeOnUserAttributesChange(callback) {
|
|
32
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
31
33
|
subscribers.add(callback);
|
|
32
|
-
|
|
34
|
+
if (fireImmediately)
|
|
35
|
+
callback(this.getUserAttributes());
|
|
36
|
+
return noSerializeWrapper(function() {
|
|
33
37
|
subscribers.delete(callback);
|
|
34
|
-
};
|
|
38
|
+
});
|
|
35
39
|
},
|
|
36
40
|
setCanTrack(value) {
|
|
37
41
|
canTrack = value;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
|
|
45
|
+
let _userAttributesService;
|
|
46
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
47
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
48
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
49
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
50
|
+
} else
|
|
51
|
+
_userAttributesService = createUserAttributesService();
|
|
52
|
+
const userAttributesService = _userAttributesService;
|
|
42
53
|
const setClientUserAttributes = (attributes) => {
|
|
43
54
|
userAttributesService.setUserAttributes(attributes);
|
|
44
55
|
};
|
|
@@ -11,11 +11,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
11
11
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
12
12
|
"react",
|
|
13
13
|
"vue",
|
|
14
|
-
"svelte"
|
|
14
|
+
"svelte",
|
|
15
|
+
"qwik"
|
|
15
16
|
];
|
|
16
17
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
17
18
|
"vue",
|
|
18
|
-
"svelte"
|
|
19
|
+
"svelte",
|
|
20
|
+
"qwik"
|
|
19
21
|
];
|
|
20
22
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
21
23
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -10,11 +10,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
10
10
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
11
11
|
"react",
|
|
12
12
|
"vue",
|
|
13
|
-
"svelte"
|
|
13
|
+
"svelte",
|
|
14
|
+
"qwik"
|
|
14
15
|
];
|
|
15
16
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
16
17
|
"vue",
|
|
17
|
-
"svelte"
|
|
18
|
+
"svelte",
|
|
19
|
+
"qwik"
|
|
18
20
|
];
|
|
19
21
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
20
22
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -16,6 +16,14 @@ const inlinedFns = require("./helpers/inlined-fns.qwik.cjs");
|
|
|
16
16
|
const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
18
|
qwik._jsxBranch();
|
|
19
|
+
const state = qwik.useStore({
|
|
20
|
+
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
21
|
+
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
22
|
+
shouldResetVariants: false,
|
|
23
|
+
unsubscribers: [],
|
|
24
|
+
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
25
|
+
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
26
|
+
});
|
|
19
27
|
const attrs = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
20
28
|
const [props2] = qwik.useLexicalScope();
|
|
21
29
|
return {
|
|
@@ -26,32 +34,34 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
26
34
|
props
|
|
27
35
|
]));
|
|
28
36
|
const filteredVariants = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
29
|
-
const [props2] = qwik.useLexicalScope();
|
|
37
|
+
const [props2, state2] = qwik.useLexicalScope();
|
|
30
38
|
return (props2.variants || []).filter((variant) => {
|
|
31
39
|
var _a2, _b2, _c2, _d2;
|
|
32
40
|
return inlinedFns.filterWithCustomTargeting({
|
|
33
41
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
34
42
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
35
43
|
} : {},
|
|
36
|
-
...
|
|
44
|
+
...state2.userAttributes
|
|
37
45
|
}, variant.query, variant.startDate, variant.endDate);
|
|
38
46
|
});
|
|
39
47
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
40
|
-
props
|
|
48
|
+
props,
|
|
49
|
+
state
|
|
41
50
|
]));
|
|
42
51
|
const blocksToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
43
52
|
var _a2;
|
|
44
|
-
const [filteredVariants2, props2] = qwik.useLexicalScope();
|
|
53
|
+
const [filteredVariants2, props2, state2] = qwik.useLexicalScope();
|
|
45
54
|
return helpers.getBlocksToRender({
|
|
46
55
|
variants: props2.variants,
|
|
47
56
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
48
|
-
isHydrated:
|
|
57
|
+
isHydrated: state2.shouldResetVariants,
|
|
49
58
|
filteredVariants: filteredVariants2.value,
|
|
50
59
|
previewingIndex: props2.previewingIndex
|
|
51
60
|
});
|
|
52
61
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
53
62
|
filteredVariants,
|
|
54
|
-
props
|
|
63
|
+
props,
|
|
64
|
+
state
|
|
55
65
|
]));
|
|
56
66
|
const hideVariantsStyleString = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
57
67
|
const [props2] = qwik.useLexicalScope();
|
|
@@ -63,20 +73,14 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
63
73
|
props
|
|
64
74
|
]));
|
|
65
75
|
const rootRef = qwik.useSignal();
|
|
66
|
-
const state = qwik.useStore({
|
|
67
|
-
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
68
|
-
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
69
|
-
shouldResetVariants: false,
|
|
70
|
-
unsubscribers: [],
|
|
71
|
-
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
72
|
-
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
73
|
-
});
|
|
74
76
|
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
75
77
|
var _a2;
|
|
76
78
|
const [filteredVariants2, props2, rootRef2, state2] = qwik.useLexicalScope();
|
|
77
79
|
state2.shouldResetVariants = true;
|
|
78
80
|
const unsub = userAttributes.userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
79
81
|
state2.userAttributes = attrs2;
|
|
82
|
+
}, {
|
|
83
|
+
fireImmediately: target.TARGET === "qwik"
|
|
80
84
|
});
|
|
81
85
|
if (!(isEditing.isEditing() || isPreviewing.isPreviewing())) {
|
|
82
86
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, _jsxBranch, useComputedQrl, useLexicalScope, useSignal,
|
|
1
|
+
import { componentQrl, inlinedQrl, _jsxBranch, useStore, useComputedQrl, useLexicalScope, useSignal, useVisibleTaskQrl, _jsxS, _jsxC, _IMMUTABLE, _fnSignal, _wrapProp } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
import { Blocks } from "../../components/blocks/blocks.qwik.mjs";
|
|
4
4
|
import { InlinedScript } from "../../components/inlined-script.qwik.mjs";
|
|
@@ -9,11 +9,19 @@ import { isEditing } from "../../functions/is-editing.qwik.mjs";
|
|
|
9
9
|
import { isPreviewing } from "../../functions/is-previewing.qwik.mjs";
|
|
10
10
|
import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
11
11
|
import { userAttributesService } from "../../helpers/user-attributes.qwik.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { getPersonalizationScript, checkShouldRenderVariants, getUpdateVisibilityStylesScript, getBlocksToRender, DEFAULT_INDEX, SDKS_REQUIRING_RESET_APPROACH } from "./helpers.qwik.mjs";
|
|
13
13
|
import { filterWithCustomTargeting } from "./helpers/inlined-fns.qwik.mjs";
|
|
14
14
|
const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
15
15
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
16
|
_jsxBranch();
|
|
17
|
+
const state = useStore({
|
|
18
|
+
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
19
|
+
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
20
|
+
shouldResetVariants: false,
|
|
21
|
+
unsubscribers: [],
|
|
22
|
+
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
23
|
+
userAttributes: userAttributesService.getUserAttributes()
|
|
24
|
+
});
|
|
17
25
|
const attrs = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
18
26
|
const [props2] = useLexicalScope();
|
|
19
27
|
return {
|
|
@@ -24,32 +32,34 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
24
32
|
props
|
|
25
33
|
]));
|
|
26
34
|
const filteredVariants = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
27
|
-
const [props2] = useLexicalScope();
|
|
35
|
+
const [props2, state2] = useLexicalScope();
|
|
28
36
|
return (props2.variants || []).filter((variant) => {
|
|
29
37
|
var _a2, _b2, _c2, _d2;
|
|
30
38
|
return filterWithCustomTargeting({
|
|
31
39
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
32
40
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
33
41
|
} : {},
|
|
34
|
-
...
|
|
42
|
+
...state2.userAttributes
|
|
35
43
|
}, variant.query, variant.startDate, variant.endDate);
|
|
36
44
|
});
|
|
37
45
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
38
|
-
props
|
|
46
|
+
props,
|
|
47
|
+
state
|
|
39
48
|
]));
|
|
40
49
|
const blocksToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
41
50
|
var _a2;
|
|
42
|
-
const [filteredVariants2, props2] = useLexicalScope();
|
|
51
|
+
const [filteredVariants2, props2, state2] = useLexicalScope();
|
|
43
52
|
return getBlocksToRender({
|
|
44
53
|
variants: props2.variants,
|
|
45
54
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
46
|
-
isHydrated:
|
|
55
|
+
isHydrated: state2.shouldResetVariants,
|
|
47
56
|
filteredVariants: filteredVariants2.value,
|
|
48
57
|
previewingIndex: props2.previewingIndex
|
|
49
58
|
});
|
|
50
59
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
51
60
|
filteredVariants,
|
|
52
|
-
props
|
|
61
|
+
props,
|
|
62
|
+
state
|
|
53
63
|
]));
|
|
54
64
|
const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
55
65
|
const [props2] = useLexicalScope();
|
|
@@ -61,20 +71,14 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
61
71
|
props
|
|
62
72
|
]));
|
|
63
73
|
const rootRef = useSignal();
|
|
64
|
-
const state = useStore({
|
|
65
|
-
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
66
|
-
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
67
|
-
shouldResetVariants: false,
|
|
68
|
-
unsubscribers: [],
|
|
69
|
-
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
70
|
-
userAttributes: userAttributesService.getUserAttributes()
|
|
71
|
-
});
|
|
72
74
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
73
75
|
var _a2;
|
|
74
76
|
const [filteredVariants2, props2, rootRef2, state2] = useLexicalScope();
|
|
75
77
|
state2.shouldResetVariants = true;
|
|
76
78
|
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
77
79
|
state2.userAttributes = attrs2;
|
|
80
|
+
}, {
|
|
81
|
+
fireImmediately: TARGET === "qwik"
|
|
78
82
|
});
|
|
79
83
|
if (!(isEditing() || isPreviewing())) {
|
|
80
84
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const target = require("../constants/target.qwik.cjs");
|
|
3
4
|
const isBrowser = require("../functions/is-browser.qwik.cjs");
|
|
4
5
|
const cookie = require("./cookie.qwik.cjs");
|
|
6
|
+
const noSerializeWrapper = require("./no-serialize-wrapper.qwik.cjs");
|
|
5
7
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
6
8
|
function createUserAttributesService() {
|
|
7
9
|
let canTrack = true;
|
|
@@ -29,18 +31,27 @@ function createUserAttributesService() {
|
|
|
29
31
|
canTrack
|
|
30
32
|
}) || "{}");
|
|
31
33
|
},
|
|
32
|
-
subscribeOnUserAttributesChange(callback) {
|
|
34
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
33
35
|
subscribers.add(callback);
|
|
34
|
-
|
|
36
|
+
if (fireImmediately)
|
|
37
|
+
callback(this.getUserAttributes());
|
|
38
|
+
return noSerializeWrapper.noSerializeWrapper(function() {
|
|
35
39
|
subscribers.delete(callback);
|
|
36
|
-
};
|
|
40
|
+
});
|
|
37
41
|
},
|
|
38
42
|
setCanTrack(value) {
|
|
39
43
|
canTrack = value;
|
|
40
44
|
}
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
let _userAttributesService;
|
|
48
|
+
if (isBrowser.isBrowser() && target.TARGET === "qwik") {
|
|
49
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
50
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
51
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
52
|
+
} else
|
|
53
|
+
_userAttributesService = createUserAttributesService();
|
|
54
|
+
const userAttributesService = _userAttributesService;
|
|
44
55
|
const setClientUserAttributes = (attributes) => {
|
|
45
56
|
userAttributesService.setUserAttributes(attributes);
|
|
46
57
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TARGET } from "../constants/target.qwik.mjs";
|
|
1
2
|
import { isBrowser } from "../functions/is-browser.qwik.mjs";
|
|
2
3
|
import { setCookie, getCookieSync } from "./cookie.qwik.mjs";
|
|
4
|
+
import { noSerializeWrapper } from "./no-serialize-wrapper.qwik.mjs";
|
|
3
5
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
4
6
|
function createUserAttributesService() {
|
|
5
7
|
let canTrack = true;
|
|
@@ -27,18 +29,27 @@ function createUserAttributesService() {
|
|
|
27
29
|
canTrack
|
|
28
30
|
}) || "{}");
|
|
29
31
|
},
|
|
30
|
-
subscribeOnUserAttributesChange(callback) {
|
|
32
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
31
33
|
subscribers.add(callback);
|
|
32
|
-
|
|
34
|
+
if (fireImmediately)
|
|
35
|
+
callback(this.getUserAttributes());
|
|
36
|
+
return noSerializeWrapper(function() {
|
|
33
37
|
subscribers.delete(callback);
|
|
34
|
-
};
|
|
38
|
+
});
|
|
35
39
|
},
|
|
36
40
|
setCanTrack(value) {
|
|
37
41
|
canTrack = value;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
|
|
45
|
+
let _userAttributesService;
|
|
46
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
47
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
48
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
49
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
50
|
+
} else
|
|
51
|
+
_userAttributesService = createUserAttributesService();
|
|
52
|
+
const userAttributesService = _userAttributesService;
|
|
42
53
|
const setClientUserAttributes = (attributes) => {
|
|
43
54
|
userAttributesService.setUserAttributes(attributes);
|
|
44
55
|
};
|
|
@@ -11,11 +11,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
11
11
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
12
12
|
"react",
|
|
13
13
|
"vue",
|
|
14
|
-
"svelte"
|
|
14
|
+
"svelte",
|
|
15
|
+
"qwik"
|
|
15
16
|
];
|
|
16
17
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
17
18
|
"vue",
|
|
18
|
-
"svelte"
|
|
19
|
+
"svelte",
|
|
20
|
+
"qwik"
|
|
19
21
|
];
|
|
20
22
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
21
23
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -10,11 +10,13 @@ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
|
10
10
|
const SDKS_SUPPORTING_PERSONALIZATION = [
|
|
11
11
|
"react",
|
|
12
12
|
"vue",
|
|
13
|
-
"svelte"
|
|
13
|
+
"svelte",
|
|
14
|
+
"qwik"
|
|
14
15
|
];
|
|
15
16
|
const SDKS_REQUIRING_RESET_APPROACH = [
|
|
16
17
|
"vue",
|
|
17
|
-
"svelte"
|
|
18
|
+
"svelte",
|
|
19
|
+
"qwik"
|
|
18
20
|
];
|
|
19
21
|
function checkShouldRenderVariants(variants, canTrack) {
|
|
20
22
|
const hasVariants = variants && variants.length > 0;
|
|
@@ -16,6 +16,14 @@ const inlinedFns = require("./helpers/inlined-fns.qwik.cjs");
|
|
|
16
16
|
const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
18
|
qwik._jsxBranch();
|
|
19
|
+
const state = qwik.useStore({
|
|
20
|
+
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
21
|
+
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
22
|
+
shouldResetVariants: false,
|
|
23
|
+
unsubscribers: [],
|
|
24
|
+
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
25
|
+
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
26
|
+
});
|
|
19
27
|
const attrs = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
20
28
|
const [props2] = qwik.useLexicalScope();
|
|
21
29
|
return {
|
|
@@ -26,32 +34,34 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
26
34
|
props
|
|
27
35
|
]));
|
|
28
36
|
const filteredVariants = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
29
|
-
const [props2] = qwik.useLexicalScope();
|
|
37
|
+
const [props2, state2] = qwik.useLexicalScope();
|
|
30
38
|
return (props2.variants || []).filter((variant) => {
|
|
31
39
|
var _a2, _b2, _c2, _d2;
|
|
32
40
|
return inlinedFns.filterWithCustomTargeting({
|
|
33
41
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
34
42
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
35
43
|
} : {},
|
|
36
|
-
...
|
|
44
|
+
...state2.userAttributes
|
|
37
45
|
}, variant.query, variant.startDate, variant.endDate);
|
|
38
46
|
});
|
|
39
47
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
40
|
-
props
|
|
48
|
+
props,
|
|
49
|
+
state
|
|
41
50
|
]));
|
|
42
51
|
const blocksToRender = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
43
52
|
var _a2;
|
|
44
|
-
const [filteredVariants2, props2] = qwik.useLexicalScope();
|
|
53
|
+
const [filteredVariants2, props2, state2] = qwik.useLexicalScope();
|
|
45
54
|
return helpers.getBlocksToRender({
|
|
46
55
|
variants: props2.variants,
|
|
47
56
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
48
|
-
isHydrated:
|
|
57
|
+
isHydrated: state2.shouldResetVariants,
|
|
49
58
|
filteredVariants: filteredVariants2.value,
|
|
50
59
|
previewingIndex: props2.previewingIndex
|
|
51
60
|
});
|
|
52
61
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
53
62
|
filteredVariants,
|
|
54
|
-
props
|
|
63
|
+
props,
|
|
64
|
+
state
|
|
55
65
|
]));
|
|
56
66
|
const hideVariantsStyleString = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
57
67
|
const [props2] = qwik.useLexicalScope();
|
|
@@ -63,20 +73,14 @@ const PersonalizationContainer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__
|
|
|
63
73
|
props
|
|
64
74
|
]));
|
|
65
75
|
const rootRef = qwik.useSignal();
|
|
66
|
-
const state = qwik.useStore({
|
|
67
|
-
scriptStr: helpers.getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
68
|
-
shouldRenderVariants: helpers.checkShouldRenderVariants(props.variants, canTrack.getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
69
|
-
shouldResetVariants: false,
|
|
70
|
-
unsubscribers: [],
|
|
71
|
-
updateVisibilityStylesScript: helpers.getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
72
|
-
userAttributes: userAttributes.userAttributesService.getUserAttributes()
|
|
73
|
-
});
|
|
74
76
|
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
75
77
|
var _a2;
|
|
76
78
|
const [filteredVariants2, props2, rootRef2, state2] = qwik.useLexicalScope();
|
|
77
79
|
state2.shouldResetVariants = true;
|
|
78
80
|
const unsub = userAttributes.userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
79
81
|
state2.userAttributes = attrs2;
|
|
82
|
+
}, {
|
|
83
|
+
fireImmediately: target.TARGET === "qwik"
|
|
80
84
|
});
|
|
81
85
|
if (!(isEditing.isEditing() || isPreviewing.isPreviewing())) {
|
|
82
86
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, _jsxBranch, useComputedQrl, useLexicalScope, useSignal,
|
|
1
|
+
import { componentQrl, inlinedQrl, _jsxBranch, useStore, useComputedQrl, useLexicalScope, useSignal, useVisibleTaskQrl, _jsxS, _jsxC, _IMMUTABLE, _fnSignal, _wrapProp } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
import { Blocks } from "../../components/blocks/blocks.qwik.mjs";
|
|
4
4
|
import { InlinedScript } from "../../components/inlined-script.qwik.mjs";
|
|
@@ -9,11 +9,19 @@ import { isEditing } from "../../functions/is-editing.qwik.mjs";
|
|
|
9
9
|
import { isPreviewing } from "../../functions/is-previewing.qwik.mjs";
|
|
10
10
|
import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
|
|
11
11
|
import { userAttributesService } from "../../helpers/user-attributes.qwik.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { getPersonalizationScript, checkShouldRenderVariants, getUpdateVisibilityStylesScript, getBlocksToRender, DEFAULT_INDEX, SDKS_REQUIRING_RESET_APPROACH } from "./helpers.qwik.mjs";
|
|
13
13
|
import { filterWithCustomTargeting } from "./helpers/inlined-fns.qwik.mjs";
|
|
14
14
|
const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
15
15
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
16
|
_jsxBranch();
|
|
17
|
+
const state = useStore({
|
|
18
|
+
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
19
|
+
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
20
|
+
shouldResetVariants: false,
|
|
21
|
+
unsubscribers: [],
|
|
22
|
+
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
23
|
+
userAttributes: userAttributesService.getUserAttributes()
|
|
24
|
+
});
|
|
17
25
|
const attrs = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
18
26
|
const [props2] = useLexicalScope();
|
|
19
27
|
return {
|
|
@@ -24,32 +32,34 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
24
32
|
props
|
|
25
33
|
]));
|
|
26
34
|
const filteredVariants = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
27
|
-
const [props2] = useLexicalScope();
|
|
35
|
+
const [props2, state2] = useLexicalScope();
|
|
28
36
|
return (props2.variants || []).filter((variant) => {
|
|
29
37
|
var _a2, _b2, _c2, _d2;
|
|
30
38
|
return filterWithCustomTargeting({
|
|
31
39
|
...((_b2 = (_a2 = props2.builderContext) == null ? void 0 : _a2.rootState) == null ? void 0 : _b2.locale) ? {
|
|
32
40
|
locale: (_d2 = (_c2 = props2.builderContext) == null ? void 0 : _c2.rootState) == null ? void 0 : _d2.locale
|
|
33
41
|
} : {},
|
|
34
|
-
...
|
|
42
|
+
...state2.userAttributes
|
|
35
43
|
}, variant.query, variant.startDate, variant.endDate);
|
|
36
44
|
});
|
|
37
45
|
}, "PersonalizationContainer_component_filteredVariants_useComputed_0jlgEflkxcQ", [
|
|
38
|
-
props
|
|
46
|
+
props,
|
|
47
|
+
state
|
|
39
48
|
]));
|
|
40
49
|
const blocksToRender = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
41
50
|
var _a2;
|
|
42
|
-
const [filteredVariants2, props2] = useLexicalScope();
|
|
51
|
+
const [filteredVariants2, props2, state2] = useLexicalScope();
|
|
43
52
|
return getBlocksToRender({
|
|
44
53
|
variants: props2.variants,
|
|
45
54
|
fallbackBlocks: (_a2 = props2.builderBlock) == null ? void 0 : _a2.children,
|
|
46
|
-
isHydrated:
|
|
55
|
+
isHydrated: state2.shouldResetVariants,
|
|
47
56
|
filteredVariants: filteredVariants2.value,
|
|
48
57
|
previewingIndex: props2.previewingIndex
|
|
49
58
|
});
|
|
50
59
|
}, "PersonalizationContainer_component_blocksToRender_useComputed_aZOAYVB7Svg", [
|
|
51
60
|
filteredVariants,
|
|
52
|
-
props
|
|
61
|
+
props,
|
|
62
|
+
state
|
|
53
63
|
]));
|
|
54
64
|
const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
55
65
|
const [props2] = useLexicalScope();
|
|
@@ -61,20 +71,14 @@ const PersonalizationContainer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ in
|
|
|
61
71
|
props
|
|
62
72
|
]));
|
|
63
73
|
const rootRef = useSignal();
|
|
64
|
-
const state = useStore({
|
|
65
|
-
scriptStr: getPersonalizationScript(props.variants, ((_a = props.builderBlock) == null ? void 0 : _a.id) || "none", (_c = (_b = props.builderContext) == null ? void 0 : _b.rootState) == null ? void 0 : _c.locale),
|
|
66
|
-
shouldRenderVariants: checkShouldRenderVariants(props.variants, getDefaultCanTrack((_d = props.builderContext) == null ? void 0 : _d.canTrack)),
|
|
67
|
-
shouldResetVariants: false,
|
|
68
|
-
unsubscribers: [],
|
|
69
|
-
updateVisibilityStylesScript: getUpdateVisibilityStylesScript(props.variants, ((_e = props.builderBlock) == null ? void 0 : _e.id) || "none", (_g = (_f = props.builderContext) == null ? void 0 : _f.rootState) == null ? void 0 : _g.locale),
|
|
70
|
-
userAttributes: userAttributesService.getUserAttributes()
|
|
71
|
-
});
|
|
72
74
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
73
75
|
var _a2;
|
|
74
76
|
const [filteredVariants2, props2, rootRef2, state2] = useLexicalScope();
|
|
75
77
|
state2.shouldResetVariants = true;
|
|
76
78
|
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
77
79
|
state2.userAttributes = attrs2;
|
|
80
|
+
}, {
|
|
81
|
+
fireImmediately: TARGET === "qwik"
|
|
78
82
|
});
|
|
79
83
|
if (!(isEditing() || isPreviewing())) {
|
|
80
84
|
const variant = filteredVariants2.value[0];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const target = require("../constants/target.qwik.cjs");
|
|
3
4
|
const isBrowser = require("../functions/is-browser.qwik.cjs");
|
|
4
5
|
const cookie = require("./cookie.qwik.cjs");
|
|
6
|
+
const noSerializeWrapper = require("./no-serialize-wrapper.qwik.cjs");
|
|
5
7
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
6
8
|
function createUserAttributesService() {
|
|
7
9
|
let canTrack = true;
|
|
@@ -29,18 +31,27 @@ function createUserAttributesService() {
|
|
|
29
31
|
canTrack
|
|
30
32
|
}) || "{}");
|
|
31
33
|
},
|
|
32
|
-
subscribeOnUserAttributesChange(callback) {
|
|
34
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
33
35
|
subscribers.add(callback);
|
|
34
|
-
|
|
36
|
+
if (fireImmediately)
|
|
37
|
+
callback(this.getUserAttributes());
|
|
38
|
+
return noSerializeWrapper.noSerializeWrapper(function() {
|
|
35
39
|
subscribers.delete(callback);
|
|
36
|
-
};
|
|
40
|
+
});
|
|
37
41
|
},
|
|
38
42
|
setCanTrack(value) {
|
|
39
43
|
canTrack = value;
|
|
40
44
|
}
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
let _userAttributesService;
|
|
48
|
+
if (isBrowser.isBrowser() && target.TARGET === "qwik") {
|
|
49
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
50
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
51
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
52
|
+
} else
|
|
53
|
+
_userAttributesService = createUserAttributesService();
|
|
54
|
+
const userAttributesService = _userAttributesService;
|
|
44
55
|
const setClientUserAttributes = (attributes) => {
|
|
45
56
|
userAttributesService.setUserAttributes(attributes);
|
|
46
57
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TARGET } from "../constants/target.qwik.mjs";
|
|
1
2
|
import { isBrowser } from "../functions/is-browser.qwik.mjs";
|
|
2
3
|
import { setCookie, getCookieSync } from "./cookie.qwik.mjs";
|
|
4
|
+
import { noSerializeWrapper } from "./no-serialize-wrapper.qwik.mjs";
|
|
3
5
|
const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
4
6
|
function createUserAttributesService() {
|
|
5
7
|
let canTrack = true;
|
|
@@ -27,18 +29,27 @@ function createUserAttributesService() {
|
|
|
27
29
|
canTrack
|
|
28
30
|
}) || "{}");
|
|
29
31
|
},
|
|
30
|
-
subscribeOnUserAttributesChange(callback) {
|
|
32
|
+
subscribeOnUserAttributesChange(callback, { fireImmediately } = {}) {
|
|
31
33
|
subscribers.add(callback);
|
|
32
|
-
|
|
34
|
+
if (fireImmediately)
|
|
35
|
+
callback(this.getUserAttributes());
|
|
36
|
+
return noSerializeWrapper(function() {
|
|
33
37
|
subscribers.delete(callback);
|
|
34
|
-
};
|
|
38
|
+
});
|
|
35
39
|
},
|
|
36
40
|
setCanTrack(value) {
|
|
37
41
|
canTrack = value;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
|
|
45
|
+
let _userAttributesService;
|
|
46
|
+
if (isBrowser() && TARGET === "qwik") {
|
|
47
|
+
if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__)
|
|
48
|
+
window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
|
|
49
|
+
_userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
|
|
50
|
+
} else
|
|
51
|
+
_userAttributesService = createUserAttributesService();
|
|
52
|
+
const userAttributesService = _userAttributesService;
|
|
42
53
|
const setClientUserAttributes = (attributes) => {
|
|
43
54
|
userAttributesService.setUserAttributes(attributes);
|
|
44
55
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
1
|
+
export declare const SDK_VERSION = "0.18.14";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function noSerializeWrapper(fn: () => void): import("@builder.io/qwik").NoSerialize<() => void>;
|
|
@@ -5,13 +5,17 @@ export declare const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
|
5
5
|
export declare function createUserAttributesService(): {
|
|
6
6
|
setUserAttributes(newAttrs: UserAttributes): void;
|
|
7
7
|
getUserAttributes(): any;
|
|
8
|
-
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void
|
|
8
|
+
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void, { fireImmediately }?: {
|
|
9
|
+
fireImmediately?: boolean;
|
|
10
|
+
}): import("@builder.io/qwik").NoSerialize<() => void>;
|
|
9
11
|
setCanTrack(value: boolean): void;
|
|
10
12
|
};
|
|
11
13
|
export declare const userAttributesService: {
|
|
12
14
|
setUserAttributes(newAttrs: UserAttributes): void;
|
|
13
15
|
getUserAttributes(): any;
|
|
14
|
-
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void
|
|
16
|
+
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void, { fireImmediately }?: {
|
|
17
|
+
fireImmediately?: boolean;
|
|
18
|
+
}): import("@builder.io/qwik").NoSerialize<() => void>;
|
|
15
19
|
setCanTrack(value: boolean): void;
|
|
16
20
|
};
|
|
17
21
|
export declare const setClientUserAttributes: (attributes: UserAttributes) => void;
|