@builder.io/sdk-qwik 0.0.23 → 0.0.25
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/index.qwik.cjs +187 -128
- package/lib/index.qwik.mjs +188 -129
- package/package.json +1 -1
- package/types/blocks/columns/columns.d.ts +3 -4
- package/types/blocks/image/image.d.ts +1 -1
- package/types/blocks/symbol/symbol.d.ts +2 -2
- package/types/components/render-block/block-styles.d.ts +2 -2
- package/types/components/render-block/render-block.d.ts +4 -470
- package/types/components/render-block/render-component.d.ts +2 -2
- package/types/components/render-block/types.d.ts +2 -2
- package/types/components/render-blocks.d.ts +2 -1
- package/types/components/render-content/render-content.d.ts +2 -2
- package/types/context/types.d.ts +3 -3
- package/types/functions/get-block-actions-handler.d.ts +1 -1
- package/types/functions/get-block-actions.d.ts +1 -1
- package/types/functions/get-block-component-options.d.ts +1 -1
- package/types/functions/get-block-properties.d.ts +1 -1
- package/types/functions/get-block-styles.d.ts +2 -468
- package/types/functions/get-block-tag.d.ts +1 -1
- package/types/functions/get-content/ab-testing.d.ts +5 -3
- package/types/functions/get-content/index.d.ts +1 -1
- package/types/functions/get-content/types.d.ts +7 -2
- package/types/functions/get-processed-block.d.ts +1 -1
- package/types/functions/register-component.d.ts +1 -1
- package/types/functions/register.d.ts +2 -2
- package/types/functions/sanitize-styles.d.ts +1 -1
- package/types/functions/track.d.ts +1 -1
- package/types/functions/transform-block.d.ts +1 -1
- package/types/helpers/ab-tests.d.ts +8 -0
- package/types/helpers/cookie.d.ts +9 -3
- package/types/helpers/localStorage.d.ts +3 -4
- package/types/helpers/sessionId.d.ts +3 -4
- package/types/helpers/visitorId.d.ts +3 -5
- package/types/types/builder-content.d.ts +1 -1
- package/types/types/typescript.d.ts +1 -0
package/lib/index.qwik.cjs
CHANGED
|
@@ -311,8 +311,7 @@ function getBlockProperties(block) {
|
|
|
311
311
|
const convertStyleObject = (obj) => {
|
|
312
312
|
return obj;
|
|
313
313
|
};
|
|
314
|
-
const sanitizeBlockStyles = (
|
|
315
|
-
};
|
|
314
|
+
const sanitizeBlockStyles = (styles) => styles;
|
|
316
315
|
const getStyleForTarget = (styles) => {
|
|
317
316
|
switch (TARGET) {
|
|
318
317
|
case "reactNative":
|
|
@@ -337,8 +336,8 @@ function getBlockStyles(block) {
|
|
|
337
336
|
if (!block.responsiveStyles)
|
|
338
337
|
return {};
|
|
339
338
|
const styles = getStyleForTarget(block.responsiveStyles);
|
|
340
|
-
sanitizeBlockStyles();
|
|
341
|
-
return
|
|
339
|
+
const newStyles = sanitizeBlockStyles(styles);
|
|
340
|
+
return newStyles;
|
|
342
341
|
}
|
|
343
342
|
function getBlockTag(block) {
|
|
344
343
|
return block.tagName || "div";
|
|
@@ -528,15 +527,27 @@ const RenderBlock = (props) => {
|
|
|
528
527
|
};
|
|
529
528
|
state.tagName = tagName2(props);
|
|
530
529
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
531
|
-
children: shouldWrap(props) ?
|
|
530
|
+
children: shouldWrap(props) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
532
531
|
children: [
|
|
533
|
-
|
|
532
|
+
isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxRuntime.jsx(state.tagName, {
|
|
533
|
+
...attributes(props)
|
|
534
|
+
}) : null,
|
|
535
|
+
!isEmptyHtmlElement(tagName2(props)) && TARGET === "vue2" && repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
536
|
+
class: "vue2-root-element-workaround",
|
|
537
|
+
children: (repeatItemData(props) || []).map(function(data, index) {
|
|
538
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RenderRepeatedBlock$1, {
|
|
539
|
+
repeatContext: data.context,
|
|
540
|
+
block: data.block
|
|
541
|
+
}, index);
|
|
542
|
+
})
|
|
543
|
+
}) : null,
|
|
544
|
+
!isEmptyHtmlElement(tagName2(props)) && TARGET !== "vue2" && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
|
|
534
545
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderRepeatedBlock$1, {
|
|
535
546
|
repeatContext: data.context,
|
|
536
547
|
block: data.block
|
|
537
548
|
}, index);
|
|
538
549
|
}) : null,
|
|
539
|
-
!repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsxs(state.tagName, {
|
|
550
|
+
!isEmptyHtmlElement(tagName2(props)) && !repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsxs(state.tagName, {
|
|
540
551
|
...attributes(props),
|
|
541
552
|
children: [
|
|
542
553
|
/* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
|
|
@@ -557,8 +568,6 @@ const RenderBlock = (props) => {
|
|
|
557
568
|
]
|
|
558
569
|
}) : null
|
|
559
570
|
]
|
|
560
|
-
}) : /* @__PURE__ */ jsxRuntime.jsx(state.tagName, {
|
|
561
|
-
...attributes(props)
|
|
562
571
|
}) : /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
|
|
563
572
|
...renderComponentProps(props),
|
|
564
573
|
context: props.context
|
|
@@ -599,9 +608,10 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) =
|
|
|
599
608
|
class: className(props) + " div-RenderBlocks",
|
|
600
609
|
"builder-path": props.path,
|
|
601
610
|
"builder-parent-id": props.parent,
|
|
611
|
+
style: props.style,
|
|
602
612
|
onClick$: qwik.inlinedQrl((event) => {
|
|
603
613
|
const [builderContext2, props2, state2] = qwik.useLexicalScope();
|
|
604
|
-
return
|
|
614
|
+
return onClick$1(props2);
|
|
605
615
|
}, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
|
|
606
616
|
builderContext,
|
|
607
617
|
props,
|
|
@@ -609,7 +619,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) =
|
|
|
609
619
|
]),
|
|
610
620
|
onMouseEnter$: qwik.inlinedQrl((event) => {
|
|
611
621
|
const [builderContext2, props2, state2] = qwik.useLexicalScope();
|
|
612
|
-
return
|
|
622
|
+
return onMouseEnter(props2);
|
|
613
623
|
}, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
|
|
614
624
|
builderContext,
|
|
615
625
|
props,
|
|
@@ -692,7 +702,10 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
|
|
|
692
702
|
children: /* @__PURE__ */ jsxRuntime.jsx(RenderBlocks$1, {
|
|
693
703
|
blocks: markMutable(column.blocks),
|
|
694
704
|
path: `component.options.columns.${index}.blocks`,
|
|
695
|
-
parent: props.builderBlock.id
|
|
705
|
+
parent: props.builderBlock.id,
|
|
706
|
+
style: {
|
|
707
|
+
flexGrow: "1"
|
|
708
|
+
}
|
|
696
709
|
})
|
|
697
710
|
}, index);
|
|
698
711
|
})
|
|
@@ -705,7 +718,9 @@ align-items: stretch;
|
|
|
705
718
|
line-height: normal; }@media (max-width: 991px) { .div-Columns {
|
|
706
719
|
flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
|
|
707
720
|
flex-direction: var(--flex-dir); } }.div-Columns-2 {
|
|
708
|
-
|
|
721
|
+
display: flex;
|
|
722
|
+
flex-direction: column;
|
|
723
|
+
align-items: stretch; }@media (max-width: 991px) { .div-Columns-2 {
|
|
709
724
|
width: var(--column-width-tablet) !important;
|
|
710
725
|
margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
|
|
711
726
|
width: var(--column-width) !important;
|
|
@@ -1903,117 +1918,13 @@ async function getFetch() {
|
|
|
1903
1918
|
throw new Error("`fetch()` not found, ensure you have it as part of your polyfills.");
|
|
1904
1919
|
return globalFetch.default || globalFetch;
|
|
1905
1920
|
}
|
|
1906
|
-
const handleABTesting = (item, testGroups) => {
|
|
1907
|
-
if (item.variations && Object.keys(item.variations).length) {
|
|
1908
|
-
const testGroup = item.id ? testGroups[item.id] : void 0;
|
|
1909
|
-
const variationValue = testGroup ? item.variations[testGroup] : void 0;
|
|
1910
|
-
if (testGroup && variationValue) {
|
|
1911
|
-
item.data = variationValue.data;
|
|
1912
|
-
item.testVariationId = variationValue.id;
|
|
1913
|
-
item.testVariationName = variationValue.name;
|
|
1914
|
-
} else {
|
|
1915
|
-
let n = 0;
|
|
1916
|
-
const random = Math.random();
|
|
1917
|
-
let set2 = false;
|
|
1918
|
-
for (const id in item.variations) {
|
|
1919
|
-
const variation = item.variations[id];
|
|
1920
|
-
const testRatio = variation.testRatio;
|
|
1921
|
-
n += testRatio;
|
|
1922
|
-
if (random < n) {
|
|
1923
|
-
const variationName = variation.name || (variation.id === item.id ? "Default variation" : "");
|
|
1924
|
-
set2 = true;
|
|
1925
|
-
Object.assign(item, {
|
|
1926
|
-
data: variation.data,
|
|
1927
|
-
testVariationId: variation.id,
|
|
1928
|
-
testVariationName: variationName
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
if (!set2)
|
|
1933
|
-
Object.assign(item, {
|
|
1934
|
-
testVariationId: item.id,
|
|
1935
|
-
testVariationName: "Default"
|
|
1936
|
-
});
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
};
|
|
1940
|
-
async function getContent(options) {
|
|
1941
|
-
return (await getAllContent({
|
|
1942
|
-
...options,
|
|
1943
|
-
limit: 1
|
|
1944
|
-
})).results[0] || null;
|
|
1945
|
-
}
|
|
1946
|
-
const generateContentUrl = (options) => {
|
|
1947
|
-
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey } = options;
|
|
1948
|
-
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`);
|
|
1949
|
-
const queryOptions = {
|
|
1950
|
-
...getBuilderSearchParamsFromWindow(),
|
|
1951
|
-
...normalizeSearchParams(options.options || {})
|
|
1952
|
-
};
|
|
1953
|
-
const flattened = flatten(queryOptions);
|
|
1954
|
-
for (const key in flattened)
|
|
1955
|
-
url.searchParams.set(key, String(flattened[key]));
|
|
1956
|
-
if (userAttributes)
|
|
1957
|
-
url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
|
|
1958
|
-
if (query) {
|
|
1959
|
-
const flattened1 = flatten({
|
|
1960
|
-
query
|
|
1961
|
-
});
|
|
1962
|
-
for (const key1 in flattened1)
|
|
1963
|
-
url.searchParams.set(key1, JSON.stringify(flattened1[key1]));
|
|
1964
|
-
}
|
|
1965
|
-
return url;
|
|
1966
|
-
};
|
|
1967
|
-
async function getAllContent(options) {
|
|
1968
|
-
const url = generateContentUrl(options);
|
|
1969
|
-
const fetch2 = await getFetch();
|
|
1970
|
-
const content = await fetch2(url.href).then((res) => res.json());
|
|
1971
|
-
if (options.testGroups)
|
|
1972
|
-
for (const item of content.results)
|
|
1973
|
-
handleABTesting(item, options.testGroups);
|
|
1974
|
-
return content;
|
|
1975
|
-
}
|
|
1976
|
-
function isPreviewing() {
|
|
1977
|
-
if (!isBrowser())
|
|
1978
|
-
return false;
|
|
1979
|
-
if (isEditing())
|
|
1980
|
-
return false;
|
|
1981
|
-
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
1982
|
-
}
|
|
1983
|
-
const components = [];
|
|
1984
|
-
function registerComponent(component3, info) {
|
|
1985
|
-
components.push({
|
|
1986
|
-
component: component3,
|
|
1987
|
-
...info
|
|
1988
|
-
});
|
|
1989
|
-
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
1990
|
-
return component3;
|
|
1991
|
-
}
|
|
1992
|
-
const createRegisterComponentMessage = ({ component: _, ...info }) => ({
|
|
1993
|
-
type: "builder.registerComponent",
|
|
1994
|
-
data: prepareComponentInfoToSend(info)
|
|
1995
|
-
});
|
|
1996
|
-
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
1997
|
-
const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
1998
|
-
const serializeFn = (fnValue) => {
|
|
1999
|
-
const fnStr = fnValue.toString().trim();
|
|
2000
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2001
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2002
|
-
};
|
|
2003
|
-
const prepareComponentInfoToSend = ({ inputs, ...info }) => ({
|
|
2004
|
-
...fastClone(info),
|
|
2005
|
-
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2006
|
-
...acc,
|
|
2007
|
-
[key]: serializeValue(value)
|
|
2008
|
-
}), {}))
|
|
2009
|
-
});
|
|
2010
1921
|
const getTopLevelDomain = (host) => {
|
|
2011
1922
|
const parts = host.split(".");
|
|
2012
1923
|
if (parts.length > 2)
|
|
2013
1924
|
return parts.slice(1).join(".");
|
|
2014
1925
|
return host;
|
|
2015
1926
|
};
|
|
2016
|
-
const getCookie = ({ name, canTrack }) => {
|
|
1927
|
+
const getCookie = async ({ name, canTrack }) => {
|
|
2017
1928
|
try {
|
|
2018
1929
|
if (!canTrack)
|
|
2019
1930
|
return void 0;
|
|
@@ -2065,7 +1976,7 @@ const createCookieString = ({ name, value, expires }) => {
|
|
|
2065
1976
|
const cookie = stringifyCookie(cookieValue);
|
|
2066
1977
|
return cookie;
|
|
2067
1978
|
};
|
|
2068
|
-
const setCookie = ({ name, value, expires, canTrack }) => {
|
|
1979
|
+
const setCookie = async ({ name, value, expires, canTrack }) => {
|
|
2069
1980
|
try {
|
|
2070
1981
|
if (!canTrack)
|
|
2071
1982
|
return void 0;
|
|
@@ -2079,7 +1990,156 @@ const setCookie = ({ name, value, expires, canTrack }) => {
|
|
|
2079
1990
|
console.warn("[COOKIE] SET error: ", err);
|
|
2080
1991
|
}
|
|
2081
1992
|
};
|
|
1993
|
+
const BUILDER_STORE_PREFIX = "builderio.variations";
|
|
1994
|
+
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1995
|
+
const getContentVariationCookie = ({ contentId, canTrack }) => getCookie({
|
|
1996
|
+
name: getContentTestKey(contentId),
|
|
1997
|
+
canTrack
|
|
1998
|
+
});
|
|
1999
|
+
const setContentVariationCookie = ({ contentId, canTrack, value }) => setCookie({
|
|
2000
|
+
name: getContentTestKey(contentId),
|
|
2001
|
+
value,
|
|
2002
|
+
canTrack
|
|
2003
|
+
});
|
|
2082
2004
|
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
2005
|
+
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
2006
|
+
const getRandomVariationId = ({ id, variations }) => {
|
|
2007
|
+
let n = 0;
|
|
2008
|
+
const random = Math.random();
|
|
2009
|
+
for (const id1 in variations) {
|
|
2010
|
+
const testRatio = variations[id1]?.testRatio;
|
|
2011
|
+
n += testRatio;
|
|
2012
|
+
if (random < n)
|
|
2013
|
+
return id1;
|
|
2014
|
+
}
|
|
2015
|
+
return id;
|
|
2016
|
+
};
|
|
2017
|
+
const getTestFields = ({ item, testGroupId }) => {
|
|
2018
|
+
const variationValue = item.variations[testGroupId];
|
|
2019
|
+
if (testGroupId === item.id || !variationValue)
|
|
2020
|
+
return {
|
|
2021
|
+
testVariationId: item.id,
|
|
2022
|
+
testVariationName: "Default"
|
|
2023
|
+
};
|
|
2024
|
+
else
|
|
2025
|
+
return {
|
|
2026
|
+
data: variationValue.data,
|
|
2027
|
+
testVariationId: variationValue.id,
|
|
2028
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
2029
|
+
};
|
|
2030
|
+
};
|
|
2031
|
+
const getContentVariation = async ({ item, canTrack }) => {
|
|
2032
|
+
const testGroupId = await getContentVariationCookie({
|
|
2033
|
+
canTrack,
|
|
2034
|
+
contentId: item.id
|
|
2035
|
+
});
|
|
2036
|
+
const testFields = testGroupId ? getTestFields({
|
|
2037
|
+
item,
|
|
2038
|
+
testGroupId
|
|
2039
|
+
}) : void 0;
|
|
2040
|
+
if (testFields)
|
|
2041
|
+
return testFields;
|
|
2042
|
+
else {
|
|
2043
|
+
const randomVariationId = getRandomVariationId({
|
|
2044
|
+
variations: item.variations,
|
|
2045
|
+
id: item.id
|
|
2046
|
+
});
|
|
2047
|
+
setContentVariationCookie({
|
|
2048
|
+
contentId: item.id,
|
|
2049
|
+
value: randomVariationId,
|
|
2050
|
+
canTrack
|
|
2051
|
+
}).catch((err) => {
|
|
2052
|
+
console.error("could not store A/B test variation: ", err);
|
|
2053
|
+
});
|
|
2054
|
+
return getTestFields({
|
|
2055
|
+
item,
|
|
2056
|
+
testGroupId: randomVariationId
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
const handleABTesting = async ({ item, canTrack }) => {
|
|
2061
|
+
if (!checkIsBuilderContentWithVariations(item))
|
|
2062
|
+
return;
|
|
2063
|
+
const variationValue = await getContentVariation({
|
|
2064
|
+
item,
|
|
2065
|
+
canTrack
|
|
2066
|
+
});
|
|
2067
|
+
Object.assign(item, variationValue);
|
|
2068
|
+
};
|
|
2069
|
+
async function getContent(options) {
|
|
2070
|
+
return (await getAllContent({
|
|
2071
|
+
...options,
|
|
2072
|
+
limit: 1
|
|
2073
|
+
})).results[0] || null;
|
|
2074
|
+
}
|
|
2075
|
+
const generateContentUrl = (options) => {
|
|
2076
|
+
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey } = options;
|
|
2077
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`);
|
|
2078
|
+
const queryOptions = {
|
|
2079
|
+
...getBuilderSearchParamsFromWindow(),
|
|
2080
|
+
...normalizeSearchParams(options.options || {})
|
|
2081
|
+
};
|
|
2082
|
+
const flattened = flatten(queryOptions);
|
|
2083
|
+
for (const key in flattened)
|
|
2084
|
+
url.searchParams.set(key, String(flattened[key]));
|
|
2085
|
+
if (userAttributes)
|
|
2086
|
+
url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
|
|
2087
|
+
if (query) {
|
|
2088
|
+
const flattened1 = flatten({
|
|
2089
|
+
query
|
|
2090
|
+
});
|
|
2091
|
+
for (const key1 in flattened1)
|
|
2092
|
+
url.searchParams.set(key1, JSON.stringify(flattened1[key1]));
|
|
2093
|
+
}
|
|
2094
|
+
return url;
|
|
2095
|
+
};
|
|
2096
|
+
async function getAllContent(options) {
|
|
2097
|
+
const url = generateContentUrl(options);
|
|
2098
|
+
const fetch2 = await getFetch();
|
|
2099
|
+
const content = await fetch2(url.href).then((res) => res.json());
|
|
2100
|
+
const canTrack = options.canTrack !== false;
|
|
2101
|
+
if (canTrack)
|
|
2102
|
+
for (const item of content.results)
|
|
2103
|
+
await handleABTesting({
|
|
2104
|
+
item,
|
|
2105
|
+
canTrack
|
|
2106
|
+
});
|
|
2107
|
+
return content;
|
|
2108
|
+
}
|
|
2109
|
+
function isPreviewing() {
|
|
2110
|
+
if (!isBrowser())
|
|
2111
|
+
return false;
|
|
2112
|
+
if (isEditing())
|
|
2113
|
+
return false;
|
|
2114
|
+
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
2115
|
+
}
|
|
2116
|
+
const components = [];
|
|
2117
|
+
function registerComponent(component3, info) {
|
|
2118
|
+
components.push({
|
|
2119
|
+
component: component3,
|
|
2120
|
+
...info
|
|
2121
|
+
});
|
|
2122
|
+
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
2123
|
+
return component3;
|
|
2124
|
+
}
|
|
2125
|
+
const createRegisterComponentMessage = ({ component: _, ...info }) => ({
|
|
2126
|
+
type: "builder.registerComponent",
|
|
2127
|
+
data: prepareComponentInfoToSend(info)
|
|
2128
|
+
});
|
|
2129
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
2130
|
+
const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2131
|
+
const serializeFn = (fnValue) => {
|
|
2132
|
+
const fnStr = fnValue.toString().trim();
|
|
2133
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2134
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2135
|
+
};
|
|
2136
|
+
const prepareComponentInfoToSend = ({ inputs, ...info }) => ({
|
|
2137
|
+
...fastClone(info),
|
|
2138
|
+
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2139
|
+
...acc,
|
|
2140
|
+
[key]: serializeValue(value)
|
|
2141
|
+
}), {}))
|
|
2142
|
+
});
|
|
2083
2143
|
function uuidv4() {
|
|
2084
2144
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
2085
2145
|
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
@@ -2090,10 +2150,10 @@ function uuid() {
|
|
|
2090
2150
|
return uuidv4().replace(/-/g, "");
|
|
2091
2151
|
}
|
|
2092
2152
|
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
2093
|
-
const getSessionId = ({ canTrack }) => {
|
|
2153
|
+
const getSessionId = async ({ canTrack }) => {
|
|
2094
2154
|
if (!canTrack)
|
|
2095
2155
|
return void 0;
|
|
2096
|
-
const sessionId = getCookie({
|
|
2156
|
+
const sessionId = await getCookie({
|
|
2097
2157
|
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2098
2158
|
canTrack
|
|
2099
2159
|
});
|
|
@@ -2155,13 +2215,13 @@ const setVisitorId = ({ id, canTrack }) => setLocalStorageItem({
|
|
|
2155
2215
|
value: id,
|
|
2156
2216
|
canTrack
|
|
2157
2217
|
});
|
|
2158
|
-
const getTrackingEventData = ({ canTrack }) => {
|
|
2218
|
+
const getTrackingEventData = async ({ canTrack }) => {
|
|
2159
2219
|
if (!canTrack)
|
|
2160
2220
|
return {
|
|
2161
2221
|
visitorId: void 0,
|
|
2162
2222
|
sessionId: void 0
|
|
2163
2223
|
};
|
|
2164
|
-
const sessionId = getSessionId({
|
|
2224
|
+
const sessionId = await getSessionId({
|
|
2165
2225
|
canTrack
|
|
2166
2226
|
});
|
|
2167
2227
|
const visitorId = getVisitorId({
|
|
@@ -2172,11 +2232,11 @@ const getTrackingEventData = ({ canTrack }) => {
|
|
|
2172
2232
|
visitorId
|
|
2173
2233
|
};
|
|
2174
2234
|
};
|
|
2175
|
-
const createEvent = ({ type: eventType, canTrack, orgId, contentId, ...properties }) => ({
|
|
2235
|
+
const createEvent = async ({ type: eventType, canTrack, orgId, contentId, ...properties }) => ({
|
|
2176
2236
|
type: eventType,
|
|
2177
2237
|
data: {
|
|
2178
2238
|
...properties,
|
|
2179
|
-
...getTrackingEventData({
|
|
2239
|
+
...await getTrackingEventData({
|
|
2180
2240
|
canTrack
|
|
2181
2241
|
}),
|
|
2182
2242
|
ownerId: orgId,
|
|
@@ -2194,7 +2254,7 @@ async function track(eventProps) {
|
|
|
2194
2254
|
method: "POST",
|
|
2195
2255
|
body: JSON.stringify({
|
|
2196
2256
|
events: [
|
|
2197
|
-
createEvent(eventProps)
|
|
2257
|
+
await createEvent(eventProps)
|
|
2198
2258
|
]
|
|
2199
2259
|
}),
|
|
2200
2260
|
headers: {
|
|
@@ -2406,7 +2466,6 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
|
|
|
2406
2466
|
if (isBrowser()) {
|
|
2407
2467
|
if (isEditing()) {
|
|
2408
2468
|
state2.forceReRenderCount = state2.forceReRenderCount + 1;
|
|
2409
|
-
elementRef2.current && qwik._useMutableProps(elementRef2.current, true);
|
|
2410
2469
|
registerInsertMenu();
|
|
2411
2470
|
setupBrowserForEditing();
|
|
2412
2471
|
Object.values(allRegisteredComponents(props2)).forEach((registeredComponent) => {
|
|
@@ -2489,7 +2548,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
|
|
|
2489
2548
|
ref: elementRef,
|
|
2490
2549
|
onClick$: qwik.inlinedQrl((event) => {
|
|
2491
2550
|
const [elementRef2, props2, state2] = qwik.useLexicalScope();
|
|
2492
|
-
return
|
|
2551
|
+
return onClick2(props2, state2);
|
|
2493
2552
|
}, "RenderContent_component__Fragment_div_onClick_wLg5o3ZkpC0", [
|
|
2494
2553
|
elementRef,
|
|
2495
2554
|
props,
|