@builder.io/sdk-solid 2.0.16 → 2.0.22
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 +7 -2
- package/lib/browser/dev.js +109 -84
- package/lib/browser/dev.jsx +167 -169
- package/lib/browser/index.js +109 -84
- package/lib/browser/index.jsx +167 -169
- package/lib/edge/dev.js +180 -118
- package/lib/edge/dev.jsx +238 -203
- package/lib/edge/index.js +180 -118
- package/lib/edge/index.jsx +238 -203
- package/lib/node/dev.js +110 -85
- package/lib/node/dev.jsx +168 -170
- package/lib/node/index.js +110 -85
- package/lib/node/index.jsx +168 -170
- package/package.json +1 -1
package/lib/node/index.js
CHANGED
|
@@ -257,29 +257,6 @@ var parseCode = (code, {
|
|
|
257
257
|
const useCode = useReturn ? `return (${code});` : code;
|
|
258
258
|
return useCode;
|
|
259
259
|
};
|
|
260
|
-
|
|
261
|
-
// src/functions/evaluate/browser-runtime/browser.ts
|
|
262
|
-
var runInBrowser = ({
|
|
263
|
-
code,
|
|
264
|
-
builder,
|
|
265
|
-
context,
|
|
266
|
-
event,
|
|
267
|
-
localState,
|
|
268
|
-
rootSetState,
|
|
269
|
-
rootState
|
|
270
|
-
}) => {
|
|
271
|
-
const functionArgs = getFunctionArguments({
|
|
272
|
-
builder,
|
|
273
|
-
context,
|
|
274
|
-
event,
|
|
275
|
-
state: flattenState({
|
|
276
|
-
rootState,
|
|
277
|
-
localState,
|
|
278
|
-
rootSetState
|
|
279
|
-
})
|
|
280
|
-
});
|
|
281
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
282
|
-
};
|
|
283
260
|
function flattenState({
|
|
284
261
|
rootState,
|
|
285
262
|
localState,
|
|
@@ -314,6 +291,29 @@ function flattenState({
|
|
|
314
291
|
});
|
|
315
292
|
}
|
|
316
293
|
|
|
294
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
295
|
+
var runInBrowser = ({
|
|
296
|
+
code,
|
|
297
|
+
builder,
|
|
298
|
+
context,
|
|
299
|
+
event,
|
|
300
|
+
localState,
|
|
301
|
+
rootSetState,
|
|
302
|
+
rootState
|
|
303
|
+
}) => {
|
|
304
|
+
const functionArgs = getFunctionArguments({
|
|
305
|
+
builder,
|
|
306
|
+
context,
|
|
307
|
+
event,
|
|
308
|
+
state: flattenState({
|
|
309
|
+
rootState,
|
|
310
|
+
localState,
|
|
311
|
+
rootSetState
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
315
|
+
};
|
|
316
|
+
|
|
317
317
|
// src/constants/sdk-name.ts
|
|
318
318
|
var SDK_NAME_FOR_TARGET = (() => {
|
|
319
319
|
switch (TARGET) {
|
|
@@ -405,7 +405,7 @@ if (typeof output === 'object' && output !== null) {
|
|
|
405
405
|
};
|
|
406
406
|
var IVM_INSTANCE = null;
|
|
407
407
|
var IVM_CONTEXT = null;
|
|
408
|
-
var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik";
|
|
408
|
+
var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik" || SDK_NAME === "@builder.io/sdk-vue";
|
|
409
409
|
var getIvm = () => {
|
|
410
410
|
try {
|
|
411
411
|
if (IVM_INSTANCE)
|
|
@@ -1272,6 +1272,14 @@ function BlockWrapper(props) {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
}
|
|
1274
1274
|
var block_wrapper_default = BlockWrapper;
|
|
1275
|
+
function Awaiter(props) {
|
|
1276
|
+
onMount(() => {
|
|
1277
|
+
});
|
|
1278
|
+
return memo(() => props.children);
|
|
1279
|
+
}
|
|
1280
|
+
var awaiter_default = Awaiter;
|
|
1281
|
+
|
|
1282
|
+
// src/components/block/components/interactive-element.tsx
|
|
1275
1283
|
function InteractiveElement(props) {
|
|
1276
1284
|
const attributes = createMemo(() => {
|
|
1277
1285
|
return props.includeBlockProps ? {
|
|
@@ -1288,17 +1296,43 @@ function InteractiveElement(props) {
|
|
|
1288
1296
|
})
|
|
1289
1297
|
} : {};
|
|
1290
1298
|
});
|
|
1291
|
-
return createComponent(
|
|
1292
|
-
get
|
|
1293
|
-
return
|
|
1299
|
+
return createComponent(Show, {
|
|
1300
|
+
get fallback() {
|
|
1301
|
+
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
1302
|
+
get attributes() {
|
|
1303
|
+
return attributes();
|
|
1304
|
+
},
|
|
1305
|
+
get component() {
|
|
1306
|
+
return props.Wrapper;
|
|
1307
|
+
},
|
|
1308
|
+
get children() {
|
|
1309
|
+
return props.children;
|
|
1310
|
+
}
|
|
1311
|
+
}));
|
|
1294
1312
|
},
|
|
1295
|
-
get
|
|
1296
|
-
return props.Wrapper;
|
|
1313
|
+
get when() {
|
|
1314
|
+
return props.Wrapper.load;
|
|
1297
1315
|
},
|
|
1298
1316
|
get children() {
|
|
1299
|
-
return
|
|
1317
|
+
return createComponent(awaiter_default, {
|
|
1318
|
+
get load() {
|
|
1319
|
+
return props.Wrapper.load;
|
|
1320
|
+
},
|
|
1321
|
+
get fallback() {
|
|
1322
|
+
return props.Wrapper.fallback;
|
|
1323
|
+
},
|
|
1324
|
+
get props() {
|
|
1325
|
+
return props.wrapperProps;
|
|
1326
|
+
},
|
|
1327
|
+
get attributes() {
|
|
1328
|
+
return attributes();
|
|
1329
|
+
},
|
|
1330
|
+
get children() {
|
|
1331
|
+
return props.children;
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1300
1334
|
}
|
|
1301
|
-
})
|
|
1335
|
+
});
|
|
1302
1336
|
}
|
|
1303
1337
|
var interactive_element_default = InteractiveElement;
|
|
1304
1338
|
|
|
@@ -1673,7 +1707,7 @@ function Block(props) {
|
|
|
1673
1707
|
});
|
|
1674
1708
|
}
|
|
1675
1709
|
var block_default = Block;
|
|
1676
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1710
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
|
|
1677
1711
|
display: flex;
|
|
1678
1712
|
flex-direction: column;
|
|
1679
1713
|
align-items: stretch;
|
|
@@ -1709,7 +1743,7 @@ function BlocksWrapper(props) {
|
|
|
1709
1743
|
});
|
|
1710
1744
|
return [createComponent(Dynamic, mergeProps({
|
|
1711
1745
|
get ["class"]() {
|
|
1712
|
-
return className() + " dynamic-
|
|
1746
|
+
return className() + " dynamic-68b2d7fe";
|
|
1713
1747
|
},
|
|
1714
1748
|
ref(r$) {
|
|
1715
1749
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1805,7 +1839,7 @@ var getColumnsClass = (id) => {
|
|
|
1805
1839
|
|
|
1806
1840
|
// src/blocks/columns/columns.tsx
|
|
1807
1841
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1808
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1842
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
|
|
1809
1843
|
display: flex;
|
|
1810
1844
|
line-height: normal;
|
|
1811
1845
|
}`);
|
|
@@ -1926,7 +1960,7 @@ function Columns(props) {
|
|
|
1926
1960
|
const _el$ = _tmpl$3();
|
|
1927
1961
|
spread(_el$, mergeProps({
|
|
1928
1962
|
get ["class"]() {
|
|
1929
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
1963
|
+
return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
|
|
1930
1964
|
},
|
|
1931
1965
|
get style() {
|
|
1932
1966
|
return columnsCssVars();
|
|
@@ -2051,16 +2085,16 @@ function getSrcSet(url) {
|
|
|
2051
2085
|
// src/blocks/image/image.tsx
|
|
2052
2086
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2053
2087
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
2054
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
2055
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
2056
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2088
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
|
|
2089
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
|
|
2090
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
|
|
2057
2091
|
opacity: 1;
|
|
2058
2092
|
transition: opacity 0.2s ease-in-out;
|
|
2059
|
-
}.div-
|
|
2093
|
+
}.div-7e6ffddc {
|
|
2060
2094
|
width: 100%;
|
|
2061
2095
|
pointer-events: none;
|
|
2062
2096
|
font-size: 0;
|
|
2063
|
-
}.div-
|
|
2097
|
+
}.div-7e6ffddc-2 {
|
|
2064
2098
|
display: flex;
|
|
2065
2099
|
flex-direction: column;
|
|
2066
2100
|
align-items: stretch;
|
|
@@ -2124,7 +2158,7 @@ function Image(props) {
|
|
|
2124
2158
|
}
|
|
2125
2159
|
}), _el$3);
|
|
2126
2160
|
effect((_p$) => {
|
|
2127
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2161
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-7e6ffddc", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.altText ? void 0 : "presentation", _v$6 = {
|
|
2128
2162
|
"object-position": props.backgroundPosition || "center",
|
|
2129
2163
|
"object-fit": props.backgroundSize || "cover",
|
|
2130
2164
|
...aspectRatioCss()
|
|
@@ -5406,7 +5440,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5406
5440
|
}
|
|
5407
5441
|
|
|
5408
5442
|
// src/constants/sdk-version.ts
|
|
5409
|
-
var SDK_VERSION = "2.0.
|
|
5443
|
+
var SDK_VERSION = "2.0.22";
|
|
5410
5444
|
|
|
5411
5445
|
// src/functions/register.ts
|
|
5412
5446
|
var registry = {};
|
|
@@ -5759,22 +5793,6 @@ function EnableEditor(props) {
|
|
|
5759
5793
|
}
|
|
5760
5794
|
})(event);
|
|
5761
5795
|
}
|
|
5762
|
-
function evaluateJsCode() {
|
|
5763
|
-
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
5764
|
-
if (jsCode) {
|
|
5765
|
-
evaluate({
|
|
5766
|
-
code: jsCode,
|
|
5767
|
-
context: props.context || {},
|
|
5768
|
-
localState: void 0,
|
|
5769
|
-
rootState: props.builderContextSignal.rootState,
|
|
5770
|
-
rootSetState: props.builderContextSignal.rootSetState,
|
|
5771
|
-
/**
|
|
5772
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5773
|
-
*/
|
|
5774
|
-
enableCache: false
|
|
5775
|
-
});
|
|
5776
|
-
}
|
|
5777
|
-
}
|
|
5778
5796
|
function onClick(event) {
|
|
5779
5797
|
if (props.builderContextSignal.content) {
|
|
5780
5798
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
@@ -5811,7 +5829,7 @@ function EnableEditor(props) {
|
|
|
5811
5829
|
rootSetState: props.builderContextSignal.rootSetState,
|
|
5812
5830
|
enableCache: true
|
|
5813
5831
|
})));
|
|
5814
|
-
|
|
5832
|
+
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5815
5833
|
mergeNewRootState({
|
|
5816
5834
|
[key]: json
|
|
5817
5835
|
});
|
|
@@ -5835,6 +5853,8 @@ function EnableEditor(props) {
|
|
|
5835
5853
|
}
|
|
5836
5854
|
}
|
|
5837
5855
|
let elementRef;
|
|
5856
|
+
runHttpRequests();
|
|
5857
|
+
emitStateUpdate();
|
|
5838
5858
|
onMount(() => {
|
|
5839
5859
|
if (isBrowser()) {
|
|
5840
5860
|
if (isEditing()) {
|
|
@@ -5889,14 +5909,6 @@ function EnableEditor(props) {
|
|
|
5889
5909
|
}
|
|
5890
5910
|
}
|
|
5891
5911
|
});
|
|
5892
|
-
onMount(() => {
|
|
5893
|
-
if (!props.apiKey) {
|
|
5894
|
-
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
5895
|
-
}
|
|
5896
|
-
evaluateJsCode();
|
|
5897
|
-
runHttpRequests();
|
|
5898
|
-
emitStateUpdate();
|
|
5899
|
-
});
|
|
5900
5912
|
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
5901
5913
|
function onUpdateFn_0() {
|
|
5902
5914
|
if (props.content) {
|
|
@@ -5904,37 +5916,27 @@ function EnableEditor(props) {
|
|
|
5904
5916
|
}
|
|
5905
5917
|
}
|
|
5906
5918
|
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
5907
|
-
const
|
|
5919
|
+
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5908
5920
|
function onUpdateFn_1() {
|
|
5909
|
-
evaluateJsCode();
|
|
5910
|
-
}
|
|
5911
|
-
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
|
|
5912
|
-
const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
5913
|
-
function onUpdateFn_2() {
|
|
5914
|
-
runHttpRequests();
|
|
5915
|
-
}
|
|
5916
|
-
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
|
|
5917
|
-
const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5918
|
-
function onUpdateFn_3() {
|
|
5919
5921
|
emitStateUpdate();
|
|
5920
5922
|
}
|
|
5921
|
-
createEffect(on(() => [
|
|
5922
|
-
const
|
|
5923
|
-
function
|
|
5923
|
+
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
|
|
5924
|
+
const onUpdateFn_2_props_data = createMemo(() => props.data);
|
|
5925
|
+
function onUpdateFn_2() {
|
|
5924
5926
|
if (props.data) {
|
|
5925
5927
|
mergeNewRootState(props.data);
|
|
5926
5928
|
}
|
|
5927
5929
|
}
|
|
5928
|
-
createEffect(on(() => [
|
|
5929
|
-
const
|
|
5930
|
-
function
|
|
5930
|
+
createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
5931
|
+
const onUpdateFn_3_props_locale = createMemo(() => props.locale);
|
|
5932
|
+
function onUpdateFn_3() {
|
|
5931
5933
|
if (props.locale) {
|
|
5932
5934
|
mergeNewRootState({
|
|
5933
5935
|
locale: props.locale
|
|
5934
5936
|
});
|
|
5935
5937
|
}
|
|
5936
5938
|
}
|
|
5937
|
-
createEffect(on(() => [
|
|
5939
|
+
createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
5938
5940
|
return createComponent(builder_context_default.Provider, {
|
|
5939
5941
|
get value() {
|
|
5940
5942
|
return props.builderContextSignal;
|
|
@@ -6102,6 +6104,29 @@ function ContentComponent(props) {
|
|
|
6102
6104
|
rootState: newRootState
|
|
6103
6105
|
}));
|
|
6104
6106
|
}
|
|
6107
|
+
if (!props.apiKey) {
|
|
6108
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
6109
|
+
}
|
|
6110
|
+
const jsCode = builderContextSignal().content?.data?.jsCode;
|
|
6111
|
+
if (jsCode) {
|
|
6112
|
+
evaluate({
|
|
6113
|
+
code: jsCode,
|
|
6114
|
+
context: props.context || {},
|
|
6115
|
+
localState: void 0,
|
|
6116
|
+
rootState: builderContextSignal().rootState,
|
|
6117
|
+
rootSetState: (newState) => {
|
|
6118
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
6119
|
+
...PREVIOUS_VALUE,
|
|
6120
|
+
rootState: newState
|
|
6121
|
+
}));
|
|
6122
|
+
},
|
|
6123
|
+
isExpression: false,
|
|
6124
|
+
/**
|
|
6125
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
6126
|
+
*/
|
|
6127
|
+
enableCache: false
|
|
6128
|
+
});
|
|
6129
|
+
}
|
|
6105
6130
|
return createComponent(components_context_default.Provider, {
|
|
6106
6131
|
get value() {
|
|
6107
6132
|
return {
|