@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/edge/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
|
|
|
5
5
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -285,7 +285,7 @@ function flattenState({
|
|
|
285
285
|
return localState[prop];
|
|
286
286
|
}
|
|
287
287
|
const val = target[prop];
|
|
288
|
-
if (typeof val === "object") {
|
|
288
|
+
if (typeof val === "object" && val !== null) {
|
|
289
289
|
return flattenState({
|
|
290
290
|
rootState: val,
|
|
291
291
|
localState: void 0,
|
|
@@ -3494,6 +3494,30 @@ var shouldForceBrowserRuntimeInNode = () => {
|
|
|
3494
3494
|
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3495
3495
|
|
|
3496
3496
|
// src/functions/evaluate/evaluate.ts
|
|
3497
|
+
var EvalCache = class _EvalCache {
|
|
3498
|
+
static cacheLimit = 20;
|
|
3499
|
+
static cache = /* @__PURE__ */ new Map();
|
|
3500
|
+
static getCacheKey(args) {
|
|
3501
|
+
return JSON.stringify({
|
|
3502
|
+
...args,
|
|
3503
|
+
// replace the event with a random number to break cache
|
|
3504
|
+
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
3505
|
+
event: args.event ? Math.random() : void 0
|
|
3506
|
+
});
|
|
3507
|
+
}
|
|
3508
|
+
static getCachedValue(key) {
|
|
3509
|
+
const cachedVal = _EvalCache.cache.get(key);
|
|
3510
|
+
return cachedVal;
|
|
3511
|
+
}
|
|
3512
|
+
static setCachedValue(key, value) {
|
|
3513
|
+
if (_EvalCache.cache.size > 20) {
|
|
3514
|
+
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
3515
|
+
}
|
|
3516
|
+
_EvalCache.cache.set(key, {
|
|
3517
|
+
value
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3497
3521
|
function evaluate({
|
|
3498
3522
|
code,
|
|
3499
3523
|
context,
|
|
@@ -3501,11 +3525,12 @@ function evaluate({
|
|
|
3501
3525
|
rootState,
|
|
3502
3526
|
rootSetState,
|
|
3503
3527
|
event,
|
|
3504
|
-
isExpression = true
|
|
3528
|
+
isExpression = true,
|
|
3529
|
+
enableCache
|
|
3505
3530
|
}) {
|
|
3506
3531
|
if (code === "") {
|
|
3507
3532
|
logger.warn("Skipping evaluation of empty code block.");
|
|
3508
|
-
return;
|
|
3533
|
+
return void 0;
|
|
3509
3534
|
}
|
|
3510
3535
|
const args = {
|
|
3511
3536
|
code: parseCode(code, {
|
|
@@ -3518,8 +3543,20 @@ function evaluate({
|
|
|
3518
3543
|
rootState,
|
|
3519
3544
|
localState
|
|
3520
3545
|
};
|
|
3546
|
+
if (enableCache) {
|
|
3547
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
3548
|
+
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
3549
|
+
if (cachedValue) {
|
|
3550
|
+
return cachedValue.value;
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3521
3553
|
try {
|
|
3522
|
-
|
|
3554
|
+
const newEval = chooseBrowserOrServerEval(args);
|
|
3555
|
+
if (enableCache) {
|
|
3556
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
3557
|
+
EvalCache.setCachedValue(cacheKey, newEval);
|
|
3558
|
+
}
|
|
3559
|
+
return newEval;
|
|
3523
3560
|
} catch (e) {
|
|
3524
3561
|
logger.error("Failed code evaluation: " + e.message, {
|
|
3525
3562
|
code
|
|
@@ -3564,7 +3601,8 @@ var evaluateBindings = ({
|
|
|
3564
3601
|
localState,
|
|
3565
3602
|
rootState,
|
|
3566
3603
|
rootSetState,
|
|
3567
|
-
context
|
|
3604
|
+
context,
|
|
3605
|
+
enableCache: true
|
|
3568
3606
|
});
|
|
3569
3607
|
set(copied, binding, value);
|
|
3570
3608
|
}
|
|
@@ -3797,6 +3835,70 @@ function bindScrollInViewAnimation(animation) {
|
|
|
3797
3835
|
});
|
|
3798
3836
|
}
|
|
3799
3837
|
|
|
3838
|
+
// src/functions/camel-to-kebab-case.ts
|
|
3839
|
+
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
3840
|
+
|
|
3841
|
+
// src/helpers/css.ts
|
|
3842
|
+
var convertStyleMapToCSSArray = (style) => {
|
|
3843
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3844
|
+
if (typeof value === "string") {
|
|
3845
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
3846
|
+
} else {
|
|
3847
|
+
return void 0;
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
return cssProps.filter(checkIsDefined);
|
|
3851
|
+
};
|
|
3852
|
+
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
3853
|
+
var createCssClass = ({
|
|
3854
|
+
mediaQuery,
|
|
3855
|
+
className,
|
|
3856
|
+
styles
|
|
3857
|
+
}) => {
|
|
3858
|
+
const cssClass = `.${className} {
|
|
3859
|
+
${convertStyleMapToCSS(styles)}
|
|
3860
|
+
}`;
|
|
3861
|
+
if (mediaQuery) {
|
|
3862
|
+
return `${mediaQuery} {
|
|
3863
|
+
${cssClass}
|
|
3864
|
+
}`;
|
|
3865
|
+
} else {
|
|
3866
|
+
return cssClass;
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
3869
|
+
|
|
3870
|
+
// src/functions/transform-style-property.ts
|
|
3871
|
+
function transformStyleProperty({
|
|
3872
|
+
style
|
|
3873
|
+
}) {
|
|
3874
|
+
return style;
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
// src/functions/get-style.ts
|
|
3878
|
+
var getStyle = ({
|
|
3879
|
+
block,
|
|
3880
|
+
context
|
|
3881
|
+
}) => {
|
|
3882
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
3883
|
+
style: block.style || {},
|
|
3884
|
+
context,
|
|
3885
|
+
block
|
|
3886
|
+
}));
|
|
3887
|
+
};
|
|
3888
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
3889
|
+
switch (TARGET) {
|
|
3890
|
+
case "svelte":
|
|
3891
|
+
case "vue":
|
|
3892
|
+
case "solid":
|
|
3893
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
3894
|
+
case "qwik":
|
|
3895
|
+
case "reactNative":
|
|
3896
|
+
case "react":
|
|
3897
|
+
case "rsc":
|
|
3898
|
+
return style;
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3800
3902
|
// src/components/block/block.helpers.ts
|
|
3801
3903
|
var getComponent = ({
|
|
3802
3904
|
block,
|
|
@@ -3837,7 +3939,8 @@ var getRepeatItemData = ({
|
|
|
3837
3939
|
localState: context.localState,
|
|
3838
3940
|
rootState: context.rootState,
|
|
3839
3941
|
rootSetState: context.rootSetState,
|
|
3840
|
-
context: context.context
|
|
3942
|
+
context: context.context,
|
|
3943
|
+
enableCache: true
|
|
3841
3944
|
});
|
|
3842
3945
|
if (!Array.isArray(itemsArray)) {
|
|
3843
3946
|
return void 0;
|
|
@@ -3908,38 +4011,6 @@ var getSizesForBreakpoints = ({
|
|
|
3908
4011
|
};
|
|
3909
4012
|
return newSizes;
|
|
3910
4013
|
};
|
|
3911
|
-
|
|
3912
|
-
// src/functions/camel-to-kebab-case.ts
|
|
3913
|
-
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
3914
|
-
|
|
3915
|
-
// src/helpers/css.ts
|
|
3916
|
-
var convertStyleMapToCSSArray = (style) => {
|
|
3917
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3918
|
-
if (typeof value === "string") {
|
|
3919
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
3920
|
-
} else {
|
|
3921
|
-
return void 0;
|
|
3922
|
-
}
|
|
3923
|
-
});
|
|
3924
|
-
return cssProps.filter(checkIsDefined);
|
|
3925
|
-
};
|
|
3926
|
-
var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
3927
|
-
var createCssClass = ({
|
|
3928
|
-
mediaQuery,
|
|
3929
|
-
className,
|
|
3930
|
-
styles
|
|
3931
|
-
}) => {
|
|
3932
|
-
const cssClass = `.${className} {
|
|
3933
|
-
${convertStyleMapToCSS(styles)}
|
|
3934
|
-
}`;
|
|
3935
|
-
if (mediaQuery) {
|
|
3936
|
-
return `${mediaQuery} {
|
|
3937
|
-
${cssClass}
|
|
3938
|
-
}`;
|
|
3939
|
-
} else {
|
|
3940
|
-
return cssClass;
|
|
3941
|
-
}
|
|
3942
|
-
};
|
|
3943
4014
|
var _tmpl$ = /* @__PURE__ */ template(`<style>`);
|
|
3944
4015
|
function InlinedStyles(props) {
|
|
3945
4016
|
return (() => {
|
|
@@ -3960,7 +4031,7 @@ var inlined_styles_default = InlinedStyles;
|
|
|
3960
4031
|
|
|
3961
4032
|
// src/components/block/components/block-styles.tsx
|
|
3962
4033
|
function BlockStyles(props) {
|
|
3963
|
-
|
|
4034
|
+
const canShowBlock = createMemo(() => {
|
|
3964
4035
|
const processedBlock = getProcessedBlock({
|
|
3965
4036
|
block: props.block,
|
|
3966
4037
|
localState: props.context.localState,
|
|
@@ -3976,8 +4047,8 @@ function BlockStyles(props) {
|
|
|
3976
4047
|
return processedBlock.show;
|
|
3977
4048
|
}
|
|
3978
4049
|
return true;
|
|
3979
|
-
}
|
|
3980
|
-
|
|
4050
|
+
});
|
|
4051
|
+
const css5 = createMemo(() => {
|
|
3981
4052
|
const processedBlock = getProcessedBlock({
|
|
3982
4053
|
block: props.block,
|
|
3983
4054
|
localState: props.context.localState,
|
|
@@ -4011,7 +4082,7 @@ function BlockStyles(props) {
|
|
|
4011
4082
|
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
|
|
4012
4083
|
}) : "";
|
|
4013
4084
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
4014
|
-
}
|
|
4085
|
+
});
|
|
4015
4086
|
return createComponent(Show, {
|
|
4016
4087
|
get when() {
|
|
4017
4088
|
return memo(() => !!(TARGET !== "reactNative" && css5()))() && canShowBlock();
|
|
@@ -4041,7 +4112,8 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
4041
4112
|
rootState: options.rootState,
|
|
4042
4113
|
rootSetState: options.rootSetState,
|
|
4043
4114
|
event,
|
|
4044
|
-
isExpression: false
|
|
4115
|
+
isExpression: false,
|
|
4116
|
+
enableCache: true
|
|
4045
4117
|
});
|
|
4046
4118
|
|
|
4047
4119
|
// src/functions/get-block-actions.ts
|
|
@@ -4069,38 +4141,6 @@ function getBlockActions(options) {
|
|
|
4069
4141
|
return obj;
|
|
4070
4142
|
}
|
|
4071
4143
|
|
|
4072
|
-
// src/functions/transform-style-property.ts
|
|
4073
|
-
function transformStyleProperty({
|
|
4074
|
-
style
|
|
4075
|
-
}) {
|
|
4076
|
-
return style;
|
|
4077
|
-
}
|
|
4078
|
-
|
|
4079
|
-
// src/functions/get-style.ts
|
|
4080
|
-
var getStyle = ({
|
|
4081
|
-
block,
|
|
4082
|
-
context
|
|
4083
|
-
}) => {
|
|
4084
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
4085
|
-
style: block.style || {},
|
|
4086
|
-
context,
|
|
4087
|
-
block
|
|
4088
|
-
}));
|
|
4089
|
-
};
|
|
4090
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
4091
|
-
switch (TARGET) {
|
|
4092
|
-
case "svelte":
|
|
4093
|
-
case "vue":
|
|
4094
|
-
case "solid":
|
|
4095
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
4096
|
-
case "qwik":
|
|
4097
|
-
case "reactNative":
|
|
4098
|
-
case "react":
|
|
4099
|
-
case "rsc":
|
|
4100
|
-
return style;
|
|
4101
|
-
}
|
|
4102
|
-
}
|
|
4103
|
-
|
|
4104
4144
|
// src/functions/transform-block-properties.ts
|
|
4105
4145
|
function transformBlockProperties({
|
|
4106
4146
|
properties
|
|
@@ -4302,21 +4342,20 @@ var repeated_block_default = RepeatedBlock;
|
|
|
4302
4342
|
|
|
4303
4343
|
// src/components/block/block.tsx
|
|
4304
4344
|
function Block(props) {
|
|
4305
|
-
const
|
|
4306
|
-
function blockComponent() {
|
|
4345
|
+
const blockComponent = createMemo(() => {
|
|
4307
4346
|
return getComponent({
|
|
4308
4347
|
block: props.block,
|
|
4309
4348
|
context: props.context,
|
|
4310
4349
|
registeredComponents: props.registeredComponents
|
|
4311
4350
|
});
|
|
4312
|
-
}
|
|
4313
|
-
|
|
4351
|
+
});
|
|
4352
|
+
const repeatItem = createMemo(() => {
|
|
4314
4353
|
return getRepeatItemData({
|
|
4315
4354
|
block: props.block,
|
|
4316
4355
|
context: props.context
|
|
4317
4356
|
});
|
|
4318
|
-
}
|
|
4319
|
-
|
|
4357
|
+
});
|
|
4358
|
+
const processedBlock = createMemo(() => {
|
|
4320
4359
|
return props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
4321
4360
|
block: props.block,
|
|
4322
4361
|
localState: props.context.localState,
|
|
@@ -4325,15 +4364,15 @@ function Block(props) {
|
|
|
4325
4364
|
context: props.context.context,
|
|
4326
4365
|
shouldEvaluateBindings: true
|
|
4327
4366
|
});
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4367
|
+
});
|
|
4368
|
+
const Tag = createMemo(() => {
|
|
4330
4369
|
const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
|
|
4331
4370
|
if (shouldUseLink) {
|
|
4332
4371
|
return props.linkComponent || "a";
|
|
4333
4372
|
}
|
|
4334
4373
|
return props.block.tagName || "div";
|
|
4335
|
-
}
|
|
4336
|
-
|
|
4374
|
+
});
|
|
4375
|
+
const canShowBlock = createMemo(() => {
|
|
4337
4376
|
if (props.block.repeat?.collection) {
|
|
4338
4377
|
if (repeatItem()?.length)
|
|
4339
4378
|
return true;
|
|
@@ -4342,12 +4381,12 @@ function Block(props) {
|
|
|
4342
4381
|
const shouldHide = "hide" in processedBlock() ? processedBlock().hide : false;
|
|
4343
4382
|
const shouldShow = "show" in processedBlock() ? processedBlock().show : true;
|
|
4344
4383
|
return shouldShow && !shouldHide;
|
|
4345
|
-
}
|
|
4346
|
-
|
|
4384
|
+
});
|
|
4385
|
+
const childrenWithoutParentComponent = createMemo(() => {
|
|
4347
4386
|
const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
|
|
4348
4387
|
return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4388
|
+
});
|
|
4389
|
+
const componentRefProps = createMemo(() => {
|
|
4351
4390
|
return {
|
|
4352
4391
|
blockChildren: processedBlock().children ?? [],
|
|
4353
4392
|
componentRef: blockComponent()?.component,
|
|
@@ -4361,14 +4400,14 @@ function Block(props) {
|
|
|
4361
4400
|
builderComponents: props.registeredComponents
|
|
4362
4401
|
} : {}
|
|
4363
4402
|
},
|
|
4364
|
-
context:
|
|
4403
|
+
context: props.context,
|
|
4365
4404
|
linkComponent: props.linkComponent,
|
|
4366
4405
|
registeredComponents: props.registeredComponents,
|
|
4367
4406
|
builderBlock: processedBlock(),
|
|
4368
4407
|
includeBlockProps: blockComponent()?.noWrap === true,
|
|
4369
4408
|
isInteractive: !blockComponent()?.isRSC
|
|
4370
4409
|
};
|
|
4371
|
-
}
|
|
4410
|
+
});
|
|
4372
4411
|
onMount(() => {
|
|
4373
4412
|
const blockId = processedBlock().id;
|
|
4374
4413
|
const animations = processedBlock().animations;
|
|
@@ -4510,14 +4549,14 @@ function Block(props) {
|
|
|
4510
4549
|
return child.id;
|
|
4511
4550
|
},
|
|
4512
4551
|
block: child,
|
|
4513
|
-
get context() {
|
|
4514
|
-
return childrenContext();
|
|
4515
|
-
},
|
|
4516
4552
|
get registeredComponents() {
|
|
4517
4553
|
return props.registeredComponents;
|
|
4518
4554
|
},
|
|
4519
4555
|
get linkComponent() {
|
|
4520
4556
|
return props.linkComponent;
|
|
4557
|
+
},
|
|
4558
|
+
get context() {
|
|
4559
|
+
return props.context;
|
|
4521
4560
|
}
|
|
4522
4561
|
});
|
|
4523
4562
|
}
|
|
@@ -4533,9 +4572,9 @@ function Block(props) {
|
|
|
4533
4572
|
}
|
|
4534
4573
|
var block_default = Block;
|
|
4535
4574
|
function BlocksWrapper(props) {
|
|
4536
|
-
|
|
4575
|
+
const className = createMemo(() => {
|
|
4537
4576
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
4538
|
-
}
|
|
4577
|
+
});
|
|
4539
4578
|
function onClick() {
|
|
4540
4579
|
if (isEditing() && !props.blocks?.length) {
|
|
4541
4580
|
window.parent?.postMessage({
|
|
@@ -4675,7 +4714,7 @@ function Columns(props) {
|
|
|
4675
4714
|
}) {
|
|
4676
4715
|
return stackAt() === "never" ? desktopStyle : stackedStyle;
|
|
4677
4716
|
}
|
|
4678
|
-
|
|
4717
|
+
const columnsCssVars = createMemo(() => {
|
|
4679
4718
|
return {
|
|
4680
4719
|
"--flex-dir": flexDir(),
|
|
4681
4720
|
"--flex-dir-tablet": getTabletStyle({
|
|
@@ -4683,7 +4722,7 @@ function Columns(props) {
|
|
|
4683
4722
|
desktopStyle: "row"
|
|
4684
4723
|
})
|
|
4685
4724
|
};
|
|
4686
|
-
}
|
|
4725
|
+
});
|
|
4687
4726
|
function columnCssVars(index) {
|
|
4688
4727
|
const gutter = index === 0 ? 0 : gutterSize();
|
|
4689
4728
|
const width = getColumnCssWidth(index);
|
|
@@ -4722,7 +4761,7 @@ function Columns(props) {
|
|
|
4722
4761
|
const breakpointSizes = getSizesForBreakpoints(props.builderContext.content?.meta?.breakpoints || {});
|
|
4723
4762
|
return breakpointSizes[size].max;
|
|
4724
4763
|
}
|
|
4725
|
-
|
|
4764
|
+
const columnsStyles = createMemo(() => {
|
|
4726
4765
|
return `
|
|
4727
4766
|
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
4728
4767
|
.${props.builderBlock.id}-breakpoints {
|
|
@@ -4748,7 +4787,7 @@ function Columns(props) {
|
|
|
4748
4787
|
}
|
|
4749
4788
|
},
|
|
4750
4789
|
`;
|
|
4751
|
-
}
|
|
4790
|
+
});
|
|
4752
4791
|
return (() => {
|
|
4753
4792
|
const _el$ = _tmpl$2();
|
|
4754
4793
|
spread(_el$, mergeProps({
|
|
@@ -4886,7 +4925,7 @@ var _tmpl$4 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
|
4886
4925
|
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
|
|
4887
4926
|
var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
|
|
4888
4927
|
function Image(props) {
|
|
4889
|
-
|
|
4928
|
+
const srcSetToUse = createMemo(() => {
|
|
4890
4929
|
const imageToUse = props.image || props.src;
|
|
4891
4930
|
const url = imageToUse;
|
|
4892
4931
|
if (!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
@@ -4902,15 +4941,15 @@ function Image(props) {
|
|
|
4902
4941
|
return getSrcSet(url);
|
|
4903
4942
|
}
|
|
4904
4943
|
return getSrcSet(url);
|
|
4905
|
-
}
|
|
4906
|
-
|
|
4944
|
+
});
|
|
4945
|
+
const webpSrcSet = createMemo(() => {
|
|
4907
4946
|
if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
|
|
4908
4947
|
return srcSetToUse().replace(/\?/g, "?format=webp&");
|
|
4909
4948
|
} else {
|
|
4910
4949
|
return "";
|
|
4911
4950
|
}
|
|
4912
|
-
}
|
|
4913
|
-
|
|
4951
|
+
});
|
|
4952
|
+
const aspectRatioCss = createMemo(() => {
|
|
4914
4953
|
const aspectRatioStyles = {
|
|
4915
4954
|
position: "absolute",
|
|
4916
4955
|
height: "100%",
|
|
@@ -4920,7 +4959,7 @@ function Image(props) {
|
|
|
4920
4959
|
};
|
|
4921
4960
|
const out = props.aspectRatio ? aspectRatioStyles : void 0;
|
|
4922
4961
|
return out;
|
|
4923
|
-
}
|
|
4962
|
+
});
|
|
4924
4963
|
return [(() => {
|
|
4925
4964
|
const _el$ = _tmpl$22(), _el$3 = _el$.firstChild;
|
|
4926
4965
|
insert(_el$, createComponent(Show, {
|
|
@@ -5910,13 +5949,15 @@ function Embed(props) {
|
|
|
5910
5949
|
}
|
|
5911
5950
|
}
|
|
5912
5951
|
let elem;
|
|
5952
|
+
const onUpdateFn_0_elem = createMemo(() => elem);
|
|
5953
|
+
const onUpdateFn_0_ranInitFn__ = createMemo(() => ranInitFn());
|
|
5913
5954
|
function onUpdateFn_0() {
|
|
5914
5955
|
if (elem && !ranInitFn()) {
|
|
5915
5956
|
setRanInitFn(true);
|
|
5916
5957
|
findAndRunScripts();
|
|
5917
5958
|
}
|
|
5918
5959
|
}
|
|
5919
|
-
createEffect(on(() => [
|
|
5960
|
+
createEffect(on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0));
|
|
5920
5961
|
return (() => {
|
|
5921
5962
|
const _el$ = _tmpl$9();
|
|
5922
5963
|
const _ref$ = elem;
|
|
@@ -6810,7 +6851,7 @@ var _tmpl$15 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
|
6810
6851
|
var _tmpl$25 = /* @__PURE__ */ template(`<div>`);
|
|
6811
6852
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
6812
6853
|
function Video(props) {
|
|
6813
|
-
|
|
6854
|
+
const videoProps = createMemo(() => {
|
|
6814
6855
|
return {
|
|
6815
6856
|
...props.autoPlay === true ? {
|
|
6816
6857
|
autoPlay: true
|
|
@@ -6828,12 +6869,12 @@ function Video(props) {
|
|
|
6828
6869
|
playsInline: true
|
|
6829
6870
|
} : {}
|
|
6830
6871
|
};
|
|
6831
|
-
}
|
|
6832
|
-
|
|
6872
|
+
});
|
|
6873
|
+
const spreadProps = createMemo(() => {
|
|
6833
6874
|
return {
|
|
6834
6875
|
...videoProps()
|
|
6835
6876
|
};
|
|
6836
|
-
}
|
|
6877
|
+
});
|
|
6837
6878
|
return (() => {
|
|
6838
6879
|
const _el$ = _tmpl$33(), _el$2 = _el$.firstChild;
|
|
6839
6880
|
_el$.style.setProperty("position", "relative");
|
|
@@ -7543,7 +7584,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
7543
7584
|
}
|
|
7544
7585
|
|
|
7545
7586
|
// src/constants/sdk-version.ts
|
|
7546
|
-
var SDK_VERSION = "0.
|
|
7587
|
+
var SDK_VERSION = "1.0.13";
|
|
7547
7588
|
|
|
7548
7589
|
// src/functions/register.ts
|
|
7549
7590
|
var registry = {};
|
|
@@ -7821,7 +7862,11 @@ function EnableEditor(props) {
|
|
|
7821
7862
|
context: props.context || {},
|
|
7822
7863
|
localState: void 0,
|
|
7823
7864
|
rootState: props.builderContextSignal.rootState,
|
|
7824
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
7865
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
7866
|
+
/**
|
|
7867
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
7868
|
+
*/
|
|
7869
|
+
enableCache: false
|
|
7825
7870
|
});
|
|
7826
7871
|
}
|
|
7827
7872
|
}
|
|
@@ -7844,13 +7889,14 @@ function EnableEditor(props) {
|
|
|
7844
7889
|
}
|
|
7845
7890
|
}
|
|
7846
7891
|
function evalExpression(expression) {
|
|
7847
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
7892
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
7848
7893
|
code: group,
|
|
7849
7894
|
context: props.context || {},
|
|
7850
7895
|
localState: void 0,
|
|
7851
7896
|
rootState: props.builderContextSignal.rootState,
|
|
7852
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
7853
|
-
|
|
7897
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
7898
|
+
enableCache: true
|
|
7899
|
+
})));
|
|
7854
7900
|
}
|
|
7855
7901
|
function handleRequest({
|
|
7856
7902
|
url,
|
|
@@ -7954,33 +8000,40 @@ function EnableEditor(props) {
|
|
|
7954
8000
|
runHttpRequests();
|
|
7955
8001
|
emitStateUpdate();
|
|
7956
8002
|
});
|
|
8003
|
+
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
7957
8004
|
function onUpdateFn_0() {
|
|
7958
8005
|
if (props.content) {
|
|
7959
8006
|
mergeNewContent(props.content);
|
|
7960
8007
|
}
|
|
7961
8008
|
}
|
|
7962
|
-
createEffect(on(() => [
|
|
8009
|
+
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
8010
|
+
const onUpdateFn_1_shouldSendResetCookie__ = createMemo(() => shouldSendResetCookie());
|
|
7963
8011
|
function onUpdateFn_1() {
|
|
7964
8012
|
}
|
|
7965
|
-
createEffect(on(() => [
|
|
8013
|
+
createEffect(on(() => [onUpdateFn_1_shouldSendResetCookie__()], onUpdateFn_1));
|
|
8014
|
+
const onUpdateFn_2_props_builderContextSignal_content__data__jsCode = createMemo(() => props.builderContextSignal.content?.data?.jsCode);
|
|
7966
8015
|
function onUpdateFn_2() {
|
|
7967
8016
|
evaluateJsCode();
|
|
7968
8017
|
}
|
|
7969
|
-
createEffect(on(() => [
|
|
8018
|
+
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__jsCode()], onUpdateFn_2));
|
|
8019
|
+
const onUpdateFn_3_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
7970
8020
|
function onUpdateFn_3() {
|
|
7971
8021
|
runHttpRequests();
|
|
7972
8022
|
}
|
|
7973
|
-
createEffect(on(() => [
|
|
8023
|
+
createEffect(on(() => [onUpdateFn_3_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_3));
|
|
8024
|
+
const onUpdateFn_4_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
7974
8025
|
function onUpdateFn_4() {
|
|
7975
8026
|
emitStateUpdate();
|
|
7976
8027
|
}
|
|
7977
|
-
createEffect(on(() => [
|
|
8028
|
+
createEffect(on(() => [onUpdateFn_4_props_builderContextSignal_rootState()], onUpdateFn_4));
|
|
8029
|
+
const onUpdateFn_5_props_data = createMemo(() => props.data);
|
|
7978
8030
|
function onUpdateFn_5() {
|
|
7979
8031
|
if (props.data) {
|
|
7980
8032
|
mergeNewRootState(props.data);
|
|
7981
8033
|
}
|
|
7982
8034
|
}
|
|
7983
|
-
createEffect(on(() => [
|
|
8035
|
+
createEffect(on(() => [onUpdateFn_5_props_data()], onUpdateFn_5));
|
|
8036
|
+
const onUpdateFn_6_props_locale = createMemo(() => props.locale);
|
|
7984
8037
|
function onUpdateFn_6() {
|
|
7985
8038
|
if (props.locale) {
|
|
7986
8039
|
mergeNewRootState({
|
|
@@ -7988,7 +8041,7 @@ function EnableEditor(props) {
|
|
|
7988
8041
|
});
|
|
7989
8042
|
}
|
|
7990
8043
|
}
|
|
7991
|
-
createEffect(on(() => [
|
|
8044
|
+
createEffect(on(() => [onUpdateFn_6_props_locale()], onUpdateFn_6));
|
|
7992
8045
|
return createComponent(builder_context_default.Provider, {
|
|
7993
8046
|
get value() {
|
|
7994
8047
|
return props.builderContextSignal;
|
|
@@ -8090,18 +8143,7 @@ var getCss = ({
|
|
|
8090
8143
|
}
|
|
8091
8144
|
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
8092
8145
|
};
|
|
8093
|
-
|
|
8094
|
-
// src/components/content/components/styles.tsx
|
|
8095
|
-
function ContentStyles(props) {
|
|
8096
|
-
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
8097
|
-
${getCss({
|
|
8098
|
-
cssCode: props.cssCode,
|
|
8099
|
-
contentId: props.contentId
|
|
8100
|
-
})}
|
|
8101
|
-
${getFontCss({
|
|
8102
|
-
customFonts: props.customFonts
|
|
8103
|
-
})}
|
|
8104
|
-
|
|
8146
|
+
var DEFAULT_STYLES = `
|
|
8105
8147
|
.builder-button {
|
|
8106
8148
|
all: unset;
|
|
8107
8149
|
}
|
|
@@ -8118,6 +8160,22 @@ ${getFontCss({
|
|
|
8118
8160
|
text-align: inherit;
|
|
8119
8161
|
font-family: inherit;
|
|
8120
8162
|
}
|
|
8163
|
+
`;
|
|
8164
|
+
var getDefaultStyles = (isNested) => {
|
|
8165
|
+
return !isNested ? DEFAULT_STYLES : "";
|
|
8166
|
+
};
|
|
8167
|
+
|
|
8168
|
+
// src/components/content/components/styles.tsx
|
|
8169
|
+
function ContentStyles(props) {
|
|
8170
|
+
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
8171
|
+
${getCss({
|
|
8172
|
+
cssCode: props.cssCode,
|
|
8173
|
+
contentId: props.contentId
|
|
8174
|
+
})}
|
|
8175
|
+
${getFontCss({
|
|
8176
|
+
customFonts: props.customFonts
|
|
8177
|
+
})}
|
|
8178
|
+
${getDefaultStyles(props.isNestedRender)}
|
|
8121
8179
|
`.trim());
|
|
8122
8180
|
return createComponent(inlined_styles_default, {
|
|
8123
8181
|
get styles() {
|
|
@@ -8282,6 +8340,9 @@ function ContentComponent(props) {
|
|
|
8282
8340
|
when: TARGET !== "reactNative",
|
|
8283
8341
|
get children() {
|
|
8284
8342
|
return createComponent(styles_default, {
|
|
8343
|
+
get isNestedRender() {
|
|
8344
|
+
return props.isNestedRender;
|
|
8345
|
+
},
|
|
8285
8346
|
get contentId() {
|
|
8286
8347
|
return builderContextSignal().content?.id;
|
|
8287
8348
|
},
|
|
@@ -8320,16 +8381,16 @@ function ContentVariants(props) {
|
|
|
8320
8381
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
8321
8382
|
content: props.content
|
|
8322
8383
|
}));
|
|
8323
|
-
|
|
8384
|
+
const updateCookieAndStylesScriptStr = createMemo(() => {
|
|
8324
8385
|
return getUpdateCookieAndStylesScript(getVariants(props.content).map((value) => ({
|
|
8325
8386
|
id: value.testVariationId,
|
|
8326
8387
|
testRatio: value.testRatio
|
|
8327
8388
|
})), props.content?.id || "");
|
|
8328
|
-
}
|
|
8329
|
-
|
|
8389
|
+
});
|
|
8390
|
+
const hideVariantsStyleString = createMemo(() => {
|
|
8330
8391
|
return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
|
|
8331
|
-
}
|
|
8332
|
-
|
|
8392
|
+
});
|
|
8393
|
+
const defaultContent = createMemo(() => {
|
|
8333
8394
|
return shouldRenderVariants() ? {
|
|
8334
8395
|
...props.content,
|
|
8335
8396
|
testVariationId: props.content?.id
|
|
@@ -8337,13 +8398,13 @@ function ContentVariants(props) {
|
|
|
8337
8398
|
item: props.content,
|
|
8338
8399
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
8339
8400
|
});
|
|
8340
|
-
}
|
|
8401
|
+
});
|
|
8341
8402
|
onMount(() => {
|
|
8342
8403
|
setShouldRenderVariants(false);
|
|
8343
8404
|
});
|
|
8344
8405
|
return [createComponent(Show, {
|
|
8345
8406
|
get when() {
|
|
8346
|
-
return !props.
|
|
8407
|
+
return !props.isNestedRender && TARGET !== "reactNative";
|
|
8347
8408
|
},
|
|
8348
8409
|
get children() {
|
|
8349
8410
|
return createComponent(inlined_script_default, {
|
|
@@ -8375,6 +8436,9 @@ function ContentVariants(props) {
|
|
|
8375
8436
|
children: (variant, _index) => {
|
|
8376
8437
|
_index();
|
|
8377
8438
|
return createComponent(content_default, {
|
|
8439
|
+
get isNestedRender() {
|
|
8440
|
+
return props.isNestedRender;
|
|
8441
|
+
},
|
|
8378
8442
|
get key() {
|
|
8379
8443
|
return variant.testVariationId;
|
|
8380
8444
|
},
|
|
@@ -8432,7 +8496,11 @@ function ContentVariants(props) {
|
|
|
8432
8496
|
}
|
|
8433
8497
|
})];
|
|
8434
8498
|
}
|
|
8435
|
-
}), createComponent(content_default, mergeProps({
|
|
8499
|
+
}), createComponent(content_default, mergeProps({
|
|
8500
|
+
get isNestedRender() {
|
|
8501
|
+
return props.isNestedRender;
|
|
8502
|
+
}
|
|
8503
|
+
}, {}, {
|
|
8436
8504
|
get content() {
|
|
8437
8505
|
return defaultContent();
|
|
8438
8506
|
},
|
|
@@ -8517,9 +8585,9 @@ var fetchSymbolContent = async ({
|
|
|
8517
8585
|
var _tmpl$17 = /* @__PURE__ */ template(`<div>`);
|
|
8518
8586
|
function Symbol2(props) {
|
|
8519
8587
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
8520
|
-
|
|
8588
|
+
const className = createMemo(() => {
|
|
8521
8589
|
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(" ");
|
|
8522
|
-
}
|
|
8590
|
+
});
|
|
8523
8591
|
function setContent() {
|
|
8524
8592
|
if (contentToUse())
|
|
8525
8593
|
return;
|
|
@@ -8533,12 +8601,12 @@ function Symbol2(props) {
|
|
|
8533
8601
|
});
|
|
8534
8602
|
}
|
|
8535
8603
|
onMount(() => {
|
|
8536
|
-
setContent();
|
|
8537
8604
|
});
|
|
8605
|
+
const onUpdateFn_0_props_symbol = createMemo(() => props.symbol);
|
|
8538
8606
|
function onUpdateFn_0() {
|
|
8539
8607
|
setContent();
|
|
8540
8608
|
}
|
|
8541
|
-
createEffect(on(() => [
|
|
8609
|
+
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
8542
8610
|
return (() => {
|
|
8543
8611
|
const _el$ = _tmpl$17();
|
|
8544
8612
|
spread(_el$, mergeProps({
|
|
@@ -8547,7 +8615,7 @@ function Symbol2(props) {
|
|
|
8547
8615
|
}
|
|
8548
8616
|
}, {}, () => props.attributes, {}), false, true);
|
|
8549
8617
|
insert(_el$, createComponent(content_variants_default, {
|
|
8550
|
-
|
|
8618
|
+
isNestedRender: true,
|
|
8551
8619
|
get apiVersion() {
|
|
8552
8620
|
return props.builderContext.apiVersion;
|
|
8553
8621
|
},
|