@builder.io/sdk-solid 0.8.1 → 0.10.0
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/dist/index.d.ts +50 -21
- package/lib/browser/dev.js +122 -153
- package/lib/browser/dev.jsx +44 -97
- package/lib/browser/index.js +122 -146
- package/lib/browser/index.jsx +44 -95
- package/lib/edge/dev.js +122 -153
- package/lib/edge/dev.jsx +44 -97
- package/lib/edge/index.js +122 -146
- package/lib/edge/index.jsx +44 -95
- package/lib/node/dev.js +122 -153
- package/lib/node/dev.jsx +44 -97
- package/lib/node/index.js +122 -146
- package/lib/node/index.jsx +44 -95
- package/package.json +1 -1
package/lib/browser/dev.jsx
CHANGED
|
@@ -41,7 +41,9 @@ var builder_context_default = createContext({
|
|
|
41
41
|
apiKey: null,
|
|
42
42
|
apiVersion: void 0,
|
|
43
43
|
componentInfos: {},
|
|
44
|
-
inheritedStyles: {}
|
|
44
|
+
inheritedStyles: {},
|
|
45
|
+
BlocksWrapper: "div",
|
|
46
|
+
BlocksWrapperProps: {}
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
// src/context/components.context.ts
|
|
@@ -598,85 +600,10 @@ function getBlockActions(options) {
|
|
|
598
600
|
return obj;
|
|
599
601
|
}
|
|
600
602
|
|
|
601
|
-
// src/functions/sanitize-react-native-block-styles.ts
|
|
602
|
-
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
603
|
-
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
604
|
-
var SHOW_WARNINGS = false;
|
|
605
|
-
var normalizeNumber = (value) => {
|
|
606
|
-
if (Number.isNaN(value)) {
|
|
607
|
-
return void 0;
|
|
608
|
-
} else if (value < 0) {
|
|
609
|
-
return 0;
|
|
610
|
-
} else {
|
|
611
|
-
return value;
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
var sanitizeReactNativeBlockStyles = (styles) => {
|
|
615
|
-
return Object.keys(styles).reduce((acc, key) => {
|
|
616
|
-
const propertyValue = styles[key];
|
|
617
|
-
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
618
|
-
if (SHOW_WARNINGS) {
|
|
619
|
-
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
620
|
-
}
|
|
621
|
-
return acc;
|
|
622
|
-
}
|
|
623
|
-
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
624
|
-
if (SHOW_WARNINGS) {
|
|
625
|
-
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
626
|
-
}
|
|
627
|
-
return acc;
|
|
628
|
-
}
|
|
629
|
-
if (typeof propertyValue === "string") {
|
|
630
|
-
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
631
|
-
if (isPixelUnit) {
|
|
632
|
-
const newValue = parseFloat(propertyValue);
|
|
633
|
-
const normalizedValue = normalizeNumber(newValue);
|
|
634
|
-
if (normalizedValue) {
|
|
635
|
-
return {
|
|
636
|
-
...acc,
|
|
637
|
-
[key]: normalizedValue
|
|
638
|
-
};
|
|
639
|
-
} else {
|
|
640
|
-
return acc;
|
|
641
|
-
}
|
|
642
|
-
} else if (propertyValue === "0") {
|
|
643
|
-
return {
|
|
644
|
-
...acc,
|
|
645
|
-
[key]: 0
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return {
|
|
650
|
-
...acc,
|
|
651
|
-
[key]: propertyValue
|
|
652
|
-
};
|
|
653
|
-
}, {});
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
// src/functions/get-react-native-block-styles.ts
|
|
657
|
-
function getReactNativeBlockStyles({
|
|
658
|
-
block,
|
|
659
|
-
context,
|
|
660
|
-
blockStyles
|
|
661
|
-
}) {
|
|
662
|
-
const responsiveStyles = block.responsiveStyles;
|
|
663
|
-
if (!responsiveStyles) {
|
|
664
|
-
return {};
|
|
665
|
-
}
|
|
666
|
-
const styles = {
|
|
667
|
-
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
668
|
-
...context.inheritedStyles,
|
|
669
|
-
...responsiveStyles.large || {},
|
|
670
|
-
...responsiveStyles.medium || {},
|
|
671
|
-
...responsiveStyles.small || {},
|
|
672
|
-
...blockStyles
|
|
673
|
-
};
|
|
674
|
-
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
675
|
-
return newStyles;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
603
|
// src/functions/transform-block-properties.ts
|
|
679
|
-
function transformBlockProperties(
|
|
604
|
+
function transformBlockProperties({
|
|
605
|
+
properties
|
|
606
|
+
}) {
|
|
680
607
|
return properties;
|
|
681
608
|
}
|
|
682
609
|
|
|
@@ -697,14 +624,11 @@ function getBlockProperties({
|
|
|
697
624
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
698
625
|
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
699
626
|
};
|
|
700
|
-
|
|
701
|
-
properties
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
return transformBlockProperties(properties);
|
|
627
|
+
return transformBlockProperties({
|
|
628
|
+
properties,
|
|
629
|
+
context,
|
|
630
|
+
block
|
|
631
|
+
});
|
|
708
632
|
}
|
|
709
633
|
function getStyleAttribute(style) {
|
|
710
634
|
switch (TARGET) {
|
|
@@ -994,6 +918,7 @@ function Block(props) {
|
|
|
994
918
|
var Block_default = Block;
|
|
995
919
|
|
|
996
920
|
// src/components/blocks/blocks-wrapper.tsx
|
|
921
|
+
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
997
922
|
import { css as css2 } from "solid-styled-components";
|
|
998
923
|
function BlocksWrapper(props) {
|
|
999
924
|
function className() {
|
|
@@ -1027,7 +952,7 @@ function BlocksWrapper(props) {
|
|
|
1027
952
|
);
|
|
1028
953
|
}
|
|
1029
954
|
}
|
|
1030
|
-
return <
|
|
955
|
+
return <Dynamic4
|
|
1031
956
|
class={className() + " " + css2({
|
|
1032
957
|
display: "flex",
|
|
1033
958
|
flexDirection: "column",
|
|
@@ -1040,7 +965,9 @@ function BlocksWrapper(props) {
|
|
|
1040
965
|
onClick={(event) => onClick()}
|
|
1041
966
|
onMouseEnter={(event) => onMouseEnter()}
|
|
1042
967
|
onKeyPress={(event) => onClick()}
|
|
1043
|
-
|
|
968
|
+
{...props.BlocksWrapperProps}
|
|
969
|
+
component={props.BlocksWrapper}
|
|
970
|
+
>{props.children}</Dynamic4>;
|
|
1044
971
|
}
|
|
1045
972
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
1046
973
|
|
|
@@ -1053,6 +980,8 @@ function Blocks(props) {
|
|
|
1053
980
|
parent={props.parent}
|
|
1054
981
|
path={props.path}
|
|
1055
982
|
styleProp={props.styleProp}
|
|
983
|
+
BlocksWrapper={props.context?.BlocksWrapper}
|
|
984
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps}
|
|
1056
985
|
>
|
|
1057
986
|
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1058
987
|
const index = _index();
|
|
@@ -2547,6 +2476,7 @@ var Inlined_script_default = InlinedScript;
|
|
|
2547
2476
|
|
|
2548
2477
|
// src/components/content/components/enable-editor.tsx
|
|
2549
2478
|
import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
2479
|
+
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
2550
2480
|
|
|
2551
2481
|
// src/helpers/preview-lru-cache/get.ts
|
|
2552
2482
|
function getPreviewContent(_searchParams) {
|
|
@@ -2722,7 +2652,7 @@ async function fetchOneEntry(options) {
|
|
|
2722
2652
|
limit: 1
|
|
2723
2653
|
});
|
|
2724
2654
|
if (allContent) {
|
|
2725
|
-
return allContent
|
|
2655
|
+
return allContent[0] || null;
|
|
2726
2656
|
}
|
|
2727
2657
|
return null;
|
|
2728
2658
|
}
|
|
@@ -2745,9 +2675,9 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
|
|
|
2745
2675
|
content.results = newResults;
|
|
2746
2676
|
}
|
|
2747
2677
|
if (!canTrack)
|
|
2748
|
-
return content;
|
|
2678
|
+
return content.results;
|
|
2749
2679
|
if (!(isBrowser() || TARGET === "reactNative"))
|
|
2750
|
-
return content;
|
|
2680
|
+
return content.results;
|
|
2751
2681
|
try {
|
|
2752
2682
|
const newResults = [];
|
|
2753
2683
|
for (const item of content.results) {
|
|
@@ -2760,7 +2690,7 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
|
|
|
2760
2690
|
} catch (e) {
|
|
2761
2691
|
logger.error("Could not process A/B tests. ", e);
|
|
2762
2692
|
}
|
|
2763
|
-
return content;
|
|
2693
|
+
return content.results;
|
|
2764
2694
|
};
|
|
2765
2695
|
async function fetchEntries(options) {
|
|
2766
2696
|
try {
|
|
@@ -3033,7 +2963,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3033
2963
|
};
|
|
3034
2964
|
|
|
3035
2965
|
// src/constants/sdk-version.ts
|
|
3036
|
-
var SDK_VERSION = "0.
|
|
2966
|
+
var SDK_VERSION = "0.10.0";
|
|
3037
2967
|
|
|
3038
2968
|
// src/functions/register.ts
|
|
3039
2969
|
var registry = {};
|
|
@@ -3171,6 +3101,9 @@ function EnableEditor(props) {
|
|
|
3171
3101
|
const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
|
|
3172
3102
|
const [lastUpdated, setLastUpdated] = createSignal10(0);
|
|
3173
3103
|
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
|
|
3104
|
+
const [ContentWrapper, setContentWrapper] = createSignal10(
|
|
3105
|
+
props.contentWrapper || "div"
|
|
3106
|
+
);
|
|
3174
3107
|
const [httpReqsData, setHttpReqsData] = createSignal10({});
|
|
3175
3108
|
const [clicked, setClicked] = createSignal10(false);
|
|
3176
3109
|
function mergeNewContent(newContent) {
|
|
@@ -3415,7 +3348,7 @@ function EnableEditor(props) {
|
|
|
3415
3348
|
emitStateUpdate();
|
|
3416
3349
|
}
|
|
3417
3350
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
3418
|
-
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><
|
|
3351
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
|
|
3419
3352
|
class={`variant-${props.content?.testVariationId || props.content?.id}`}
|
|
3420
3353
|
{...{}}
|
|
3421
3354
|
key={forceReRenderCount()}
|
|
@@ -3428,7 +3361,9 @@ function EnableEditor(props) {
|
|
|
3428
3361
|
hidden: true,
|
|
3429
3362
|
"aria-hidden": true
|
|
3430
3363
|
}}
|
|
3431
|
-
|
|
3364
|
+
{...props.contentWrapperProps}
|
|
3365
|
+
component={ContentWrapper()}
|
|
3366
|
+
>{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
|
|
3432
3367
|
}
|
|
3433
3368
|
var Enable_editor_default = EnableEditor;
|
|
3434
3369
|
|
|
@@ -3618,7 +3553,9 @@ function ContentComponent(props) {
|
|
|
3618
3553
|
}),
|
|
3619
3554
|
{}
|
|
3620
3555
|
),
|
|
3621
|
-
inheritedStyles: {}
|
|
3556
|
+
inheritedStyles: {},
|
|
3557
|
+
BlocksWrapper: props.blocksWrapper || "div",
|
|
3558
|
+
BlocksWrapperProps: props.blocksWrapperProps || {}
|
|
3622
3559
|
});
|
|
3623
3560
|
function contentSetState(newRootState) {
|
|
3624
3561
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -3641,6 +3578,8 @@ function ContentComponent(props) {
|
|
|
3641
3578
|
enrich={props.enrich}
|
|
3642
3579
|
showContent={props.showContent}
|
|
3643
3580
|
builderContextSignal={builderContextSignal()}
|
|
3581
|
+
contentWrapper={props.contentWrapper}
|
|
3582
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3644
3583
|
{...{
|
|
3645
3584
|
setBuilderContextSignal
|
|
3646
3585
|
}}
|
|
@@ -3719,6 +3658,10 @@ function ContentVariants(props) {
|
|
|
3719
3658
|
includeRefs={props.includeRefs}
|
|
3720
3659
|
enrich={props.enrich}
|
|
3721
3660
|
isSsrAbTest={shouldRenderVariants()}
|
|
3661
|
+
blocksWrapper={props.blocksWrapper}
|
|
3662
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3663
|
+
contentWrapper={props.contentWrapper}
|
|
3664
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3722
3665
|
/>;
|
|
3723
3666
|
}}</For5>
|
|
3724
3667
|
</Show12>
|
|
@@ -3737,6 +3680,10 @@ function ContentVariants(props) {
|
|
|
3737
3680
|
includeRefs={props.includeRefs}
|
|
3738
3681
|
enrich={props.enrich}
|
|
3739
3682
|
isSsrAbTest={shouldRenderVariants()}
|
|
3683
|
+
blocksWrapper={props.blocksWrapper}
|
|
3684
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3685
|
+
contentWrapper={props.contentWrapper}
|
|
3686
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3740
3687
|
/>
|
|
3741
3688
|
</>;
|
|
3742
3689
|
}
|