@builder.io/sdk-solid 0.8.0 → 0.9.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 +48 -19
- package/lib/browser/dev.js +118 -149
- package/lib/browser/dev.jsx +40 -93
- package/lib/browser/index.js +118 -142
- package/lib/browser/index.jsx +40 -91
- package/lib/edge/dev.js +118 -149
- package/lib/edge/dev.jsx +40 -93
- package/lib/edge/index.js +118 -142
- package/lib/edge/index.jsx +40 -91
- package/lib/node/dev.js +134 -160
- package/lib/node/dev.jsx +56 -104
- package/lib/node/index.js +132 -151
- package/lib/node/index.jsx +54 -100
- package/package.json +1 -1
package/lib/node/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
|
|
@@ -225,11 +227,16 @@ var set = (obj, _path, value) => {
|
|
|
225
227
|
|
|
226
228
|
// src/functions/evaluate/node-runtime/safeDynamicRequire.ts
|
|
227
229
|
import { createRequire } from "node:module";
|
|
228
|
-
var noop = () =>
|
|
230
|
+
var noop = () => {
|
|
231
|
+
};
|
|
229
232
|
var safeDynamicRequire = noop;
|
|
230
233
|
try {
|
|
231
234
|
safeDynamicRequire = createRequire(import.meta.url);
|
|
232
235
|
} catch (error) {
|
|
236
|
+
try {
|
|
237
|
+
safeDynamicRequire = eval("require");
|
|
238
|
+
} catch (error2) {
|
|
239
|
+
}
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
// src/functions/evaluate/node-runtime/node-runtime.ts
|
|
@@ -719,85 +726,10 @@ function getBlockActions(options) {
|
|
|
719
726
|
return obj;
|
|
720
727
|
}
|
|
721
728
|
|
|
722
|
-
// src/functions/sanitize-react-native-block-styles.ts
|
|
723
|
-
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
724
|
-
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
725
|
-
var SHOW_WARNINGS = false;
|
|
726
|
-
var normalizeNumber = (value) => {
|
|
727
|
-
if (Number.isNaN(value)) {
|
|
728
|
-
return void 0;
|
|
729
|
-
} else if (value < 0) {
|
|
730
|
-
return 0;
|
|
731
|
-
} else {
|
|
732
|
-
return value;
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
var sanitizeReactNativeBlockStyles = (styles) => {
|
|
736
|
-
return Object.keys(styles).reduce((acc, key) => {
|
|
737
|
-
const propertyValue = styles[key];
|
|
738
|
-
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
739
|
-
if (SHOW_WARNINGS) {
|
|
740
|
-
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
741
|
-
}
|
|
742
|
-
return acc;
|
|
743
|
-
}
|
|
744
|
-
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
745
|
-
if (SHOW_WARNINGS) {
|
|
746
|
-
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
747
|
-
}
|
|
748
|
-
return acc;
|
|
749
|
-
}
|
|
750
|
-
if (typeof propertyValue === "string") {
|
|
751
|
-
const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
|
|
752
|
-
if (isPixelUnit) {
|
|
753
|
-
const newValue = parseFloat(propertyValue);
|
|
754
|
-
const normalizedValue = normalizeNumber(newValue);
|
|
755
|
-
if (normalizedValue) {
|
|
756
|
-
return {
|
|
757
|
-
...acc,
|
|
758
|
-
[key]: normalizedValue
|
|
759
|
-
};
|
|
760
|
-
} else {
|
|
761
|
-
return acc;
|
|
762
|
-
}
|
|
763
|
-
} else if (propertyValue === "0") {
|
|
764
|
-
return {
|
|
765
|
-
...acc,
|
|
766
|
-
[key]: 0
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
return {
|
|
771
|
-
...acc,
|
|
772
|
-
[key]: propertyValue
|
|
773
|
-
};
|
|
774
|
-
}, {});
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
// src/functions/get-react-native-block-styles.ts
|
|
778
|
-
function getReactNativeBlockStyles({
|
|
779
|
-
block,
|
|
780
|
-
context,
|
|
781
|
-
blockStyles
|
|
782
|
-
}) {
|
|
783
|
-
const responsiveStyles = block.responsiveStyles;
|
|
784
|
-
if (!responsiveStyles) {
|
|
785
|
-
return {};
|
|
786
|
-
}
|
|
787
|
-
const styles = {
|
|
788
|
-
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
789
|
-
...context.inheritedStyles,
|
|
790
|
-
...responsiveStyles.large || {},
|
|
791
|
-
...responsiveStyles.medium || {},
|
|
792
|
-
...responsiveStyles.small || {},
|
|
793
|
-
...blockStyles
|
|
794
|
-
};
|
|
795
|
-
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
796
|
-
return newStyles;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
729
|
// src/functions/transform-block-properties.ts
|
|
800
|
-
function transformBlockProperties(
|
|
730
|
+
function transformBlockProperties({
|
|
731
|
+
properties
|
|
732
|
+
}) {
|
|
801
733
|
return properties;
|
|
802
734
|
}
|
|
803
735
|
|
|
@@ -818,14 +750,11 @@ function getBlockProperties({
|
|
|
818
750
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
819
751
|
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
820
752
|
};
|
|
821
|
-
|
|
822
|
-
properties
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
return transformBlockProperties(properties);
|
|
753
|
+
return transformBlockProperties({
|
|
754
|
+
properties,
|
|
755
|
+
context,
|
|
756
|
+
block
|
|
757
|
+
});
|
|
829
758
|
}
|
|
830
759
|
function getStyleAttribute(style) {
|
|
831
760
|
switch (TARGET) {
|
|
@@ -1115,6 +1044,7 @@ function Block(props) {
|
|
|
1115
1044
|
var Block_default = Block;
|
|
1116
1045
|
|
|
1117
1046
|
// src/components/blocks/blocks-wrapper.tsx
|
|
1047
|
+
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1118
1048
|
import { css as css2 } from "solid-styled-components";
|
|
1119
1049
|
function BlocksWrapper(props) {
|
|
1120
1050
|
function className() {
|
|
@@ -1148,7 +1078,7 @@ function BlocksWrapper(props) {
|
|
|
1148
1078
|
);
|
|
1149
1079
|
}
|
|
1150
1080
|
}
|
|
1151
|
-
return <
|
|
1081
|
+
return <Dynamic4
|
|
1152
1082
|
class={className() + " " + css2({
|
|
1153
1083
|
display: "flex",
|
|
1154
1084
|
flexDirection: "column",
|
|
@@ -1161,7 +1091,9 @@ function BlocksWrapper(props) {
|
|
|
1161
1091
|
onClick={(event) => onClick()}
|
|
1162
1092
|
onMouseEnter={(event) => onMouseEnter()}
|
|
1163
1093
|
onKeyPress={(event) => onClick()}
|
|
1164
|
-
|
|
1094
|
+
{...props.BlocksWrapperProps}
|
|
1095
|
+
component={props.BlocksWrapper}
|
|
1096
|
+
>{props.children}</Dynamic4>;
|
|
1165
1097
|
}
|
|
1166
1098
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
1167
1099
|
|
|
@@ -1174,6 +1106,8 @@ function Blocks(props) {
|
|
|
1174
1106
|
parent={props.parent}
|
|
1175
1107
|
path={props.path}
|
|
1176
1108
|
styleProp={props.styleProp}
|
|
1109
|
+
BlocksWrapper={props.context?.BlocksWrapper}
|
|
1110
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps}
|
|
1177
1111
|
>
|
|
1178
1112
|
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1179
1113
|
const index = _index();
|
|
@@ -2010,8 +1944,8 @@ function CustomCode(props) {
|
|
|
2010
1944
|
try {
|
|
2011
1945
|
scriptsRun().push(script.innerText);
|
|
2012
1946
|
new Function(script.innerText)();
|
|
2013
|
-
} catch (
|
|
2014
|
-
console.warn("`CustomCode`: Error running script:",
|
|
1947
|
+
} catch (error2) {
|
|
1948
|
+
console.warn("`CustomCode`: Error running script:", error2);
|
|
2015
1949
|
}
|
|
2016
1950
|
}
|
|
2017
1951
|
}
|
|
@@ -2090,8 +2024,8 @@ function Embed(props) {
|
|
|
2090
2024
|
try {
|
|
2091
2025
|
scriptsRun().push(script.innerText);
|
|
2092
2026
|
new Function(script.innerText)();
|
|
2093
|
-
} catch (
|
|
2094
|
-
console.warn("`Embed`: Error running script:",
|
|
2027
|
+
} catch (error2) {
|
|
2028
|
+
console.warn("`Embed`: Error running script:", error2);
|
|
2095
2029
|
}
|
|
2096
2030
|
}
|
|
2097
2031
|
}
|
|
@@ -2668,6 +2602,7 @@ var Inlined_script_default = InlinedScript;
|
|
|
2668
2602
|
|
|
2669
2603
|
// src/components/content/components/enable-editor.tsx
|
|
2670
2604
|
import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
2605
|
+
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
2671
2606
|
|
|
2672
2607
|
// src/helpers/preview-lru-cache/get.ts
|
|
2673
2608
|
function getPreviewContent(_searchParams) {
|
|
@@ -2896,8 +2831,8 @@ async function fetchEntries(options) {
|
|
|
2896
2831
|
return null;
|
|
2897
2832
|
}
|
|
2898
2833
|
return _processContentResult(options, content);
|
|
2899
|
-
} catch (
|
|
2900
|
-
logger.error("Error fetching data. ",
|
|
2834
|
+
} catch (error2) {
|
|
2835
|
+
logger.error("Error fetching data. ", error2);
|
|
2901
2836
|
return null;
|
|
2902
2837
|
}
|
|
2903
2838
|
}
|
|
@@ -3154,7 +3089,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3154
3089
|
};
|
|
3155
3090
|
|
|
3156
3091
|
// src/constants/sdk-version.ts
|
|
3157
|
-
var SDK_VERSION = "0.
|
|
3092
|
+
var SDK_VERSION = "0.9.0";
|
|
3158
3093
|
|
|
3159
3094
|
// src/functions/register.ts
|
|
3160
3095
|
var registry = {};
|
|
@@ -3245,18 +3180,18 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3245
3180
|
const id = data.data.id;
|
|
3246
3181
|
const fn = new Function(text);
|
|
3247
3182
|
let result;
|
|
3248
|
-
let
|
|
3183
|
+
let error2 = null;
|
|
3249
3184
|
try {
|
|
3250
3185
|
result = fn.apply(null, args);
|
|
3251
3186
|
} catch (err) {
|
|
3252
|
-
|
|
3187
|
+
error2 = err;
|
|
3253
3188
|
}
|
|
3254
|
-
if (
|
|
3189
|
+
if (error2) {
|
|
3255
3190
|
window.parent?.postMessage({
|
|
3256
3191
|
type: "builder.evaluateError",
|
|
3257
3192
|
data: {
|
|
3258
3193
|
id,
|
|
3259
|
-
error:
|
|
3194
|
+
error: error2.message
|
|
3260
3195
|
}
|
|
3261
3196
|
}, "*");
|
|
3262
3197
|
} else {
|
|
@@ -3292,6 +3227,9 @@ function EnableEditor(props) {
|
|
|
3292
3227
|
const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
|
|
3293
3228
|
const [lastUpdated, setLastUpdated] = createSignal10(0);
|
|
3294
3229
|
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
|
|
3230
|
+
const [ContentWrapper, setContentWrapper] = createSignal10(
|
|
3231
|
+
props.contentWrapper || "div"
|
|
3232
|
+
);
|
|
3295
3233
|
const [httpReqsData, setHttpReqsData] = createSignal10({});
|
|
3296
3234
|
const [clicked, setClicked] = createSignal10(false);
|
|
3297
3235
|
function mergeNewContent(newContent) {
|
|
@@ -3536,7 +3474,7 @@ function EnableEditor(props) {
|
|
|
3536
3474
|
emitStateUpdate();
|
|
3537
3475
|
}
|
|
3538
3476
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
3539
|
-
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><
|
|
3477
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
|
|
3540
3478
|
class={`variant-${props.content?.testVariationId || props.content?.id}`}
|
|
3541
3479
|
{...{}}
|
|
3542
3480
|
key={forceReRenderCount()}
|
|
@@ -3549,7 +3487,9 @@ function EnableEditor(props) {
|
|
|
3549
3487
|
hidden: true,
|
|
3550
3488
|
"aria-hidden": true
|
|
3551
3489
|
}}
|
|
3552
|
-
|
|
3490
|
+
{...props.contentWrapperProps}
|
|
3491
|
+
component={ContentWrapper()}
|
|
3492
|
+
>{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
|
|
3553
3493
|
}
|
|
3554
3494
|
var Enable_editor_default = EnableEditor;
|
|
3555
3495
|
|
|
@@ -3739,7 +3679,9 @@ function ContentComponent(props) {
|
|
|
3739
3679
|
}),
|
|
3740
3680
|
{}
|
|
3741
3681
|
),
|
|
3742
|
-
inheritedStyles: {}
|
|
3682
|
+
inheritedStyles: {},
|
|
3683
|
+
BlocksWrapper: props.blocksWrapper || "div",
|
|
3684
|
+
BlocksWrapperProps: props.blocksWrapperProps || {}
|
|
3743
3685
|
});
|
|
3744
3686
|
function contentSetState(newRootState) {
|
|
3745
3687
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -3762,6 +3704,8 @@ function ContentComponent(props) {
|
|
|
3762
3704
|
enrich={props.enrich}
|
|
3763
3705
|
showContent={props.showContent}
|
|
3764
3706
|
builderContextSignal={builderContextSignal()}
|
|
3707
|
+
contentWrapper={props.contentWrapper}
|
|
3708
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3765
3709
|
{...{
|
|
3766
3710
|
setBuilderContextSignal
|
|
3767
3711
|
}}
|
|
@@ -3840,6 +3784,10 @@ function ContentVariants(props) {
|
|
|
3840
3784
|
includeRefs={props.includeRefs}
|
|
3841
3785
|
enrich={props.enrich}
|
|
3842
3786
|
isSsrAbTest={shouldRenderVariants()}
|
|
3787
|
+
blocksWrapper={props.blocksWrapper}
|
|
3788
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3789
|
+
contentWrapper={props.contentWrapper}
|
|
3790
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3843
3791
|
/>;
|
|
3844
3792
|
}}</For5>
|
|
3845
3793
|
</Show12>
|
|
@@ -3858,6 +3806,10 @@ function ContentVariants(props) {
|
|
|
3858
3806
|
includeRefs={props.includeRefs}
|
|
3859
3807
|
enrich={props.enrich}
|
|
3860
3808
|
isSsrAbTest={shouldRenderVariants()}
|
|
3809
|
+
blocksWrapper={props.blocksWrapper}
|
|
3810
|
+
blocksWrapperProps={props.blocksWrapperProps}
|
|
3811
|
+
contentWrapper={props.contentWrapper}
|
|
3812
|
+
contentWrapperProps={props.contentWrapperProps}
|
|
3861
3813
|
/>
|
|
3862
3814
|
</>;
|
|
3863
3815
|
}
|