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