@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/dist/index.d.ts
CHANGED
|
@@ -480,6 +480,11 @@ interface ComponentInfo {
|
|
|
480
480
|
}
|
|
481
481
|
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* To be overriden to the correct `Component` type for each framework.
|
|
485
|
+
*/
|
|
486
|
+
type ComponentReference = any;
|
|
487
|
+
|
|
483
488
|
/**
|
|
484
489
|
* no-op type for extra context types on a per-SDK basis
|
|
485
490
|
* See `overrides/react-native/src/context/extra-context-types.ts` for an example
|
|
@@ -488,7 +493,7 @@ interface ExtraContextTypes {
|
|
|
488
493
|
}
|
|
489
494
|
|
|
490
495
|
type RegisteredComponent = ComponentInfo & {
|
|
491
|
-
component:
|
|
496
|
+
component: ComponentReference;
|
|
492
497
|
};
|
|
493
498
|
type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
494
499
|
type BuilderRenderState = Record<string, unknown>;
|
package/lib/browser/dev.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/helpers/nullable.ts
|
|
318
318
|
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
319
319
|
|
|
@@ -323,24 +323,30 @@ function isNodeRuntime() {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
// src/functions/evaluate/should-force-browser-runtime-in-node.ts
|
|
326
|
-
var shouldForceBrowserRuntimeInNode = (
|
|
326
|
+
var shouldForceBrowserRuntimeInNode = ({
|
|
327
|
+
shouldLogWarning
|
|
328
|
+
}) => {
|
|
327
329
|
if (!isNodeRuntime())
|
|
328
330
|
return false;
|
|
329
331
|
const isArm64 = process.arch === "arm64";
|
|
330
332
|
const isNode20 = process.version.startsWith("v20");
|
|
331
333
|
const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
|
|
332
334
|
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
333
|
-
|
|
335
|
+
if (shouldLogWarning) {
|
|
336
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
334
337
|
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.
|
|
335
338
|
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
336
339
|
`);
|
|
340
|
+
}
|
|
337
341
|
return true;
|
|
338
342
|
}
|
|
339
343
|
return false;
|
|
340
344
|
};
|
|
341
345
|
|
|
342
346
|
// src/functions/evaluate/choose-eval.ts
|
|
343
|
-
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode(
|
|
347
|
+
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode({
|
|
348
|
+
shouldLogWarning: true
|
|
349
|
+
}) ? runInBrowser(args) : runInBrowser(args);
|
|
344
350
|
|
|
345
351
|
// src/functions/evaluate/evaluate.ts
|
|
346
352
|
var DISABLE_CACHE = true;
|
|
@@ -1102,6 +1108,14 @@ function BlockWrapper(props) {
|
|
|
1102
1108
|
});
|
|
1103
1109
|
}
|
|
1104
1110
|
var block_wrapper_default = BlockWrapper;
|
|
1111
|
+
function Awaiter(props) {
|
|
1112
|
+
onMount(() => {
|
|
1113
|
+
});
|
|
1114
|
+
return memo(() => props.children);
|
|
1115
|
+
}
|
|
1116
|
+
var awaiter_default = Awaiter;
|
|
1117
|
+
|
|
1118
|
+
// src/components/block/components/interactive-element.tsx
|
|
1105
1119
|
function InteractiveElement(props) {
|
|
1106
1120
|
const attributes = createMemo(() => {
|
|
1107
1121
|
return props.includeBlockProps ? {
|
|
@@ -1118,17 +1132,43 @@ function InteractiveElement(props) {
|
|
|
1118
1132
|
})
|
|
1119
1133
|
} : {};
|
|
1120
1134
|
});
|
|
1121
|
-
return createComponent(
|
|
1122
|
-
get
|
|
1123
|
-
return
|
|
1135
|
+
return createComponent(Show, {
|
|
1136
|
+
get fallback() {
|
|
1137
|
+
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
1138
|
+
get attributes() {
|
|
1139
|
+
return attributes();
|
|
1140
|
+
},
|
|
1141
|
+
get component() {
|
|
1142
|
+
return props.Wrapper;
|
|
1143
|
+
},
|
|
1144
|
+
get children() {
|
|
1145
|
+
return props.children;
|
|
1146
|
+
}
|
|
1147
|
+
}));
|
|
1124
1148
|
},
|
|
1125
|
-
get
|
|
1126
|
-
return props.Wrapper;
|
|
1149
|
+
get when() {
|
|
1150
|
+
return props.Wrapper.load;
|
|
1127
1151
|
},
|
|
1128
1152
|
get children() {
|
|
1129
|
-
return
|
|
1153
|
+
return createComponent(awaiter_default, {
|
|
1154
|
+
get load() {
|
|
1155
|
+
return props.Wrapper.load;
|
|
1156
|
+
},
|
|
1157
|
+
get fallback() {
|
|
1158
|
+
return props.Wrapper.fallback;
|
|
1159
|
+
},
|
|
1160
|
+
get props() {
|
|
1161
|
+
return props.wrapperProps;
|
|
1162
|
+
},
|
|
1163
|
+
get attributes() {
|
|
1164
|
+
return attributes();
|
|
1165
|
+
},
|
|
1166
|
+
get children() {
|
|
1167
|
+
return props.children;
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1130
1170
|
}
|
|
1131
|
-
})
|
|
1171
|
+
});
|
|
1132
1172
|
}
|
|
1133
1173
|
var interactive_element_default = InteractiveElement;
|
|
1134
1174
|
|
|
@@ -1503,7 +1543,7 @@ function Block(props) {
|
|
|
1503
1543
|
});
|
|
1504
1544
|
}
|
|
1505
1545
|
var block_default = Block;
|
|
1506
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1546
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
|
|
1507
1547
|
display: flex;
|
|
1508
1548
|
flex-direction: column;
|
|
1509
1549
|
align-items: stretch;
|
|
@@ -1539,7 +1579,7 @@ function BlocksWrapper(props) {
|
|
|
1539
1579
|
});
|
|
1540
1580
|
return [createComponent(Dynamic, mergeProps({
|
|
1541
1581
|
get ["class"]() {
|
|
1542
|
-
return className() + " dynamic-
|
|
1582
|
+
return className() + " dynamic-68b2d7fe";
|
|
1543
1583
|
},
|
|
1544
1584
|
ref(r$) {
|
|
1545
1585
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1635,7 +1675,7 @@ var getColumnsClass = (id) => {
|
|
|
1635
1675
|
|
|
1636
1676
|
// src/blocks/columns/columns.tsx
|
|
1637
1677
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1638
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1678
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
|
|
1639
1679
|
display: flex;
|
|
1640
1680
|
line-height: normal;
|
|
1641
1681
|
}`);
|
|
@@ -1756,7 +1796,7 @@ function Columns(props) {
|
|
|
1756
1796
|
const _el$ = _tmpl$3();
|
|
1757
1797
|
spread(_el$, mergeProps({
|
|
1758
1798
|
get ["class"]() {
|
|
1759
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
1799
|
+
return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
|
|
1760
1800
|
},
|
|
1761
1801
|
get style() {
|
|
1762
1802
|
return columnsCssVars();
|
|
@@ -1881,16 +1921,16 @@ function getSrcSet(url) {
|
|
|
1881
1921
|
// src/blocks/image/image.tsx
|
|
1882
1922
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
1883
1923
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
1884
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
1885
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
1886
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
1924
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
|
|
1925
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
|
|
1926
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
|
|
1887
1927
|
opacity: 1;
|
|
1888
1928
|
transition: opacity 0.2s ease-in-out;
|
|
1889
|
-
}.div-
|
|
1929
|
+
}.div-7e6ffddc {
|
|
1890
1930
|
width: 100%;
|
|
1891
1931
|
pointer-events: none;
|
|
1892
1932
|
font-size: 0;
|
|
1893
|
-
}.div-
|
|
1933
|
+
}.div-7e6ffddc-2 {
|
|
1894
1934
|
display: flex;
|
|
1895
1935
|
flex-direction: column;
|
|
1896
1936
|
align-items: stretch;
|
|
@@ -1955,7 +1995,7 @@ function Image(props) {
|
|
|
1955
1995
|
}
|
|
1956
1996
|
}), _el$3);
|
|
1957
1997
|
effect((_p$) => {
|
|
1958
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
1998
|
+
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 = {
|
|
1959
1999
|
"object-position": props.backgroundPosition || "center",
|
|
1960
2000
|
"object-fit": props.backgroundSize || "cover",
|
|
1961
2001
|
...aspectRatioCss()
|
|
@@ -5245,7 +5285,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5245
5285
|
}
|
|
5246
5286
|
|
|
5247
5287
|
// src/constants/sdk-version.ts
|
|
5248
|
-
var SDK_VERSION = "2.0.
|
|
5288
|
+
var SDK_VERSION = "2.0.21";
|
|
5249
5289
|
|
|
5250
5290
|
// src/functions/register.ts
|
|
5251
5291
|
var registry = {};
|
|
@@ -5599,22 +5639,6 @@ function EnableEditor(props) {
|
|
|
5599
5639
|
}
|
|
5600
5640
|
})(event);
|
|
5601
5641
|
}
|
|
5602
|
-
function evaluateJsCode() {
|
|
5603
|
-
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
5604
|
-
if (jsCode) {
|
|
5605
|
-
evaluate({
|
|
5606
|
-
code: jsCode,
|
|
5607
|
-
context: props.context || {},
|
|
5608
|
-
localState: void 0,
|
|
5609
|
-
rootState: props.builderContextSignal.rootState,
|
|
5610
|
-
rootSetState: props.builderContextSignal.rootSetState,
|
|
5611
|
-
/**
|
|
5612
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5613
|
-
*/
|
|
5614
|
-
enableCache: false
|
|
5615
|
-
});
|
|
5616
|
-
}
|
|
5617
|
-
}
|
|
5618
5642
|
function onClick(event) {
|
|
5619
5643
|
if (props.builderContextSignal.content) {
|
|
5620
5644
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
@@ -5651,7 +5675,7 @@ function EnableEditor(props) {
|
|
|
5651
5675
|
rootSetState: props.builderContextSignal.rootSetState,
|
|
5652
5676
|
enableCache: true
|
|
5653
5677
|
})));
|
|
5654
|
-
|
|
5678
|
+
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5655
5679
|
mergeNewRootState({
|
|
5656
5680
|
[key]: json
|
|
5657
5681
|
});
|
|
@@ -5676,6 +5700,8 @@ function EnableEditor(props) {
|
|
|
5676
5700
|
}
|
|
5677
5701
|
}
|
|
5678
5702
|
let elementRef;
|
|
5703
|
+
runHttpRequests();
|
|
5704
|
+
emitStateUpdate();
|
|
5679
5705
|
onMount(() => {
|
|
5680
5706
|
if (isBrowser()) {
|
|
5681
5707
|
if (isEditing()) {
|
|
@@ -5730,14 +5756,6 @@ function EnableEditor(props) {
|
|
|
5730
5756
|
}
|
|
5731
5757
|
}
|
|
5732
5758
|
});
|
|
5733
|
-
onMount(() => {
|
|
5734
|
-
if (!props.apiKey) {
|
|
5735
|
-
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
5736
|
-
}
|
|
5737
|
-
evaluateJsCode();
|
|
5738
|
-
runHttpRequests();
|
|
5739
|
-
emitStateUpdate();
|
|
5740
|
-
});
|
|
5741
5759
|
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
5742
5760
|
function onUpdateFn_0() {
|
|
5743
5761
|
if (props.content) {
|
|
@@ -5745,37 +5763,27 @@ function EnableEditor(props) {
|
|
|
5745
5763
|
}
|
|
5746
5764
|
}
|
|
5747
5765
|
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
5748
|
-
const
|
|
5766
|
+
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5749
5767
|
function onUpdateFn_1() {
|
|
5750
|
-
evaluateJsCode();
|
|
5751
|
-
}
|
|
5752
|
-
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
|
|
5753
|
-
const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
5754
|
-
function onUpdateFn_2() {
|
|
5755
|
-
runHttpRequests();
|
|
5756
|
-
}
|
|
5757
|
-
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
|
|
5758
|
-
const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
5759
|
-
function onUpdateFn_3() {
|
|
5760
5768
|
emitStateUpdate();
|
|
5761
5769
|
}
|
|
5762
|
-
createEffect(on(() => [
|
|
5763
|
-
const
|
|
5764
|
-
function
|
|
5770
|
+
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
|
|
5771
|
+
const onUpdateFn_2_props_data = createMemo(() => props.data);
|
|
5772
|
+
function onUpdateFn_2() {
|
|
5765
5773
|
if (props.data) {
|
|
5766
5774
|
mergeNewRootState(props.data);
|
|
5767
5775
|
}
|
|
5768
5776
|
}
|
|
5769
|
-
createEffect(on(() => [
|
|
5770
|
-
const
|
|
5771
|
-
function
|
|
5777
|
+
createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
5778
|
+
const onUpdateFn_3_props_locale = createMemo(() => props.locale);
|
|
5779
|
+
function onUpdateFn_3() {
|
|
5772
5780
|
if (props.locale) {
|
|
5773
5781
|
mergeNewRootState({
|
|
5774
5782
|
locale: props.locale
|
|
5775
5783
|
});
|
|
5776
5784
|
}
|
|
5777
5785
|
}
|
|
5778
|
-
createEffect(on(() => [
|
|
5786
|
+
createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
5779
5787
|
return createComponent(builder_context_default.Provider, {
|
|
5780
5788
|
get value() {
|
|
5781
5789
|
return props.builderContextSignal;
|
|
@@ -5943,6 +5951,29 @@ function ContentComponent(props) {
|
|
|
5943
5951
|
rootState: newRootState
|
|
5944
5952
|
}));
|
|
5945
5953
|
}
|
|
5954
|
+
if (!props.apiKey) {
|
|
5955
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
5956
|
+
}
|
|
5957
|
+
const jsCode = builderContextSignal().content?.data?.jsCode;
|
|
5958
|
+
if (jsCode) {
|
|
5959
|
+
evaluate({
|
|
5960
|
+
code: jsCode,
|
|
5961
|
+
context: props.context || {},
|
|
5962
|
+
localState: void 0,
|
|
5963
|
+
rootState: builderContextSignal().rootState,
|
|
5964
|
+
rootSetState: (newState) => {
|
|
5965
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
5966
|
+
...PREVIOUS_VALUE,
|
|
5967
|
+
rootState: newState
|
|
5968
|
+
}));
|
|
5969
|
+
},
|
|
5970
|
+
isExpression: false,
|
|
5971
|
+
/**
|
|
5972
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5973
|
+
*/
|
|
5974
|
+
enableCache: false
|
|
5975
|
+
});
|
|
5976
|
+
}
|
|
5946
5977
|
return createComponent(components_context_default.Provider, {
|
|
5947
5978
|
get value() {
|
|
5948
5979
|
return {
|