@builder.io/sdk-solid 0.14.6 → 1.0.13
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 +1 -1
- package/lib/browser/dev.js +217 -149
- package/lib/browser/dev.jsx +276 -187
- package/lib/browser/index.js +217 -149
- package/lib/browser/index.jsx +276 -187
- package/lib/edge/dev.js +217 -149
- package/lib/edge/dev.jsx +276 -187
- package/lib/edge/index.js +217 -149
- package/lib/edge/index.jsx +276 -187
- package/lib/node/dev.js +217 -149
- package/lib/node/dev.jsx +276 -187
- package/lib/node/index.js +217 -149
- package/lib/node/index.jsx +276 -187
- package/package.json +1 -1
package/lib/browser/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, Dynamic, memo, use } from 'solid-js/web';
|
|
2
|
-
import { createContext, useContext, Show, For, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
2
|
+
import { createContext, useContext, Show, For, createSignal, createMemo, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
import { css } from 'solid-styled-components';
|
|
4
4
|
|
|
5
5
|
// src/blocks/button/button.tsx
|
|
@@ -281,7 +281,7 @@ function flattenState({
|
|
|
281
281
|
return localState[prop];
|
|
282
282
|
}
|
|
283
283
|
const val = target[prop];
|
|
284
|
-
if (typeof val === "object") {
|
|
284
|
+
if (typeof val === "object" && val !== null) {
|
|
285
285
|
return flattenState({
|
|
286
286
|
rootState: val,
|
|
287
287
|
localState: void 0,
|
|
@@ -333,6 +333,30 @@ var shouldForceBrowserRuntimeInNode = () => {
|
|
|
333
333
|
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
|
|
334
334
|
|
|
335
335
|
// src/functions/evaluate/evaluate.ts
|
|
336
|
+
var EvalCache = class _EvalCache {
|
|
337
|
+
static cacheLimit = 20;
|
|
338
|
+
static cache = /* @__PURE__ */ new Map();
|
|
339
|
+
static getCacheKey(args) {
|
|
340
|
+
return JSON.stringify({
|
|
341
|
+
...args,
|
|
342
|
+
// replace the event with a random number to break cache
|
|
343
|
+
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
344
|
+
event: args.event ? Math.random() : void 0
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
static getCachedValue(key) {
|
|
348
|
+
const cachedVal = _EvalCache.cache.get(key);
|
|
349
|
+
return cachedVal;
|
|
350
|
+
}
|
|
351
|
+
static setCachedValue(key, value) {
|
|
352
|
+
if (_EvalCache.cache.size > 20) {
|
|
353
|
+
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
354
|
+
}
|
|
355
|
+
_EvalCache.cache.set(key, {
|
|
356
|
+
value
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
};
|
|
336
360
|
function evaluate({
|
|
337
361
|
code,
|
|
338
362
|
context,
|
|
@@ -340,11 +364,12 @@ function evaluate({
|
|
|
340
364
|
rootState,
|
|
341
365
|
rootSetState,
|
|
342
366
|
event,
|
|
343
|
-
isExpression = true
|
|
367
|
+
isExpression = true,
|
|
368
|
+
enableCache
|
|
344
369
|
}) {
|
|
345
370
|
if (code === "") {
|
|
346
371
|
logger.warn("Skipping evaluation of empty code block.");
|
|
347
|
-
return;
|
|
372
|
+
return void 0;
|
|
348
373
|
}
|
|
349
374
|
const args = {
|
|
350
375
|
code: parseCode(code, {
|
|
@@ -357,8 +382,20 @@ function evaluate({
|
|
|
357
382
|
rootState,
|
|
358
383
|
localState
|
|
359
384
|
};
|
|
385
|
+
if (enableCache) {
|
|
386
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
387
|
+
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
388
|
+
if (cachedValue) {
|
|
389
|
+
return cachedValue.value;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
360
392
|
try {
|
|
361
|
-
|
|
393
|
+
const newEval = chooseBrowserOrServerEval(args);
|
|
394
|
+
if (enableCache) {
|
|
395
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
396
|
+
EvalCache.setCachedValue(cacheKey, newEval);
|
|
397
|
+
}
|
|
398
|
+
return newEval;
|
|
362
399
|
} catch (e) {
|
|
363
400
|
logger.error("Failed code evaluation: " + e.message, {
|
|
364
401
|
code
|
|
@@ -413,7 +450,8 @@ var evaluateBindings = ({
|
|
|
413
450
|
localState,
|
|
414
451
|
rootState,
|
|
415
452
|
rootSetState,
|
|
416
|
-
context
|
|
453
|
+
context,
|
|
454
|
+
enableCache: true
|
|
417
455
|
});
|
|
418
456
|
set(copied, binding, value);
|
|
419
457
|
}
|
|
@@ -647,6 +685,70 @@ function bindScrollInViewAnimation(animation) {
|
|
|
647
685
|
});
|
|
648
686
|
}
|
|
649
687
|
|
|
688
|
+
// src/functions/camel-to-kebab-case.ts
|
|
689
|
+
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
690
|
+
|
|
691
|
+
// src/helpers/css.ts
|
|
692
|
+
var convertStyleMapToCSSArray = (style) => {
|
|
693
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
694
|
+
if (typeof value === "string") {
|
|
695
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
696
|
+
} else {
|
|
697
|
+
return void 0;
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
return cssProps.filter(checkIsDefined);
|
|
701
|
+
};
|
|
702
|
+
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
703
|
+
var createCssClass = ({
|
|
704
|
+
mediaQuery,
|
|
705
|
+
className,
|
|
706
|
+
styles
|
|
707
|
+
}) => {
|
|
708
|
+
const cssClass = `.${className} {
|
|
709
|
+
${convertStyleMapToCSS(styles)}
|
|
710
|
+
}`;
|
|
711
|
+
if (mediaQuery) {
|
|
712
|
+
return `${mediaQuery} {
|
|
713
|
+
${cssClass}
|
|
714
|
+
}`;
|
|
715
|
+
} else {
|
|
716
|
+
return cssClass;
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
// src/functions/transform-style-property.ts
|
|
721
|
+
function transformStyleProperty({
|
|
722
|
+
style
|
|
723
|
+
}) {
|
|
724
|
+
return style;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/functions/get-style.ts
|
|
728
|
+
var getStyle = ({
|
|
729
|
+
block,
|
|
730
|
+
context
|
|
731
|
+
}) => {
|
|
732
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
733
|
+
style: block.style || {},
|
|
734
|
+
context,
|
|
735
|
+
block
|
|
736
|
+
}));
|
|
737
|
+
};
|
|
738
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
739
|
+
switch (TARGET) {
|
|
740
|
+
case "svelte":
|
|
741
|
+
case "vue":
|
|
742
|
+
case "solid":
|
|
743
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
744
|
+
case "qwik":
|
|
745
|
+
case "reactNative":
|
|
746
|
+
case "react":
|
|
747
|
+
case "rsc":
|
|
748
|
+
return style;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
650
752
|
// src/components/block/block.helpers.ts
|
|
651
753
|
var getComponent = ({
|
|
652
754
|
block,
|
|
@@ -690,7 +792,8 @@ var getRepeatItemData = ({
|
|
|
690
792
|
localState: context.localState,
|
|
691
793
|
rootState: context.rootState,
|
|
692
794
|
rootSetState: context.rootSetState,
|
|
693
|
-
context: context.context
|
|
795
|
+
context: context.context,
|
|
796
|
+
enableCache: true
|
|
694
797
|
});
|
|
695
798
|
if (!Array.isArray(itemsArray)) {
|
|
696
799
|
return void 0;
|
|
@@ -761,38 +864,6 @@ var getSizesForBreakpoints = ({
|
|
|
761
864
|
};
|
|
762
865
|
return newSizes;
|
|
763
866
|
};
|
|
764
|
-
|
|
765
|
-
// src/functions/camel-to-kebab-case.ts
|
|
766
|
-
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
767
|
-
|
|
768
|
-
// src/helpers/css.ts
|
|
769
|
-
var convertStyleMapToCSSArray = (style) => {
|
|
770
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
771
|
-
if (typeof value === "string") {
|
|
772
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
773
|
-
} else {
|
|
774
|
-
return void 0;
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
return cssProps.filter(checkIsDefined);
|
|
778
|
-
};
|
|
779
|
-
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
780
|
-
var createCssClass = ({
|
|
781
|
-
mediaQuery,
|
|
782
|
-
className,
|
|
783
|
-
styles
|
|
784
|
-
}) => {
|
|
785
|
-
const cssClass = `.${className} {
|
|
786
|
-
${convertStyleMapToCSS(styles)}
|
|
787
|
-
}`;
|
|
788
|
-
if (mediaQuery) {
|
|
789
|
-
return `${mediaQuery} {
|
|
790
|
-
${cssClass}
|
|
791
|
-
}`;
|
|
792
|
-
} else {
|
|
793
|
-
return cssClass;
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
867
|
var _tmpl$ = /* @__PURE__ */ template(`<style>`);
|
|
797
868
|
function InlinedStyles(props) {
|
|
798
869
|
return (() => {
|
|
@@ -813,7 +884,7 @@ var inlined_styles_default = InlinedStyles;
|
|
|
813
884
|
|
|
814
885
|
// src/components/block/components/block-styles.tsx
|
|
815
886
|
function BlockStyles(props) {
|
|
816
|
-
|
|
887
|
+
const canShowBlock = createMemo(() => {
|
|
817
888
|
const processedBlock = getProcessedBlock({
|
|
818
889
|
block: props.block,
|
|
819
890
|
localState: props.context.localState,
|
|
@@ -829,8 +900,8 @@ function BlockStyles(props) {
|
|
|
829
900
|
return processedBlock.show;
|
|
830
901
|
}
|
|
831
902
|
return true;
|
|
832
|
-
}
|
|
833
|
-
|
|
903
|
+
});
|
|
904
|
+
const css5 = createMemo(() => {
|
|
834
905
|
const processedBlock = getProcessedBlock({
|
|
835
906
|
block: props.block,
|
|
836
907
|
localState: props.context.localState,
|
|
@@ -864,7 +935,7 @@ function BlockStyles(props) {
|
|
|
864
935
|
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
|
|
865
936
|
}) : "";
|
|
866
937
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
867
|
-
}
|
|
938
|
+
});
|
|
868
939
|
return createComponent(Show, {
|
|
869
940
|
get when() {
|
|
870
941
|
return memo(() => !!(TARGET !== "reactNative" && css5()))() && canShowBlock();
|
|
@@ -894,7 +965,8 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
894
965
|
rootState: options.rootState,
|
|
895
966
|
rootSetState: options.rootSetState,
|
|
896
967
|
event,
|
|
897
|
-
isExpression: false
|
|
968
|
+
isExpression: false,
|
|
969
|
+
enableCache: true
|
|
898
970
|
});
|
|
899
971
|
|
|
900
972
|
// src/functions/get-block-actions.ts
|
|
@@ -922,38 +994,6 @@ function getBlockActions(options) {
|
|
|
922
994
|
return obj;
|
|
923
995
|
}
|
|
924
996
|
|
|
925
|
-
// src/functions/transform-style-property.ts
|
|
926
|
-
function transformStyleProperty({
|
|
927
|
-
style
|
|
928
|
-
}) {
|
|
929
|
-
return style;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
// src/functions/get-style.ts
|
|
933
|
-
var getStyle = ({
|
|
934
|
-
block,
|
|
935
|
-
context
|
|
936
|
-
}) => {
|
|
937
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
938
|
-
style: block.style || {},
|
|
939
|
-
context,
|
|
940
|
-
block
|
|
941
|
-
}));
|
|
942
|
-
};
|
|
943
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
944
|
-
switch (TARGET) {
|
|
945
|
-
case "svelte":
|
|
946
|
-
case "vue":
|
|
947
|
-
case "solid":
|
|
948
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
949
|
-
case "qwik":
|
|
950
|
-
case "reactNative":
|
|
951
|
-
case "react":
|
|
952
|
-
case "rsc":
|
|
953
|
-
return style;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
997
|
// src/functions/transform-block-properties.ts
|
|
958
998
|
function transformBlockProperties({
|
|
959
999
|
properties
|
|
@@ -1155,21 +1195,20 @@ var repeated_block_default = RepeatedBlock;
|
|
|
1155
1195
|
|
|
1156
1196
|
// src/components/block/block.tsx
|
|
1157
1197
|
function Block(props) {
|
|
1158
|
-
const
|
|
1159
|
-
function blockComponent() {
|
|
1198
|
+
const blockComponent = createMemo(() => {
|
|
1160
1199
|
return getComponent({
|
|
1161
1200
|
block: props.block,
|
|
1162
1201
|
context: props.context,
|
|
1163
1202
|
registeredComponents: props.registeredComponents
|
|
1164
1203
|
});
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1204
|
+
});
|
|
1205
|
+
const repeatItem = createMemo(() => {
|
|
1167
1206
|
return getRepeatItemData({
|
|
1168
1207
|
block: props.block,
|
|
1169
1208
|
context: props.context
|
|
1170
1209
|
});
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1210
|
+
});
|
|
1211
|
+
const processedBlock = createMemo(() => {
|
|
1173
1212
|
return props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
1174
1213
|
block: props.block,
|
|
1175
1214
|
localState: props.context.localState,
|
|
@@ -1178,15 +1217,15 @@ function Block(props) {
|
|
|
1178
1217
|
context: props.context.context,
|
|
1179
1218
|
shouldEvaluateBindings: true
|
|
1180
1219
|
});
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1220
|
+
});
|
|
1221
|
+
const Tag = createMemo(() => {
|
|
1183
1222
|
const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
|
|
1184
1223
|
if (shouldUseLink) {
|
|
1185
1224
|
return props.linkComponent || "a";
|
|
1186
1225
|
}
|
|
1187
1226
|
return props.block.tagName || "div";
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1227
|
+
});
|
|
1228
|
+
const canShowBlock = createMemo(() => {
|
|
1190
1229
|
if (props.block.repeat?.collection) {
|
|
1191
1230
|
if (repeatItem()?.length)
|
|
1192
1231
|
return true;
|
|
@@ -1195,12 +1234,12 @@ function Block(props) {
|
|
|
1195
1234
|
const shouldHide = "hide" in processedBlock() ? processedBlock().hide : false;
|
|
1196
1235
|
const shouldShow = "show" in processedBlock() ? processedBlock().show : true;
|
|
1197
1236
|
return shouldShow && !shouldHide;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1237
|
+
});
|
|
1238
|
+
const childrenWithoutParentComponent = createMemo(() => {
|
|
1200
1239
|
const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
|
|
1201
1240
|
return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1241
|
+
});
|
|
1242
|
+
const componentRefProps = createMemo(() => {
|
|
1204
1243
|
return {
|
|
1205
1244
|
blockChildren: processedBlock().children ?? [],
|
|
1206
1245
|
componentRef: blockComponent()?.component,
|
|
@@ -1214,14 +1253,14 @@ function Block(props) {
|
|
|
1214
1253
|
builderComponents: props.registeredComponents
|
|
1215
1254
|
} : {}
|
|
1216
1255
|
},
|
|
1217
|
-
context:
|
|
1256
|
+
context: props.context,
|
|
1218
1257
|
linkComponent: props.linkComponent,
|
|
1219
1258
|
registeredComponents: props.registeredComponents,
|
|
1220
1259
|
builderBlock: processedBlock(),
|
|
1221
1260
|
includeBlockProps: blockComponent()?.noWrap === true,
|
|
1222
1261
|
isInteractive: !blockComponent()?.isRSC
|
|
1223
1262
|
};
|
|
1224
|
-
}
|
|
1263
|
+
});
|
|
1225
1264
|
onMount(() => {
|
|
1226
1265
|
const blockId = processedBlock().id;
|
|
1227
1266
|
const animations = processedBlock().animations;
|
|
@@ -1363,14 +1402,14 @@ function Block(props) {
|
|
|
1363
1402
|
return child.id;
|
|
1364
1403
|
},
|
|
1365
1404
|
block: child,
|
|
1366
|
-
get context() {
|
|
1367
|
-
return childrenContext();
|
|
1368
|
-
},
|
|
1369
1405
|
get registeredComponents() {
|
|
1370
1406
|
return props.registeredComponents;
|
|
1371
1407
|
},
|
|
1372
1408
|
get linkComponent() {
|
|
1373
1409
|
return props.linkComponent;
|
|
1410
|
+
},
|
|
1411
|
+
get context() {
|
|
1412
|
+
return props.context;
|
|
1374
1413
|
}
|
|
1375
1414
|
});
|
|
1376
1415
|
}
|
|
@@ -1386,9 +1425,9 @@ function Block(props) {
|
|
|
1386
1425
|
}
|
|
1387
1426
|
var block_default = Block;
|
|
1388
1427
|
function BlocksWrapper(props) {
|
|
1389
|
-
|
|
1428
|
+
const className = createMemo(() => {
|
|
1390
1429
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
1391
|
-
}
|
|
1430
|
+
});
|
|
1392
1431
|
function onClick() {
|
|
1393
1432
|
if (isEditing() && !props.blocks?.length) {
|
|
1394
1433
|
window.parent?.postMessage({
|
|
@@ -1528,7 +1567,7 @@ function Columns(props) {
|
|
|
1528
1567
|
}) {
|
|
1529
1568
|
return stackAt() === "never" ? desktopStyle : stackedStyle;
|
|
1530
1569
|
}
|
|
1531
|
-
|
|
1570
|
+
const columnsCssVars = createMemo(() => {
|
|
1532
1571
|
return {
|
|
1533
1572
|
"--flex-dir": flexDir(),
|
|
1534
1573
|
"--flex-dir-tablet": getTabletStyle({
|
|
@@ -1536,7 +1575,7 @@ function Columns(props) {
|
|
|
1536
1575
|
desktopStyle: "row"
|
|
1537
1576
|
})
|
|
1538
1577
|
};
|
|
1539
|
-
}
|
|
1578
|
+
});
|
|
1540
1579
|
function columnCssVars(index) {
|
|
1541
1580
|
const gutter = index === 0 ? 0 : gutterSize();
|
|
1542
1581
|
const width = getColumnCssWidth(index);
|
|
@@ -1575,7 +1614,7 @@ function Columns(props) {
|
|
|
1575
1614
|
const breakpointSizes = getSizesForBreakpoints(props.builderContext.content?.meta?.breakpoints || {});
|
|
1576
1615
|
return breakpointSizes[size].max;
|
|
1577
1616
|
}
|
|
1578
|
-
|
|
1617
|
+
const columnsStyles = createMemo(() => {
|
|
1579
1618
|
return `
|
|
1580
1619
|
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
1581
1620
|
.${props.builderBlock.id}-breakpoints {
|
|
@@ -1601,7 +1640,7 @@ function Columns(props) {
|
|
|
1601
1640
|
}
|
|
1602
1641
|
},
|
|
1603
1642
|
`;
|
|
1604
|
-
}
|
|
1643
|
+
});
|
|
1605
1644
|
return (() => {
|
|
1606
1645
|
const _el$ = _tmpl$2();
|
|
1607
1646
|
spread(_el$, mergeProps({
|
|
@@ -1739,7 +1778,7 @@ var _tmpl$4 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
|
1739
1778
|
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
|
|
1740
1779
|
var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
|
|
1741
1780
|
function Image(props) {
|
|
1742
|
-
|
|
1781
|
+
const srcSetToUse = createMemo(() => {
|
|
1743
1782
|
const imageToUse = props.image || props.src;
|
|
1744
1783
|
const url = imageToUse;
|
|
1745
1784
|
if (!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
@@ -1756,15 +1795,15 @@ function Image(props) {
|
|
|
1756
1795
|
return getSrcSet(url);
|
|
1757
1796
|
}
|
|
1758
1797
|
return getSrcSet(url);
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1798
|
+
});
|
|
1799
|
+
const webpSrcSet = createMemo(() => {
|
|
1761
1800
|
if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
|
|
1762
1801
|
return srcSetToUse().replace(/\?/g, "?format=webp&");
|
|
1763
1802
|
} else {
|
|
1764
1803
|
return "";
|
|
1765
1804
|
}
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1805
|
+
});
|
|
1806
|
+
const aspectRatioCss = createMemo(() => {
|
|
1768
1807
|
const aspectRatioStyles = {
|
|
1769
1808
|
position: "absolute",
|
|
1770
1809
|
height: "100%",
|
|
@@ -1774,7 +1813,7 @@ function Image(props) {
|
|
|
1774
1813
|
};
|
|
1775
1814
|
const out = props.aspectRatio ? aspectRatioStyles : void 0;
|
|
1776
1815
|
return out;
|
|
1777
|
-
}
|
|
1816
|
+
});
|
|
1778
1817
|
return [(() => {
|
|
1779
1818
|
const _el$ = _tmpl$22(), _el$3 = _el$.firstChild;
|
|
1780
1819
|
insert(_el$, createComponent(Show, {
|
|
@@ -2767,13 +2806,15 @@ function Embed(props) {
|
|
|
2767
2806
|
}
|
|
2768
2807
|
}
|
|
2769
2808
|
let elem;
|
|
2809
|
+
const onUpdateFn_0_elem = createMemo(() => elem);
|
|
2810
|
+
const onUpdateFn_0_ranInitFn__ = createMemo(() => ranInitFn());
|
|
2770
2811
|
function onUpdateFn_0() {
|
|
2771
2812
|
if (elem && !ranInitFn()) {
|
|
2772
2813
|
setRanInitFn(true);
|
|
2773
2814
|
findAndRunScripts();
|
|
2774
2815
|
}
|
|
2775
2816
|
}
|
|
2776
|
-
createEffect(on(() => [
|
|
2817
|
+
createEffect(on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0));
|
|
2777
2818
|
return (() => {
|
|
2778
2819
|
const _el$ = _tmpl$9();
|
|
2779
2820
|
const _ref$ = elem;
|
|
@@ -3667,7 +3708,7 @@ var _tmpl$15 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
|
3667
3708
|
var _tmpl$25 = /* @__PURE__ */ template(`<div>`);
|
|
3668
3709
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
3669
3710
|
function Video(props) {
|
|
3670
|
-
|
|
3711
|
+
const videoProps = createMemo(() => {
|
|
3671
3712
|
return {
|
|
3672
3713
|
...props.autoPlay === true ? {
|
|
3673
3714
|
autoPlay: true
|
|
@@ -3685,12 +3726,12 @@ function Video(props) {
|
|
|
3685
3726
|
playsInline: true
|
|
3686
3727
|
} : {}
|
|
3687
3728
|
};
|
|
3688
|
-
}
|
|
3689
|
-
|
|
3729
|
+
});
|
|
3730
|
+
const spreadProps = createMemo(() => {
|
|
3690
3731
|
return {
|
|
3691
3732
|
...videoProps()
|
|
3692
3733
|
};
|
|
3693
|
-
}
|
|
3734
|
+
});
|
|
3694
3735
|
return (() => {
|
|
3695
3736
|
const _el$ = _tmpl$33(), _el$2 = _el$.firstChild;
|
|
3696
3737
|
_el$.style.setProperty("position", "relative");
|
|
@@ -4405,7 +4446,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4405
4446
|
}
|
|
4406
4447
|
|
|
4407
4448
|
// src/constants/sdk-version.ts
|
|
4408
|
-
var SDK_VERSION = "0.
|
|
4449
|
+
var SDK_VERSION = "1.0.13";
|
|
4409
4450
|
|
|
4410
4451
|
// src/functions/register.ts
|
|
4411
4452
|
var registry = {};
|
|
@@ -4684,7 +4725,11 @@ function EnableEditor(props) {
|
|
|
4684
4725
|
context: props.context || {},
|
|
4685
4726
|
localState: void 0,
|
|
4686
4727
|
rootState: props.builderContextSignal.rootState,
|
|
4687
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4728
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4729
|
+
/**
|
|
4730
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
4731
|
+
*/
|
|
4732
|
+
enableCache: false
|
|
4688
4733
|
});
|
|
4689
4734
|
}
|
|
4690
4735
|
}
|
|
@@ -4707,13 +4752,14 @@ function EnableEditor(props) {
|
|
|
4707
4752
|
}
|
|
4708
4753
|
}
|
|
4709
4754
|
function evalExpression(expression) {
|
|
4710
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
4755
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
4711
4756
|
code: group,
|
|
4712
4757
|
context: props.context || {},
|
|
4713
4758
|
localState: void 0,
|
|
4714
4759
|
rootState: props.builderContextSignal.rootState,
|
|
4715
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4716
|
-
|
|
4760
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4761
|
+
enableCache: true
|
|
4762
|
+
})));
|
|
4717
4763
|
}
|
|
4718
4764
|
function handleRequest({
|
|
4719
4765
|
url,
|
|
@@ -4818,33 +4864,40 @@ function EnableEditor(props) {
|
|
|
4818
4864
|
runHttpRequests();
|
|
4819
4865
|
emitStateUpdate();
|
|
4820
4866
|
});
|
|
4867
|
+
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
4821
4868
|
function onUpdateFn_0() {
|
|
4822
4869
|
if (props.content) {
|
|
4823
4870
|
mergeNewContent(props.content);
|
|
4824
4871
|
}
|
|
4825
4872
|
}
|
|
4826
|
-
createEffect(on(() => [
|
|
4873
|
+
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
4874
|
+
const onUpdateFn_1_shouldSendResetCookie__ = createMemo(() => shouldSendResetCookie());
|
|
4827
4875
|
function onUpdateFn_1() {
|
|
4828
4876
|
}
|
|
4829
|
-
createEffect(on(() => [
|
|
4877
|
+
createEffect(on(() => [onUpdateFn_1_shouldSendResetCookie__()], onUpdateFn_1));
|
|
4878
|
+
const onUpdateFn_2_props_builderContextSignal_content__data__jsCode = createMemo(() => props.builderContextSignal.content?.data?.jsCode);
|
|
4830
4879
|
function onUpdateFn_2() {
|
|
4831
4880
|
evaluateJsCode();
|
|
4832
4881
|
}
|
|
4833
|
-
createEffect(on(() => [
|
|
4882
|
+
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__jsCode()], onUpdateFn_2));
|
|
4883
|
+
const onUpdateFn_3_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
4834
4884
|
function onUpdateFn_3() {
|
|
4835
4885
|
runHttpRequests();
|
|
4836
4886
|
}
|
|
4837
|
-
createEffect(on(() => [
|
|
4887
|
+
createEffect(on(() => [onUpdateFn_3_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_3));
|
|
4888
|
+
const onUpdateFn_4_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
4838
4889
|
function onUpdateFn_4() {
|
|
4839
4890
|
emitStateUpdate();
|
|
4840
4891
|
}
|
|
4841
|
-
createEffect(on(() => [
|
|
4892
|
+
createEffect(on(() => [onUpdateFn_4_props_builderContextSignal_rootState()], onUpdateFn_4));
|
|
4893
|
+
const onUpdateFn_5_props_data = createMemo(() => props.data);
|
|
4842
4894
|
function onUpdateFn_5() {
|
|
4843
4895
|
if (props.data) {
|
|
4844
4896
|
mergeNewRootState(props.data);
|
|
4845
4897
|
}
|
|
4846
4898
|
}
|
|
4847
|
-
createEffect(on(() => [
|
|
4899
|
+
createEffect(on(() => [onUpdateFn_5_props_data()], onUpdateFn_5));
|
|
4900
|
+
const onUpdateFn_6_props_locale = createMemo(() => props.locale);
|
|
4848
4901
|
function onUpdateFn_6() {
|
|
4849
4902
|
if (props.locale) {
|
|
4850
4903
|
mergeNewRootState({
|
|
@@ -4852,7 +4905,7 @@ function EnableEditor(props) {
|
|
|
4852
4905
|
});
|
|
4853
4906
|
}
|
|
4854
4907
|
}
|
|
4855
|
-
createEffect(on(() => [
|
|
4908
|
+
createEffect(on(() => [onUpdateFn_6_props_locale()], onUpdateFn_6));
|
|
4856
4909
|
return createComponent(builder_context_default.Provider, {
|
|
4857
4910
|
get value() {
|
|
4858
4911
|
return props.builderContextSignal;
|
|
@@ -4954,18 +5007,7 @@ var getCss = ({
|
|
|
4954
5007
|
}
|
|
4955
5008
|
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
4956
5009
|
};
|
|
4957
|
-
|
|
4958
|
-
// src/components/content/components/styles.tsx
|
|
4959
|
-
function ContentStyles(props) {
|
|
4960
|
-
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
4961
|
-
${getCss({
|
|
4962
|
-
cssCode: props.cssCode,
|
|
4963
|
-
contentId: props.contentId
|
|
4964
|
-
})}
|
|
4965
|
-
${getFontCss({
|
|
4966
|
-
customFonts: props.customFonts
|
|
4967
|
-
})}
|
|
4968
|
-
|
|
5010
|
+
var DEFAULT_STYLES = `
|
|
4969
5011
|
.builder-button {
|
|
4970
5012
|
all: unset;
|
|
4971
5013
|
}
|
|
@@ -4982,6 +5024,22 @@ ${getFontCss({
|
|
|
4982
5024
|
text-align: inherit;
|
|
4983
5025
|
font-family: inherit;
|
|
4984
5026
|
}
|
|
5027
|
+
`;
|
|
5028
|
+
var getDefaultStyles = (isNested) => {
|
|
5029
|
+
return !isNested ? DEFAULT_STYLES : "";
|
|
5030
|
+
};
|
|
5031
|
+
|
|
5032
|
+
// src/components/content/components/styles.tsx
|
|
5033
|
+
function ContentStyles(props) {
|
|
5034
|
+
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
5035
|
+
${getCss({
|
|
5036
|
+
cssCode: props.cssCode,
|
|
5037
|
+
contentId: props.contentId
|
|
5038
|
+
})}
|
|
5039
|
+
${getFontCss({
|
|
5040
|
+
customFonts: props.customFonts
|
|
5041
|
+
})}
|
|
5042
|
+
${getDefaultStyles(props.isNestedRender)}
|
|
4985
5043
|
`.trim());
|
|
4986
5044
|
return createComponent(inlined_styles_default, {
|
|
4987
5045
|
get styles() {
|
|
@@ -5146,6 +5204,9 @@ function ContentComponent(props) {
|
|
|
5146
5204
|
when: TARGET !== "reactNative",
|
|
5147
5205
|
get children() {
|
|
5148
5206
|
return createComponent(styles_default, {
|
|
5207
|
+
get isNestedRender() {
|
|
5208
|
+
return props.isNestedRender;
|
|
5209
|
+
},
|
|
5149
5210
|
get contentId() {
|
|
5150
5211
|
return builderContextSignal().content?.id;
|
|
5151
5212
|
},
|
|
@@ -5184,16 +5245,16 @@ function ContentVariants(props) {
|
|
|
5184
5245
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5185
5246
|
content: props.content
|
|
5186
5247
|
}));
|
|
5187
|
-
|
|
5248
|
+
const updateCookieAndStylesScriptStr = createMemo(() => {
|
|
5188
5249
|
return getUpdateCookieAndStylesScript(getVariants(props.content).map((value) => ({
|
|
5189
5250
|
id: value.testVariationId,
|
|
5190
5251
|
testRatio: value.testRatio
|
|
5191
5252
|
})), props.content?.id || "");
|
|
5192
|
-
}
|
|
5193
|
-
|
|
5253
|
+
});
|
|
5254
|
+
const hideVariantsStyleString = createMemo(() => {
|
|
5194
5255
|
return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
|
|
5195
|
-
}
|
|
5196
|
-
|
|
5256
|
+
});
|
|
5257
|
+
const defaultContent = createMemo(() => {
|
|
5197
5258
|
return shouldRenderVariants() ? {
|
|
5198
5259
|
...props.content,
|
|
5199
5260
|
testVariationId: props.content?.id
|
|
@@ -5201,13 +5262,13 @@ function ContentVariants(props) {
|
|
|
5201
5262
|
item: props.content,
|
|
5202
5263
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
5203
5264
|
});
|
|
5204
|
-
}
|
|
5265
|
+
});
|
|
5205
5266
|
onMount(() => {
|
|
5206
5267
|
setShouldRenderVariants(false);
|
|
5207
5268
|
});
|
|
5208
5269
|
return [createComponent(Show, {
|
|
5209
5270
|
get when() {
|
|
5210
|
-
return !props.
|
|
5271
|
+
return !props.isNestedRender && TARGET !== "reactNative";
|
|
5211
5272
|
},
|
|
5212
5273
|
get children() {
|
|
5213
5274
|
return createComponent(inlined_script_default, {
|
|
@@ -5239,6 +5300,9 @@ function ContentVariants(props) {
|
|
|
5239
5300
|
children: (variant, _index) => {
|
|
5240
5301
|
_index();
|
|
5241
5302
|
return createComponent(content_default, {
|
|
5303
|
+
get isNestedRender() {
|
|
5304
|
+
return props.isNestedRender;
|
|
5305
|
+
},
|
|
5242
5306
|
get key() {
|
|
5243
5307
|
return variant.testVariationId;
|
|
5244
5308
|
},
|
|
@@ -5296,7 +5360,11 @@ function ContentVariants(props) {
|
|
|
5296
5360
|
}
|
|
5297
5361
|
})];
|
|
5298
5362
|
}
|
|
5299
|
-
}), createComponent(content_default, mergeProps({
|
|
5363
|
+
}), createComponent(content_default, mergeProps({
|
|
5364
|
+
get isNestedRender() {
|
|
5365
|
+
return props.isNestedRender;
|
|
5366
|
+
}
|
|
5367
|
+
}, {}, {
|
|
5300
5368
|
get content() {
|
|
5301
5369
|
return defaultContent();
|
|
5302
5370
|
},
|
|
@@ -5381,9 +5449,9 @@ var fetchSymbolContent = async ({
|
|
|
5381
5449
|
var _tmpl$17 = /* @__PURE__ */ template(`<div>`);
|
|
5382
5450
|
function Symbol(props) {
|
|
5383
5451
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
5384
|
-
|
|
5452
|
+
const className = createMemo(() => {
|
|
5385
5453
|
return [...[props.attributes[getClassPropName()]], "builder-symbol", props.symbol?.inline ? "builder-inline-symbol" : void 0, props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0].filter(Boolean).join(" ");
|
|
5386
|
-
}
|
|
5454
|
+
});
|
|
5387
5455
|
function setContent() {
|
|
5388
5456
|
if (contentToUse())
|
|
5389
5457
|
return;
|
|
@@ -5397,12 +5465,12 @@ function Symbol(props) {
|
|
|
5397
5465
|
});
|
|
5398
5466
|
}
|
|
5399
5467
|
onMount(() => {
|
|
5400
|
-
setContent();
|
|
5401
5468
|
});
|
|
5469
|
+
const onUpdateFn_0_props_symbol = createMemo(() => props.symbol);
|
|
5402
5470
|
function onUpdateFn_0() {
|
|
5403
5471
|
setContent();
|
|
5404
5472
|
}
|
|
5405
|
-
createEffect(on(() => [
|
|
5473
|
+
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
5406
5474
|
return (() => {
|
|
5407
5475
|
const _el$ = _tmpl$17();
|
|
5408
5476
|
spread(_el$, mergeProps({
|
|
@@ -5411,7 +5479,7 @@ function Symbol(props) {
|
|
|
5411
5479
|
}
|
|
5412
5480
|
}, {}, () => props.attributes, {}), false, true);
|
|
5413
5481
|
insert(_el$, createComponent(content_variants_default, {
|
|
5414
|
-
|
|
5482
|
+
isNestedRender: true,
|
|
5415
5483
|
get apiVersion() {
|
|
5416
5484
|
return props.builderContext.apiVersion;
|
|
5417
5485
|
},
|