@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/node/index.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
|
import { createRequire } from 'node:module';
|
|
5
5
|
|
|
@@ -280,7 +280,7 @@ function flattenState({
|
|
|
280
280
|
return localState[prop];
|
|
281
281
|
}
|
|
282
282
|
const val = target[prop];
|
|
283
|
-
if (typeof val === "object") {
|
|
283
|
+
if (typeof val === "object" && val !== null) {
|
|
284
284
|
return flattenState({
|
|
285
285
|
rootState: val,
|
|
286
286
|
localState: void 0,
|
|
@@ -468,6 +468,30 @@ var shouldForceBrowserRuntimeInNode = () => {
|
|
|
468
468
|
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
469
469
|
|
|
470
470
|
// src/functions/evaluate/evaluate.ts
|
|
471
|
+
var EvalCache = class _EvalCache {
|
|
472
|
+
static cacheLimit = 20;
|
|
473
|
+
static cache = /* @__PURE__ */ new Map();
|
|
474
|
+
static getCacheKey(args) {
|
|
475
|
+
return JSON.stringify({
|
|
476
|
+
...args,
|
|
477
|
+
// replace the event with a random number to break cache
|
|
478
|
+
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
479
|
+
event: args.event ? Math.random() : void 0
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
static getCachedValue(key) {
|
|
483
|
+
const cachedVal = _EvalCache.cache.get(key);
|
|
484
|
+
return cachedVal;
|
|
485
|
+
}
|
|
486
|
+
static setCachedValue(key, value) {
|
|
487
|
+
if (_EvalCache.cache.size > 20) {
|
|
488
|
+
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
489
|
+
}
|
|
490
|
+
_EvalCache.cache.set(key, {
|
|
491
|
+
value
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
};
|
|
471
495
|
function evaluate({
|
|
472
496
|
code,
|
|
473
497
|
context,
|
|
@@ -475,11 +499,12 @@ function evaluate({
|
|
|
475
499
|
rootState,
|
|
476
500
|
rootSetState,
|
|
477
501
|
event,
|
|
478
|
-
isExpression = true
|
|
502
|
+
isExpression = true,
|
|
503
|
+
enableCache
|
|
479
504
|
}) {
|
|
480
505
|
if (code === "") {
|
|
481
506
|
logger.warn("Skipping evaluation of empty code block.");
|
|
482
|
-
return;
|
|
507
|
+
return void 0;
|
|
483
508
|
}
|
|
484
509
|
const args = {
|
|
485
510
|
code: parseCode(code, {
|
|
@@ -492,8 +517,20 @@ function evaluate({
|
|
|
492
517
|
rootState,
|
|
493
518
|
localState
|
|
494
519
|
};
|
|
520
|
+
if (enableCache) {
|
|
521
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
522
|
+
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
523
|
+
if (cachedValue) {
|
|
524
|
+
return cachedValue.value;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
495
527
|
try {
|
|
496
|
-
|
|
528
|
+
const newEval = chooseBrowserOrServerEval(args);
|
|
529
|
+
if (enableCache) {
|
|
530
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
531
|
+
EvalCache.setCachedValue(cacheKey, newEval);
|
|
532
|
+
}
|
|
533
|
+
return newEval;
|
|
497
534
|
} catch (e) {
|
|
498
535
|
logger.error("Failed code evaluation: " + e.message, {
|
|
499
536
|
code
|
|
@@ -535,7 +572,8 @@ var evaluateBindings = ({
|
|
|
535
572
|
localState,
|
|
536
573
|
rootState,
|
|
537
574
|
rootSetState,
|
|
538
|
-
context
|
|
575
|
+
context,
|
|
576
|
+
enableCache: true
|
|
539
577
|
});
|
|
540
578
|
set(copied, binding, value);
|
|
541
579
|
}
|
|
@@ -768,6 +806,70 @@ function bindScrollInViewAnimation(animation) {
|
|
|
768
806
|
});
|
|
769
807
|
}
|
|
770
808
|
|
|
809
|
+
// src/functions/camel-to-kebab-case.ts
|
|
810
|
+
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
811
|
+
|
|
812
|
+
// src/helpers/css.ts
|
|
813
|
+
var convertStyleMapToCSSArray = (style) => {
|
|
814
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
815
|
+
if (typeof value === "string") {
|
|
816
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
817
|
+
} else {
|
|
818
|
+
return void 0;
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
return cssProps.filter(checkIsDefined);
|
|
822
|
+
};
|
|
823
|
+
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
824
|
+
var createCssClass = ({
|
|
825
|
+
mediaQuery,
|
|
826
|
+
className,
|
|
827
|
+
styles
|
|
828
|
+
}) => {
|
|
829
|
+
const cssClass = `.${className} {
|
|
830
|
+
${convertStyleMapToCSS(styles)}
|
|
831
|
+
}`;
|
|
832
|
+
if (mediaQuery) {
|
|
833
|
+
return `${mediaQuery} {
|
|
834
|
+
${cssClass}
|
|
835
|
+
}`;
|
|
836
|
+
} else {
|
|
837
|
+
return cssClass;
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// src/functions/transform-style-property.ts
|
|
842
|
+
function transformStyleProperty({
|
|
843
|
+
style
|
|
844
|
+
}) {
|
|
845
|
+
return style;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// src/functions/get-style.ts
|
|
849
|
+
var getStyle = ({
|
|
850
|
+
block,
|
|
851
|
+
context
|
|
852
|
+
}) => {
|
|
853
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
854
|
+
style: block.style || {},
|
|
855
|
+
context,
|
|
856
|
+
block
|
|
857
|
+
}));
|
|
858
|
+
};
|
|
859
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
860
|
+
switch (TARGET) {
|
|
861
|
+
case "svelte":
|
|
862
|
+
case "vue":
|
|
863
|
+
case "solid":
|
|
864
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
865
|
+
case "qwik":
|
|
866
|
+
case "reactNative":
|
|
867
|
+
case "react":
|
|
868
|
+
case "rsc":
|
|
869
|
+
return style;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
771
873
|
// src/components/block/block.helpers.ts
|
|
772
874
|
var getComponent = ({
|
|
773
875
|
block,
|
|
@@ -808,7 +910,8 @@ var getRepeatItemData = ({
|
|
|
808
910
|
localState: context.localState,
|
|
809
911
|
rootState: context.rootState,
|
|
810
912
|
rootSetState: context.rootSetState,
|
|
811
|
-
context: context.context
|
|
913
|
+
context: context.context,
|
|
914
|
+
enableCache: true
|
|
812
915
|
});
|
|
813
916
|
if (!Array.isArray(itemsArray)) {
|
|
814
917
|
return void 0;
|
|
@@ -879,38 +982,6 @@ var getSizesForBreakpoints = ({
|
|
|
879
982
|
};
|
|
880
983
|
return newSizes;
|
|
881
984
|
};
|
|
882
|
-
|
|
883
|
-
// src/functions/camel-to-kebab-case.ts
|
|
884
|
-
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
885
|
-
|
|
886
|
-
// src/helpers/css.ts
|
|
887
|
-
var convertStyleMapToCSSArray = (style) => {
|
|
888
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
889
|
-
if (typeof value === "string") {
|
|
890
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
891
|
-
} else {
|
|
892
|
-
return void 0;
|
|
893
|
-
}
|
|
894
|
-
});
|
|
895
|
-
return cssProps.filter(checkIsDefined);
|
|
896
|
-
};
|
|
897
|
-
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
898
|
-
var createCssClass = ({
|
|
899
|
-
mediaQuery,
|
|
900
|
-
className,
|
|
901
|
-
styles
|
|
902
|
-
}) => {
|
|
903
|
-
const cssClass = `.${className} {
|
|
904
|
-
${convertStyleMapToCSS(styles)}
|
|
905
|
-
}`;
|
|
906
|
-
if (mediaQuery) {
|
|
907
|
-
return `${mediaQuery} {
|
|
908
|
-
${cssClass}
|
|
909
|
-
}`;
|
|
910
|
-
} else {
|
|
911
|
-
return cssClass;
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
985
|
var _tmpl$ = /* @__PURE__ */ template(`<style>`);
|
|
915
986
|
function InlinedStyles(props) {
|
|
916
987
|
return (() => {
|
|
@@ -931,7 +1002,7 @@ var inlined_styles_default = InlinedStyles;
|
|
|
931
1002
|
|
|
932
1003
|
// src/components/block/components/block-styles.tsx
|
|
933
1004
|
function BlockStyles(props) {
|
|
934
|
-
|
|
1005
|
+
const canShowBlock = createMemo(() => {
|
|
935
1006
|
const processedBlock = getProcessedBlock({
|
|
936
1007
|
block: props.block,
|
|
937
1008
|
localState: props.context.localState,
|
|
@@ -947,8 +1018,8 @@ function BlockStyles(props) {
|
|
|
947
1018
|
return processedBlock.show;
|
|
948
1019
|
}
|
|
949
1020
|
return true;
|
|
950
|
-
}
|
|
951
|
-
|
|
1021
|
+
});
|
|
1022
|
+
const css5 = createMemo(() => {
|
|
952
1023
|
const processedBlock = getProcessedBlock({
|
|
953
1024
|
block: props.block,
|
|
954
1025
|
localState: props.context.localState,
|
|
@@ -982,7 +1053,7 @@ function BlockStyles(props) {
|
|
|
982
1053
|
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
|
|
983
1054
|
}) : "";
|
|
984
1055
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
985
|
-
}
|
|
1056
|
+
});
|
|
986
1057
|
return createComponent(Show, {
|
|
987
1058
|
get when() {
|
|
988
1059
|
return memo(() => !!(TARGET !== "reactNative" && css5()))() && canShowBlock();
|
|
@@ -1012,7 +1083,8 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1012
1083
|
rootState: options.rootState,
|
|
1013
1084
|
rootSetState: options.rootSetState,
|
|
1014
1085
|
event,
|
|
1015
|
-
isExpression: false
|
|
1086
|
+
isExpression: false,
|
|
1087
|
+
enableCache: true
|
|
1016
1088
|
});
|
|
1017
1089
|
|
|
1018
1090
|
// src/functions/get-block-actions.ts
|
|
@@ -1040,38 +1112,6 @@ function getBlockActions(options) {
|
|
|
1040
1112
|
return obj;
|
|
1041
1113
|
}
|
|
1042
1114
|
|
|
1043
|
-
// src/functions/transform-style-property.ts
|
|
1044
|
-
function transformStyleProperty({
|
|
1045
|
-
style
|
|
1046
|
-
}) {
|
|
1047
|
-
return style;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
// src/functions/get-style.ts
|
|
1051
|
-
var getStyle = ({
|
|
1052
|
-
block,
|
|
1053
|
-
context
|
|
1054
|
-
}) => {
|
|
1055
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
1056
|
-
style: block.style || {},
|
|
1057
|
-
context,
|
|
1058
|
-
block
|
|
1059
|
-
}));
|
|
1060
|
-
};
|
|
1061
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
1062
|
-
switch (TARGET) {
|
|
1063
|
-
case "svelte":
|
|
1064
|
-
case "vue":
|
|
1065
|
-
case "solid":
|
|
1066
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
1067
|
-
case "qwik":
|
|
1068
|
-
case "reactNative":
|
|
1069
|
-
case "react":
|
|
1070
|
-
case "rsc":
|
|
1071
|
-
return style;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
1115
|
// src/functions/transform-block-properties.ts
|
|
1076
1116
|
function transformBlockProperties({
|
|
1077
1117
|
properties
|
|
@@ -1273,21 +1313,20 @@ var repeated_block_default = RepeatedBlock;
|
|
|
1273
1313
|
|
|
1274
1314
|
// src/components/block/block.tsx
|
|
1275
1315
|
function Block(props) {
|
|
1276
|
-
const
|
|
1277
|
-
function blockComponent() {
|
|
1316
|
+
const blockComponent = createMemo(() => {
|
|
1278
1317
|
return getComponent({
|
|
1279
1318
|
block: props.block,
|
|
1280
1319
|
context: props.context,
|
|
1281
1320
|
registeredComponents: props.registeredComponents
|
|
1282
1321
|
});
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1322
|
+
});
|
|
1323
|
+
const repeatItem = createMemo(() => {
|
|
1285
1324
|
return getRepeatItemData({
|
|
1286
1325
|
block: props.block,
|
|
1287
1326
|
context: props.context
|
|
1288
1327
|
});
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1328
|
+
});
|
|
1329
|
+
const processedBlock = createMemo(() => {
|
|
1291
1330
|
return props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
1292
1331
|
block: props.block,
|
|
1293
1332
|
localState: props.context.localState,
|
|
@@ -1296,15 +1335,15 @@ function Block(props) {
|
|
|
1296
1335
|
context: props.context.context,
|
|
1297
1336
|
shouldEvaluateBindings: true
|
|
1298
1337
|
});
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1338
|
+
});
|
|
1339
|
+
const Tag = createMemo(() => {
|
|
1301
1340
|
const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
|
|
1302
1341
|
if (shouldUseLink) {
|
|
1303
1342
|
return props.linkComponent || "a";
|
|
1304
1343
|
}
|
|
1305
1344
|
return props.block.tagName || "div";
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1345
|
+
});
|
|
1346
|
+
const canShowBlock = createMemo(() => {
|
|
1308
1347
|
if (props.block.repeat?.collection) {
|
|
1309
1348
|
if (repeatItem()?.length)
|
|
1310
1349
|
return true;
|
|
@@ -1313,12 +1352,12 @@ function Block(props) {
|
|
|
1313
1352
|
const shouldHide = "hide" in processedBlock() ? processedBlock().hide : false;
|
|
1314
1353
|
const shouldShow = "show" in processedBlock() ? processedBlock().show : true;
|
|
1315
1354
|
return shouldShow && !shouldHide;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1355
|
+
});
|
|
1356
|
+
const childrenWithoutParentComponent = createMemo(() => {
|
|
1318
1357
|
const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
|
|
1319
1358
|
return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1359
|
+
});
|
|
1360
|
+
const componentRefProps = createMemo(() => {
|
|
1322
1361
|
return {
|
|
1323
1362
|
blockChildren: processedBlock().children ?? [],
|
|
1324
1363
|
componentRef: blockComponent()?.component,
|
|
@@ -1332,14 +1371,14 @@ function Block(props) {
|
|
|
1332
1371
|
builderComponents: props.registeredComponents
|
|
1333
1372
|
} : {}
|
|
1334
1373
|
},
|
|
1335
|
-
context:
|
|
1374
|
+
context: props.context,
|
|
1336
1375
|
linkComponent: props.linkComponent,
|
|
1337
1376
|
registeredComponents: props.registeredComponents,
|
|
1338
1377
|
builderBlock: processedBlock(),
|
|
1339
1378
|
includeBlockProps: blockComponent()?.noWrap === true,
|
|
1340
1379
|
isInteractive: !blockComponent()?.isRSC
|
|
1341
1380
|
};
|
|
1342
|
-
}
|
|
1381
|
+
});
|
|
1343
1382
|
onMount(() => {
|
|
1344
1383
|
const blockId = processedBlock().id;
|
|
1345
1384
|
const animations = processedBlock().animations;
|
|
@@ -1481,14 +1520,14 @@ function Block(props) {
|
|
|
1481
1520
|
return child.id;
|
|
1482
1521
|
},
|
|
1483
1522
|
block: child,
|
|
1484
|
-
get context() {
|
|
1485
|
-
return childrenContext();
|
|
1486
|
-
},
|
|
1487
1523
|
get registeredComponents() {
|
|
1488
1524
|
return props.registeredComponents;
|
|
1489
1525
|
},
|
|
1490
1526
|
get linkComponent() {
|
|
1491
1527
|
return props.linkComponent;
|
|
1528
|
+
},
|
|
1529
|
+
get context() {
|
|
1530
|
+
return props.context;
|
|
1492
1531
|
}
|
|
1493
1532
|
});
|
|
1494
1533
|
}
|
|
@@ -1504,9 +1543,9 @@ function Block(props) {
|
|
|
1504
1543
|
}
|
|
1505
1544
|
var block_default = Block;
|
|
1506
1545
|
function BlocksWrapper(props) {
|
|
1507
|
-
|
|
1546
|
+
const className = createMemo(() => {
|
|
1508
1547
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
1509
|
-
}
|
|
1548
|
+
});
|
|
1510
1549
|
function onClick() {
|
|
1511
1550
|
if (isEditing() && !props.blocks?.length) {
|
|
1512
1551
|
window.parent?.postMessage({
|
|
@@ -1646,7 +1685,7 @@ function Columns(props) {
|
|
|
1646
1685
|
}) {
|
|
1647
1686
|
return stackAt() === "never" ? desktopStyle : stackedStyle;
|
|
1648
1687
|
}
|
|
1649
|
-
|
|
1688
|
+
const columnsCssVars = createMemo(() => {
|
|
1650
1689
|
return {
|
|
1651
1690
|
"--flex-dir": flexDir(),
|
|
1652
1691
|
"--flex-dir-tablet": getTabletStyle({
|
|
@@ -1654,7 +1693,7 @@ function Columns(props) {
|
|
|
1654
1693
|
desktopStyle: "row"
|
|
1655
1694
|
})
|
|
1656
1695
|
};
|
|
1657
|
-
}
|
|
1696
|
+
});
|
|
1658
1697
|
function columnCssVars(index) {
|
|
1659
1698
|
const gutter = index === 0 ? 0 : gutterSize();
|
|
1660
1699
|
const width = getColumnCssWidth(index);
|
|
@@ -1693,7 +1732,7 @@ function Columns(props) {
|
|
|
1693
1732
|
const breakpointSizes = getSizesForBreakpoints(props.builderContext.content?.meta?.breakpoints || {});
|
|
1694
1733
|
return breakpointSizes[size].max;
|
|
1695
1734
|
}
|
|
1696
|
-
|
|
1735
|
+
const columnsStyles = createMemo(() => {
|
|
1697
1736
|
return `
|
|
1698
1737
|
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
1699
1738
|
.${props.builderBlock.id}-breakpoints {
|
|
@@ -1719,7 +1758,7 @@ function Columns(props) {
|
|
|
1719
1758
|
}
|
|
1720
1759
|
},
|
|
1721
1760
|
`;
|
|
1722
|
-
}
|
|
1761
|
+
});
|
|
1723
1762
|
return (() => {
|
|
1724
1763
|
const _el$ = _tmpl$2();
|
|
1725
1764
|
spread(_el$, mergeProps({
|
|
@@ -1857,7 +1896,7 @@ var _tmpl$4 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
|
1857
1896
|
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
|
|
1858
1897
|
var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
|
|
1859
1898
|
function Image(props) {
|
|
1860
|
-
|
|
1899
|
+
const srcSetToUse = createMemo(() => {
|
|
1861
1900
|
const imageToUse = props.image || props.src;
|
|
1862
1901
|
const url = imageToUse;
|
|
1863
1902
|
if (!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
@@ -1873,15 +1912,15 @@ function Image(props) {
|
|
|
1873
1912
|
return getSrcSet(url);
|
|
1874
1913
|
}
|
|
1875
1914
|
return getSrcSet(url);
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1915
|
+
});
|
|
1916
|
+
const webpSrcSet = createMemo(() => {
|
|
1878
1917
|
if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
|
|
1879
1918
|
return srcSetToUse().replace(/\?/g, "?format=webp&");
|
|
1880
1919
|
} else {
|
|
1881
1920
|
return "";
|
|
1882
1921
|
}
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1922
|
+
});
|
|
1923
|
+
const aspectRatioCss = createMemo(() => {
|
|
1885
1924
|
const aspectRatioStyles = {
|
|
1886
1925
|
position: "absolute",
|
|
1887
1926
|
height: "100%",
|
|
@@ -1891,7 +1930,7 @@ function Image(props) {
|
|
|
1891
1930
|
};
|
|
1892
1931
|
const out = props.aspectRatio ? aspectRatioStyles : void 0;
|
|
1893
1932
|
return out;
|
|
1894
|
-
}
|
|
1933
|
+
});
|
|
1895
1934
|
return [(() => {
|
|
1896
1935
|
const _el$ = _tmpl$22(), _el$3 = _el$.firstChild;
|
|
1897
1936
|
insert(_el$, createComponent(Show, {
|
|
@@ -2881,13 +2920,15 @@ function Embed(props) {
|
|
|
2881
2920
|
}
|
|
2882
2921
|
}
|
|
2883
2922
|
let elem;
|
|
2923
|
+
const onUpdateFn_0_elem = createMemo(() => elem);
|
|
2924
|
+
const onUpdateFn_0_ranInitFn__ = createMemo(() => ranInitFn());
|
|
2884
2925
|
function onUpdateFn_0() {
|
|
2885
2926
|
if (elem && !ranInitFn()) {
|
|
2886
2927
|
setRanInitFn(true);
|
|
2887
2928
|
findAndRunScripts();
|
|
2888
2929
|
}
|
|
2889
2930
|
}
|
|
2890
|
-
createEffect(on(() => [
|
|
2931
|
+
createEffect(on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0));
|
|
2891
2932
|
return (() => {
|
|
2892
2933
|
const _el$ = _tmpl$9();
|
|
2893
2934
|
const _ref$ = elem;
|
|
@@ -3781,7 +3822,7 @@ var _tmpl$15 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
|
3781
3822
|
var _tmpl$25 = /* @__PURE__ */ template(`<div>`);
|
|
3782
3823
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
3783
3824
|
function Video(props) {
|
|
3784
|
-
|
|
3825
|
+
const videoProps = createMemo(() => {
|
|
3785
3826
|
return {
|
|
3786
3827
|
...props.autoPlay === true ? {
|
|
3787
3828
|
autoPlay: true
|
|
@@ -3799,12 +3840,12 @@ function Video(props) {
|
|
|
3799
3840
|
playsInline: true
|
|
3800
3841
|
} : {}
|
|
3801
3842
|
};
|
|
3802
|
-
}
|
|
3803
|
-
|
|
3843
|
+
});
|
|
3844
|
+
const spreadProps = createMemo(() => {
|
|
3804
3845
|
return {
|
|
3805
3846
|
...videoProps()
|
|
3806
3847
|
};
|
|
3807
|
-
}
|
|
3848
|
+
});
|
|
3808
3849
|
return (() => {
|
|
3809
3850
|
const _el$ = _tmpl$33(), _el$2 = _el$.firstChild;
|
|
3810
3851
|
_el$.style.setProperty("position", "relative");
|
|
@@ -4514,7 +4555,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4514
4555
|
}
|
|
4515
4556
|
|
|
4516
4557
|
// src/constants/sdk-version.ts
|
|
4517
|
-
var SDK_VERSION = "0.
|
|
4558
|
+
var SDK_VERSION = "1.0.13";
|
|
4518
4559
|
|
|
4519
4560
|
// src/functions/register.ts
|
|
4520
4561
|
var registry = {};
|
|
@@ -4792,7 +4833,11 @@ function EnableEditor(props) {
|
|
|
4792
4833
|
context: props.context || {},
|
|
4793
4834
|
localState: void 0,
|
|
4794
4835
|
rootState: props.builderContextSignal.rootState,
|
|
4795
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4836
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4837
|
+
/**
|
|
4838
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
4839
|
+
*/
|
|
4840
|
+
enableCache: false
|
|
4796
4841
|
});
|
|
4797
4842
|
}
|
|
4798
4843
|
}
|
|
@@ -4815,13 +4860,14 @@ function EnableEditor(props) {
|
|
|
4815
4860
|
}
|
|
4816
4861
|
}
|
|
4817
4862
|
function evalExpression(expression) {
|
|
4818
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
4863
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
4819
4864
|
code: group,
|
|
4820
4865
|
context: props.context || {},
|
|
4821
4866
|
localState: void 0,
|
|
4822
4867
|
rootState: props.builderContextSignal.rootState,
|
|
4823
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4824
|
-
|
|
4868
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4869
|
+
enableCache: true
|
|
4870
|
+
})));
|
|
4825
4871
|
}
|
|
4826
4872
|
function handleRequest({
|
|
4827
4873
|
url,
|
|
@@ -4925,33 +4971,40 @@ function EnableEditor(props) {
|
|
|
4925
4971
|
runHttpRequests();
|
|
4926
4972
|
emitStateUpdate();
|
|
4927
4973
|
});
|
|
4974
|
+
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
4928
4975
|
function onUpdateFn_0() {
|
|
4929
4976
|
if (props.content) {
|
|
4930
4977
|
mergeNewContent(props.content);
|
|
4931
4978
|
}
|
|
4932
4979
|
}
|
|
4933
|
-
createEffect(on(() => [
|
|
4980
|
+
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
4981
|
+
const onUpdateFn_1_shouldSendResetCookie__ = createMemo(() => shouldSendResetCookie());
|
|
4934
4982
|
function onUpdateFn_1() {
|
|
4935
4983
|
}
|
|
4936
|
-
createEffect(on(() => [
|
|
4984
|
+
createEffect(on(() => [onUpdateFn_1_shouldSendResetCookie__()], onUpdateFn_1));
|
|
4985
|
+
const onUpdateFn_2_props_builderContextSignal_content__data__jsCode = createMemo(() => props.builderContextSignal.content?.data?.jsCode);
|
|
4937
4986
|
function onUpdateFn_2() {
|
|
4938
4987
|
evaluateJsCode();
|
|
4939
4988
|
}
|
|
4940
|
-
createEffect(on(() => [
|
|
4989
|
+
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__jsCode()], onUpdateFn_2));
|
|
4990
|
+
const onUpdateFn_3_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
4941
4991
|
function onUpdateFn_3() {
|
|
4942
4992
|
runHttpRequests();
|
|
4943
4993
|
}
|
|
4944
|
-
createEffect(on(() => [
|
|
4994
|
+
createEffect(on(() => [onUpdateFn_3_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_3));
|
|
4995
|
+
const onUpdateFn_4_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
4945
4996
|
function onUpdateFn_4() {
|
|
4946
4997
|
emitStateUpdate();
|
|
4947
4998
|
}
|
|
4948
|
-
createEffect(on(() => [
|
|
4999
|
+
createEffect(on(() => [onUpdateFn_4_props_builderContextSignal_rootState()], onUpdateFn_4));
|
|
5000
|
+
const onUpdateFn_5_props_data = createMemo(() => props.data);
|
|
4949
5001
|
function onUpdateFn_5() {
|
|
4950
5002
|
if (props.data) {
|
|
4951
5003
|
mergeNewRootState(props.data);
|
|
4952
5004
|
}
|
|
4953
5005
|
}
|
|
4954
|
-
createEffect(on(() => [
|
|
5006
|
+
createEffect(on(() => [onUpdateFn_5_props_data()], onUpdateFn_5));
|
|
5007
|
+
const onUpdateFn_6_props_locale = createMemo(() => props.locale);
|
|
4955
5008
|
function onUpdateFn_6() {
|
|
4956
5009
|
if (props.locale) {
|
|
4957
5010
|
mergeNewRootState({
|
|
@@ -4959,7 +5012,7 @@ function EnableEditor(props) {
|
|
|
4959
5012
|
});
|
|
4960
5013
|
}
|
|
4961
5014
|
}
|
|
4962
|
-
createEffect(on(() => [
|
|
5015
|
+
createEffect(on(() => [onUpdateFn_6_props_locale()], onUpdateFn_6));
|
|
4963
5016
|
return createComponent(builder_context_default.Provider, {
|
|
4964
5017
|
get value() {
|
|
4965
5018
|
return props.builderContextSignal;
|
|
@@ -5061,18 +5114,7 @@ var getCss = ({
|
|
|
5061
5114
|
}
|
|
5062
5115
|
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
5063
5116
|
};
|
|
5064
|
-
|
|
5065
|
-
// src/components/content/components/styles.tsx
|
|
5066
|
-
function ContentStyles(props) {
|
|
5067
|
-
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
5068
|
-
${getCss({
|
|
5069
|
-
cssCode: props.cssCode,
|
|
5070
|
-
contentId: props.contentId
|
|
5071
|
-
})}
|
|
5072
|
-
${getFontCss({
|
|
5073
|
-
customFonts: props.customFonts
|
|
5074
|
-
})}
|
|
5075
|
-
|
|
5117
|
+
var DEFAULT_STYLES = `
|
|
5076
5118
|
.builder-button {
|
|
5077
5119
|
all: unset;
|
|
5078
5120
|
}
|
|
@@ -5089,6 +5131,22 @@ ${getFontCss({
|
|
|
5089
5131
|
text-align: inherit;
|
|
5090
5132
|
font-family: inherit;
|
|
5091
5133
|
}
|
|
5134
|
+
`;
|
|
5135
|
+
var getDefaultStyles = (isNested) => {
|
|
5136
|
+
return !isNested ? DEFAULT_STYLES : "";
|
|
5137
|
+
};
|
|
5138
|
+
|
|
5139
|
+
// src/components/content/components/styles.tsx
|
|
5140
|
+
function ContentStyles(props) {
|
|
5141
|
+
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
5142
|
+
${getCss({
|
|
5143
|
+
cssCode: props.cssCode,
|
|
5144
|
+
contentId: props.contentId
|
|
5145
|
+
})}
|
|
5146
|
+
${getFontCss({
|
|
5147
|
+
customFonts: props.customFonts
|
|
5148
|
+
})}
|
|
5149
|
+
${getDefaultStyles(props.isNestedRender)}
|
|
5092
5150
|
`.trim());
|
|
5093
5151
|
return createComponent(inlined_styles_default, {
|
|
5094
5152
|
get styles() {
|
|
@@ -5253,6 +5311,9 @@ function ContentComponent(props) {
|
|
|
5253
5311
|
when: TARGET !== "reactNative",
|
|
5254
5312
|
get children() {
|
|
5255
5313
|
return createComponent(styles_default, {
|
|
5314
|
+
get isNestedRender() {
|
|
5315
|
+
return props.isNestedRender;
|
|
5316
|
+
},
|
|
5256
5317
|
get contentId() {
|
|
5257
5318
|
return builderContextSignal().content?.id;
|
|
5258
5319
|
},
|
|
@@ -5291,16 +5352,16 @@ function ContentVariants(props) {
|
|
|
5291
5352
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5292
5353
|
content: props.content
|
|
5293
5354
|
}));
|
|
5294
|
-
|
|
5355
|
+
const updateCookieAndStylesScriptStr = createMemo(() => {
|
|
5295
5356
|
return getUpdateCookieAndStylesScript(getVariants(props.content).map((value) => ({
|
|
5296
5357
|
id: value.testVariationId,
|
|
5297
5358
|
testRatio: value.testRatio
|
|
5298
5359
|
})), props.content?.id || "");
|
|
5299
|
-
}
|
|
5300
|
-
|
|
5360
|
+
});
|
|
5361
|
+
const hideVariantsStyleString = createMemo(() => {
|
|
5301
5362
|
return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
|
|
5302
|
-
}
|
|
5303
|
-
|
|
5363
|
+
});
|
|
5364
|
+
const defaultContent = createMemo(() => {
|
|
5304
5365
|
return shouldRenderVariants() ? {
|
|
5305
5366
|
...props.content,
|
|
5306
5367
|
testVariationId: props.content?.id
|
|
@@ -5308,13 +5369,13 @@ function ContentVariants(props) {
|
|
|
5308
5369
|
item: props.content,
|
|
5309
5370
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
5310
5371
|
});
|
|
5311
|
-
}
|
|
5372
|
+
});
|
|
5312
5373
|
onMount(() => {
|
|
5313
5374
|
setShouldRenderVariants(false);
|
|
5314
5375
|
});
|
|
5315
5376
|
return [createComponent(Show, {
|
|
5316
5377
|
get when() {
|
|
5317
|
-
return !props.
|
|
5378
|
+
return !props.isNestedRender && TARGET !== "reactNative";
|
|
5318
5379
|
},
|
|
5319
5380
|
get children() {
|
|
5320
5381
|
return createComponent(inlined_script_default, {
|
|
@@ -5346,6 +5407,9 @@ function ContentVariants(props) {
|
|
|
5346
5407
|
children: (variant, _index) => {
|
|
5347
5408
|
_index();
|
|
5348
5409
|
return createComponent(content_default, {
|
|
5410
|
+
get isNestedRender() {
|
|
5411
|
+
return props.isNestedRender;
|
|
5412
|
+
},
|
|
5349
5413
|
get key() {
|
|
5350
5414
|
return variant.testVariationId;
|
|
5351
5415
|
},
|
|
@@ -5403,7 +5467,11 @@ function ContentVariants(props) {
|
|
|
5403
5467
|
}
|
|
5404
5468
|
})];
|
|
5405
5469
|
}
|
|
5406
|
-
}), createComponent(content_default, mergeProps({
|
|
5470
|
+
}), createComponent(content_default, mergeProps({
|
|
5471
|
+
get isNestedRender() {
|
|
5472
|
+
return props.isNestedRender;
|
|
5473
|
+
}
|
|
5474
|
+
}, {}, {
|
|
5407
5475
|
get content() {
|
|
5408
5476
|
return defaultContent();
|
|
5409
5477
|
},
|
|
@@ -5488,9 +5556,9 @@ var fetchSymbolContent = async ({
|
|
|
5488
5556
|
var _tmpl$17 = /* @__PURE__ */ template(`<div>`);
|
|
5489
5557
|
function Symbol(props) {
|
|
5490
5558
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
5491
|
-
|
|
5559
|
+
const className = createMemo(() => {
|
|
5492
5560
|
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(" ");
|
|
5493
|
-
}
|
|
5561
|
+
});
|
|
5494
5562
|
function setContent() {
|
|
5495
5563
|
if (contentToUse())
|
|
5496
5564
|
return;
|
|
@@ -5504,12 +5572,12 @@ function Symbol(props) {
|
|
|
5504
5572
|
});
|
|
5505
5573
|
}
|
|
5506
5574
|
onMount(() => {
|
|
5507
|
-
setContent();
|
|
5508
5575
|
});
|
|
5576
|
+
const onUpdateFn_0_props_symbol = createMemo(() => props.symbol);
|
|
5509
5577
|
function onUpdateFn_0() {
|
|
5510
5578
|
setContent();
|
|
5511
5579
|
}
|
|
5512
|
-
createEffect(on(() => [
|
|
5580
|
+
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
5513
5581
|
return (() => {
|
|
5514
5582
|
const _el$ = _tmpl$17();
|
|
5515
5583
|
spread(_el$, mergeProps({
|
|
@@ -5518,7 +5586,7 @@ function Symbol(props) {
|
|
|
5518
5586
|
}
|
|
5519
5587
|
}, {}, () => props.attributes, {}), false, true);
|
|
5520
5588
|
insert(_el$, createComponent(content_variants_default, {
|
|
5521
|
-
|
|
5589
|
+
isNestedRender: true,
|
|
5522
5590
|
get apiVersion() {
|
|
5523
5591
|
return props.builderContext.apiVersion;
|
|
5524
5592
|
},
|