@builder.io/sdk-solid 2.0.15 → 2.0.21
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 +6 -1
- package/lib/browser/dev.js +118 -87
- package/lib/browser/dev.jsx +176 -172
- package/lib/browser/index.js +118 -87
- package/lib/browser/index.jsx +176 -172
- package/lib/edge/dev.js +189 -121
- package/lib/edge/dev.jsx +247 -206
- package/lib/edge/index.js +189 -121
- package/lib/edge/index.jsx +247 -206
- package/lib/node/dev.js +119 -88
- package/lib/node/dev.jsx +177 -173
- package/lib/node/index.js +119 -88
- package/lib/node/index.jsx +177 -173
- package/package.json +1 -1
package/lib/node/dev.js
CHANGED
|
@@ -258,29 +258,6 @@ var parseCode = (code, {
|
|
|
258
258
|
const useCode = useReturn ? `return (${code});` : code;
|
|
259
259
|
return useCode;
|
|
260
260
|
};
|
|
261
|
-
|
|
262
|
-
// src/functions/evaluate/browser-runtime/browser.ts
|
|
263
|
-
var runInBrowser = ({
|
|
264
|
-
code,
|
|
265
|
-
builder,
|
|
266
|
-
context,
|
|
267
|
-
event,
|
|
268
|
-
localState,
|
|
269
|
-
rootSetState,
|
|
270
|
-
rootState
|
|
271
|
-
}) => {
|
|
272
|
-
const functionArgs = getFunctionArguments({
|
|
273
|
-
builder,
|
|
274
|
-
context,
|
|
275
|
-
event,
|
|
276
|
-
state: flattenState({
|
|
277
|
-
rootState,
|
|
278
|
-
localState,
|
|
279
|
-
rootSetState
|
|
280
|
-
})
|
|
281
|
-
});
|
|
282
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
283
|
-
};
|
|
284
261
|
function flattenState({
|
|
285
262
|
rootState,
|
|
286
263
|
localState,
|
|
@@ -315,6 +292,29 @@ function flattenState({
|
|
|
315
292
|
});
|
|
316
293
|
}
|
|
317
294
|
|
|
295
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
296
|
+
var runInBrowser = ({
|
|
297
|
+
code,
|
|
298
|
+
builder,
|
|
299
|
+
context,
|
|
300
|
+
event,
|
|
301
|
+
localState,
|
|
302
|
+
rootSetState,
|
|
303
|
+
rootState
|
|
304
|
+
}) => {
|
|
305
|
+
const functionArgs = getFunctionArguments({
|
|
306
|
+
builder,
|
|
307
|
+
context,
|
|
308
|
+
event,
|
|
309
|
+
state: flattenState({
|
|
310
|
+
rootState,
|
|
311
|
+
localState,
|
|
312
|
+
rootSetState
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
316
|
+
};
|
|
317
|
+
|
|
318
318
|
// src/constants/sdk-name.ts
|
|
319
319
|
var SDK_NAME_FOR_TARGET = (() => {
|
|
320
320
|
switch (TARGET) {
|
|
@@ -406,7 +406,7 @@ if (typeof output === 'object' && output !== null) {
|
|
|
406
406
|
};
|
|
407
407
|
var IVM_INSTANCE = null;
|
|
408
408
|
var IVM_CONTEXT = null;
|
|
409
|
-
var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik";
|
|
409
|
+
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";
|
|
410
410
|
var getIvm = () => {
|
|
411
411
|
try {
|
|
412
412
|
if (IVM_INSTANCE)
|
|
@@ -506,24 +506,30 @@ function isNodeRuntime() {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
// src/functions/evaluate/should-force-browser-runtime-in-node.ts
|
|
509
|
-
var shouldForceBrowserRuntimeInNode = (
|
|
509
|
+
var shouldForceBrowserRuntimeInNode = ({
|
|
510
|
+
shouldLogWarning
|
|
511
|
+
}) => {
|
|
510
512
|
if (!isNodeRuntime())
|
|
511
513
|
return false;
|
|
512
514
|
const isArm64 = process.arch === "arm64";
|
|
513
515
|
const isNode20 = process.version.startsWith("v20");
|
|
514
516
|
const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
|
|
515
517
|
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
516
|
-
|
|
518
|
+
if (shouldLogWarning) {
|
|
519
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
517
520
|
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
518
521
|
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
519
522
|
`);
|
|
523
|
+
}
|
|
520
524
|
return true;
|
|
521
525
|
}
|
|
522
526
|
return false;
|
|
523
527
|
};
|
|
524
528
|
|
|
525
529
|
// src/functions/evaluate/choose-eval.ts
|
|
526
|
-
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode(
|
|
530
|
+
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode({
|
|
531
|
+
shouldLogWarning: true
|
|
532
|
+
}) ? runInBrowser(args) : runInNode(args);
|
|
527
533
|
|
|
528
534
|
// src/functions/evaluate/evaluate.ts
|
|
529
535
|
var DISABLE_CACHE = true;
|
|
@@ -1272,6 +1278,14 @@ function BlockWrapper(props) {
|
|
|
1272
1278
|
});
|
|
1273
1279
|
}
|
|
1274
1280
|
var block_wrapper_default = BlockWrapper;
|
|
1281
|
+
function Awaiter(props) {
|
|
1282
|
+
onMount(() => {
|
|
1283
|
+
});
|
|
1284
|
+
return memo(() => props.children);
|
|
1285
|
+
}
|
|
1286
|
+
var awaiter_default = Awaiter;
|
|
1287
|
+
|
|
1288
|
+
// src/components/block/components/interactive-element.tsx
|
|
1275
1289
|
function InteractiveElement(props) {
|
|
1276
1290
|
const attributes = createMemo(() => {
|
|
1277
1291
|
return props.includeBlockProps ? {
|
|
@@ -1288,17 +1302,43 @@ function InteractiveElement(props) {
|
|
|
1288
1302
|
})
|
|
1289
1303
|
} : {};
|
|
1290
1304
|
});
|
|
1291
|
-
return createComponent(
|
|
1292
|
-
get
|
|
1293
|
-
return
|
|
1305
|
+
return createComponent(Show, {
|
|
1306
|
+
get fallback() {
|
|
1307
|
+
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
1308
|
+
get attributes() {
|
|
1309
|
+
return attributes();
|
|
1310
|
+
},
|
|
1311
|
+
get component() {
|
|
1312
|
+
return props.Wrapper;
|
|
1313
|
+
},
|
|
1314
|
+
get children() {
|
|
1315
|
+
return props.children;
|
|
1316
|
+
}
|
|
1317
|
+
}));
|
|
1294
1318
|
},
|
|
1295
|
-
get
|
|
1296
|
-
return props.Wrapper;
|
|
1319
|
+
get when() {
|
|
1320
|
+
return props.Wrapper.load;
|
|
1297
1321
|
},
|
|
1298
1322
|
get children() {
|
|
1299
|
-
return
|
|
1323
|
+
return createComponent(awaiter_default, {
|
|
1324
|
+
get load() {
|
|
1325
|
+
return props.Wrapper.load;
|
|
1326
|
+
},
|
|
1327
|
+
get fallback() {
|
|
1328
|
+
return props.Wrapper.fallback;
|
|
1329
|
+
},
|
|
1330
|
+
get props() {
|
|
1331
|
+
return props.wrapperProps;
|
|
1332
|
+
},
|
|
1333
|
+
get attributes() {
|
|
1334
|
+
return attributes();
|
|
1335
|
+
},
|
|
1336
|
+
get children() {
|
|
1337
|
+
return props.children;
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1300
1340
|
}
|
|
1301
|
-
})
|
|
1341
|
+
});
|
|
1302
1342
|
}
|
|
1303
1343
|
var interactive_element_default = InteractiveElement;
|
|
1304
1344
|
|
|
@@ -1673,7 +1713,7 @@ function Block(props) {
|
|
|
1673
1713
|
});
|
|
1674
1714
|
}
|
|
1675
1715
|
var block_default = Block;
|
|
1676
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1716
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
|
|
1677
1717
|
display: flex;
|
|
1678
1718
|
flex-direction: column;
|
|
1679
1719
|
align-items: stretch;
|
|
@@ -1709,7 +1749,7 @@ function BlocksWrapper(props) {
|
|
|
1709
1749
|
});
|
|
1710
1750
|
return [createComponent(Dynamic, mergeProps({
|
|
1711
1751
|
get ["class"]() {
|
|
1712
|
-
return className() + " dynamic-
|
|
1752
|
+
return className() + " dynamic-68b2d7fe";
|
|
1713
1753
|
},
|
|
1714
1754
|
ref(r$) {
|
|
1715
1755
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1805,7 +1845,7 @@ var getColumnsClass = (id) => {
|
|
|
1805
1845
|
|
|
1806
1846
|
// src/blocks/columns/columns.tsx
|
|
1807
1847
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1808
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1848
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
|
|
1809
1849
|
display: flex;
|
|
1810
1850
|
line-height: normal;
|
|
1811
1851
|
}`);
|
|
@@ -1926,7 +1966,7 @@ function Columns(props) {
|
|
|
1926
1966
|
const _el$ = _tmpl$3();
|
|
1927
1967
|
spread(_el$, mergeProps({
|
|
1928
1968
|
get ["class"]() {
|
|
1929
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
1969
|
+
return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
|
|
1930
1970
|
},
|
|
1931
1971
|
get style() {
|
|
1932
1972
|
return columnsCssVars();
|
|
@@ -2051,16 +2091,16 @@ function getSrcSet(url) {
|
|
|
2051
2091
|
// src/blocks/image/image.tsx
|
|
2052
2092
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2053
2093
|
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-
|
|
2094
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
|
|
2095
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
|
|
2096
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
|
|
2057
2097
|
opacity: 1;
|
|
2058
2098
|
transition: opacity 0.2s ease-in-out;
|
|
2059
|
-
}.div-
|
|
2099
|
+
}.div-7e6ffddc {
|
|
2060
2100
|
width: 100%;
|
|
2061
2101
|
pointer-events: none;
|
|
2062
2102
|
font-size: 0;
|
|
2063
|
-
}.div-
|
|
2103
|
+
}.div-7e6ffddc-2 {
|
|
2064
2104
|
display: flex;
|
|
2065
2105
|
flex-direction: column;
|
|
2066
2106
|
align-items: stretch;
|
|
@@ -2125,7 +2165,7 @@ function Image(props) {
|
|
|
2125
2165
|
}
|
|
2126
2166
|
}), _el$3);
|
|
2127
2167
|
effect((_p$) => {
|
|
2128
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2168
|
+
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 = {
|
|
2129
2169
|
"object-position": props.backgroundPosition || "center",
|
|
2130
2170
|
"object-fit": props.backgroundSize || "cover",
|
|
2131
2171
|
...aspectRatioCss()
|
|
@@ -5415,7 +5455,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5415
5455
|
}
|
|
5416
5456
|
|
|
5417
5457
|
// src/constants/sdk-version.ts
|
|
5418
|
-
var SDK_VERSION = "2.0.
|
|
5458
|
+
var SDK_VERSION = "2.0.21";
|
|
5419
5459
|
|
|
5420
5460
|
// src/functions/register.ts
|
|
5421
5461
|
var registry = {};
|
|
@@ -5769,22 +5809,6 @@ function EnableEditor(props) {
|
|
|
5769
5809
|
}
|
|
5770
5810
|
})(event);
|
|
5771
5811
|
}
|
|
5772
|
-
function evaluateJsCode() {
|
|
5773
|
-
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
5774
|
-
if (jsCode) {
|
|
5775
|
-
evaluate({
|
|
5776
|
-
code: jsCode,
|
|
5777
|
-
context: props.context || {},
|
|
5778
|
-
localState: void 0,
|
|
5779
|
-
rootState: props.builderContextSignal.rootState,
|
|
5780
|
-
rootSetState: props.builderContextSignal.rootSetState,
|
|
5781
|
-
/**
|
|
5782
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5783
|
-
*/
|
|
5784
|
-
enableCache: false
|
|
5785
|
-
});
|
|
5786
|
-
}
|
|
5787
|
-
}
|
|
5788
5812
|
function onClick(event) {
|
|
5789
5813
|
if (props.builderContextSignal.content) {
|
|
5790
5814
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
@@ -5821,7 +5845,7 @@ function EnableEditor(props) {
|
|
|
5821
5845
|
rootSetState: props.builderContextSignal.rootSetState,
|
|
5822
5846
|
enableCache: true
|
|
5823
5847
|
})));
|
|
5824
|
-
|
|
5848
|
+
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5825
5849
|
mergeNewRootState({
|
|
5826
5850
|
[key]: json
|
|
5827
5851
|
});
|
|
@@ -5846,6 +5870,8 @@ function EnableEditor(props) {
|
|
|
5846
5870
|
}
|
|
5847
5871
|
}
|
|
5848
5872
|
let elementRef;
|
|
5873
|
+
runHttpRequests();
|
|
5874
|
+
emitStateUpdate();
|
|
5849
5875
|
onMount(() => {
|
|
5850
5876
|
if (isBrowser()) {
|
|
5851
5877
|
if (isEditing()) {
|
|
@@ -5900,14 +5926,6 @@ function EnableEditor(props) {
|
|
|
5900
5926
|
}
|
|
5901
5927
|
}
|
|
5902
5928
|
});
|
|
5903
|
-
onMount(() => {
|
|
5904
|
-
if (!props.apiKey) {
|
|
5905
|
-
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
5906
|
-
}
|
|
5907
|
-
evaluateJsCode();
|
|
5908
|
-
runHttpRequests();
|
|
5909
|
-
emitStateUpdate();
|
|
5910
|
-
});
|
|
5911
5929
|
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
5912
5930
|
function onUpdateFn_0() {
|
|
5913
5931
|
if (props.content) {
|
|
@@ -5915,37 +5933,27 @@ function EnableEditor(props) {
|
|
|
5915
5933
|
}
|
|
5916
5934
|
}
|
|
5917
5935
|
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
5918
|
-
const
|
|
5936
|
+
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5919
5937
|
function onUpdateFn_1() {
|
|
5920
|
-
evaluateJsCode();
|
|
5921
|
-
}
|
|
5922
|
-
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
|
|
5923
|
-
const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
5924
|
-
function onUpdateFn_2() {
|
|
5925
|
-
runHttpRequests();
|
|
5926
|
-
}
|
|
5927
|
-
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
|
|
5928
|
-
const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5929
|
-
function onUpdateFn_3() {
|
|
5930
5938
|
emitStateUpdate();
|
|
5931
5939
|
}
|
|
5932
|
-
createEffect(on(() => [
|
|
5933
|
-
const
|
|
5934
|
-
function
|
|
5940
|
+
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
|
|
5941
|
+
const onUpdateFn_2_props_data = createMemo(() => props.data);
|
|
5942
|
+
function onUpdateFn_2() {
|
|
5935
5943
|
if (props.data) {
|
|
5936
5944
|
mergeNewRootState(props.data);
|
|
5937
5945
|
}
|
|
5938
5946
|
}
|
|
5939
|
-
createEffect(on(() => [
|
|
5940
|
-
const
|
|
5941
|
-
function
|
|
5947
|
+
createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
5948
|
+
const onUpdateFn_3_props_locale = createMemo(() => props.locale);
|
|
5949
|
+
function onUpdateFn_3() {
|
|
5942
5950
|
if (props.locale) {
|
|
5943
5951
|
mergeNewRootState({
|
|
5944
5952
|
locale: props.locale
|
|
5945
5953
|
});
|
|
5946
5954
|
}
|
|
5947
5955
|
}
|
|
5948
|
-
createEffect(on(() => [
|
|
5956
|
+
createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
5949
5957
|
return createComponent(builder_context_default.Provider, {
|
|
5950
5958
|
get value() {
|
|
5951
5959
|
return props.builderContextSignal;
|
|
@@ -6113,6 +6121,29 @@ function ContentComponent(props) {
|
|
|
6113
6121
|
rootState: newRootState
|
|
6114
6122
|
}));
|
|
6115
6123
|
}
|
|
6124
|
+
if (!props.apiKey) {
|
|
6125
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
6126
|
+
}
|
|
6127
|
+
const jsCode = builderContextSignal().content?.data?.jsCode;
|
|
6128
|
+
if (jsCode) {
|
|
6129
|
+
evaluate({
|
|
6130
|
+
code: jsCode,
|
|
6131
|
+
context: props.context || {},
|
|
6132
|
+
localState: void 0,
|
|
6133
|
+
rootState: builderContextSignal().rootState,
|
|
6134
|
+
rootSetState: (newState) => {
|
|
6135
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
6136
|
+
...PREVIOUS_VALUE,
|
|
6137
|
+
rootState: newState
|
|
6138
|
+
}));
|
|
6139
|
+
},
|
|
6140
|
+
isExpression: false,
|
|
6141
|
+
/**
|
|
6142
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
6143
|
+
*/
|
|
6144
|
+
enableCache: false
|
|
6145
|
+
});
|
|
6146
|
+
}
|
|
6116
6147
|
return createComponent(components_context_default.Provider, {
|
|
6117
6148
|
get value() {
|
|
6118
6149
|
return {
|