@builder.io/sdk-solid 0.12.5 → 0.12.7
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 +18 -1
- package/lib/browser/dev.js +248 -12
- package/lib/browser/dev.jsx +260 -28
- package/lib/browser/index.js +247 -12
- package/lib/browser/index.jsx +259 -28
- package/lib/edge/dev.js +248 -12
- package/lib/edge/dev.jsx +260 -28
- package/lib/edge/index.js +247 -12
- package/lib/edge/index.jsx +259 -28
- package/lib/node/dev.js +248 -12
- package/lib/node/dev.jsx +260 -28
- package/lib/node/index.js +247 -12
- package/lib/node/index.jsx +259 -28
- package/package.json +1 -1
package/lib/edge/dev.jsx
CHANGED
|
@@ -107,7 +107,7 @@ import { createContext as createContext2 } from "solid-js";
|
|
|
107
107
|
var components_context_default = createContext2({ registeredComponents: {} });
|
|
108
108
|
|
|
109
109
|
// src/components/block/block.tsx
|
|
110
|
-
import { Show as Show4, For as For2, createSignal as createSignal4 } from "solid-js";
|
|
110
|
+
import { Show as Show4, For as For2, onMount, createSignal as createSignal4 } from "solid-js";
|
|
111
111
|
|
|
112
112
|
// src/functions/get-block-component-options.ts
|
|
113
113
|
function getBlockComponentOptions(block) {
|
|
@@ -239,27 +239,43 @@ var runInBrowser = ({
|
|
|
239
239
|
builder,
|
|
240
240
|
context,
|
|
241
241
|
event,
|
|
242
|
-
state: flattenState(
|
|
242
|
+
state: flattenState({
|
|
243
|
+
rootState,
|
|
244
|
+
localState,
|
|
245
|
+
rootSetState
|
|
246
|
+
})
|
|
243
247
|
});
|
|
244
248
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
245
249
|
};
|
|
246
|
-
function flattenState(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
function flattenState({
|
|
251
|
+
rootState,
|
|
252
|
+
localState,
|
|
253
|
+
rootSetState
|
|
254
|
+
}) {
|
|
250
255
|
return new Proxy(rootState, {
|
|
251
|
-
get: (
|
|
256
|
+
get: (target, prop) => {
|
|
252
257
|
if (localState && prop in localState) {
|
|
253
258
|
return localState[prop];
|
|
254
259
|
}
|
|
255
|
-
|
|
260
|
+
const val = target[prop];
|
|
261
|
+
if (typeof val === "object") {
|
|
262
|
+
return flattenState({
|
|
263
|
+
rootState: val,
|
|
264
|
+
localState: void 0,
|
|
265
|
+
rootSetState: rootSetState ? (subState) => {
|
|
266
|
+
target[prop] = subState;
|
|
267
|
+
rootSetState(target);
|
|
268
|
+
} : void 0
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return val;
|
|
256
272
|
},
|
|
257
|
-
set: (
|
|
273
|
+
set: (target, prop, value) => {
|
|
258
274
|
if (localState && prop in localState) {
|
|
259
275
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
260
276
|
}
|
|
261
|
-
|
|
262
|
-
rootSetState?.(
|
|
277
|
+
target[prop] = value;
|
|
278
|
+
rootSetState?.(target);
|
|
263
279
|
return true;
|
|
264
280
|
}
|
|
265
281
|
});
|
|
@@ -3549,6 +3565,212 @@ function getProcessedBlock({
|
|
|
3549
3565
|
}
|
|
3550
3566
|
}
|
|
3551
3567
|
|
|
3568
|
+
// src/components/block/animator.ts
|
|
3569
|
+
function throttle(func, wait, options = {}) {
|
|
3570
|
+
let context;
|
|
3571
|
+
let args;
|
|
3572
|
+
let result;
|
|
3573
|
+
let timeout = null;
|
|
3574
|
+
let previous = 0;
|
|
3575
|
+
const later = function() {
|
|
3576
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
3577
|
+
timeout = null;
|
|
3578
|
+
result = func.apply(context, args);
|
|
3579
|
+
if (!timeout)
|
|
3580
|
+
context = args = null;
|
|
3581
|
+
};
|
|
3582
|
+
return function() {
|
|
3583
|
+
const now = Date.now();
|
|
3584
|
+
if (!previous && options.leading === false)
|
|
3585
|
+
previous = now;
|
|
3586
|
+
const remaining = wait - (now - previous);
|
|
3587
|
+
context = this;
|
|
3588
|
+
args = arguments;
|
|
3589
|
+
if (remaining <= 0 || remaining > wait) {
|
|
3590
|
+
if (timeout) {
|
|
3591
|
+
clearTimeout(timeout);
|
|
3592
|
+
timeout = null;
|
|
3593
|
+
}
|
|
3594
|
+
previous = now;
|
|
3595
|
+
result = func.apply(context, args);
|
|
3596
|
+
if (!timeout)
|
|
3597
|
+
context = args = null;
|
|
3598
|
+
} else if (!timeout && options.trailing !== false) {
|
|
3599
|
+
timeout = setTimeout(later, remaining);
|
|
3600
|
+
}
|
|
3601
|
+
return result;
|
|
3602
|
+
};
|
|
3603
|
+
}
|
|
3604
|
+
function assign(target, ..._args) {
|
|
3605
|
+
const to = Object(target);
|
|
3606
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
3607
|
+
const nextSource = arguments[index];
|
|
3608
|
+
if (nextSource != null) {
|
|
3609
|
+
for (const nextKey in nextSource) {
|
|
3610
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
3611
|
+
to[nextKey] = nextSource[nextKey];
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
return to;
|
|
3617
|
+
}
|
|
3618
|
+
var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
3619
|
+
function bindAnimations(animations) {
|
|
3620
|
+
for (const animation of animations) {
|
|
3621
|
+
switch (animation.trigger) {
|
|
3622
|
+
case "pageLoad":
|
|
3623
|
+
triggerAnimation(animation);
|
|
3624
|
+
break;
|
|
3625
|
+
case "hover":
|
|
3626
|
+
bindHoverAnimation(animation);
|
|
3627
|
+
break;
|
|
3628
|
+
case "scrollInView":
|
|
3629
|
+
bindScrollInViewAnimation(animation);
|
|
3630
|
+
break;
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
function warnElementNotPresent(id2) {
|
|
3635
|
+
console.warn(`Cannot animate element: element with ID ${id2} not found!`);
|
|
3636
|
+
}
|
|
3637
|
+
function augmentAnimation(animation, element) {
|
|
3638
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
3639
|
+
const computedStyle = getComputedStyle(element);
|
|
3640
|
+
const firstStyles = animation.steps[0].styles;
|
|
3641
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
3642
|
+
const bothStyles = [firstStyles, lastStyles];
|
|
3643
|
+
for (const styles of bothStyles) {
|
|
3644
|
+
for (const style of stylesUsed) {
|
|
3645
|
+
if (!(style in styles)) {
|
|
3646
|
+
styles[style] = computedStyle[style];
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
function getAllStylesUsed(animation) {
|
|
3652
|
+
const properties = [];
|
|
3653
|
+
for (const step of animation.steps) {
|
|
3654
|
+
for (const key in step.styles) {
|
|
3655
|
+
if (properties.indexOf(key) === -1) {
|
|
3656
|
+
properties.push(key);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
return properties;
|
|
3661
|
+
}
|
|
3662
|
+
function triggerAnimation(animation) {
|
|
3663
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3664
|
+
if (!elements.length) {
|
|
3665
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3666
|
+
return;
|
|
3667
|
+
}
|
|
3668
|
+
Array.from(elements).forEach((element) => {
|
|
3669
|
+
augmentAnimation(animation, element);
|
|
3670
|
+
element.style.transition = "none";
|
|
3671
|
+
element.style.transitionDelay = "0";
|
|
3672
|
+
assign(element.style, animation.steps[0].styles);
|
|
3673
|
+
setTimeout(() => {
|
|
3674
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3675
|
+
if (animation.delay) {
|
|
3676
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3677
|
+
}
|
|
3678
|
+
assign(element.style, animation.steps[1].styles);
|
|
3679
|
+
setTimeout(() => {
|
|
3680
|
+
element.style.transition = "";
|
|
3681
|
+
element.style.transitionDelay = "";
|
|
3682
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
3683
|
+
});
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
function bindHoverAnimation(animation) {
|
|
3687
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3688
|
+
if (!elements.length) {
|
|
3689
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3690
|
+
return;
|
|
3691
|
+
}
|
|
3692
|
+
Array.from(elements).forEach((element) => {
|
|
3693
|
+
augmentAnimation(animation, element);
|
|
3694
|
+
const defaultState = animation.steps[0].styles;
|
|
3695
|
+
const hoverState = animation.steps[1].styles;
|
|
3696
|
+
function attachDefaultState() {
|
|
3697
|
+
assign(element.style, defaultState);
|
|
3698
|
+
}
|
|
3699
|
+
function attachHoverState() {
|
|
3700
|
+
assign(element.style, hoverState);
|
|
3701
|
+
}
|
|
3702
|
+
attachDefaultState();
|
|
3703
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
3704
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
3705
|
+
setTimeout(() => {
|
|
3706
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3707
|
+
if (animation.delay) {
|
|
3708
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3709
|
+
}
|
|
3710
|
+
});
|
|
3711
|
+
});
|
|
3712
|
+
}
|
|
3713
|
+
function bindScrollInViewAnimation(animation) {
|
|
3714
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3715
|
+
if (!elements.length) {
|
|
3716
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3717
|
+
return;
|
|
3718
|
+
}
|
|
3719
|
+
Array.from(elements).forEach((element) => {
|
|
3720
|
+
augmentAnimation(animation, element);
|
|
3721
|
+
let triggered = false;
|
|
3722
|
+
let pendingAnimation = false;
|
|
3723
|
+
function immediateOnScroll() {
|
|
3724
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
3725
|
+
triggered = true;
|
|
3726
|
+
pendingAnimation = true;
|
|
3727
|
+
setTimeout(() => {
|
|
3728
|
+
assign(element.style, animation.steps[1].styles);
|
|
3729
|
+
if (!animation.repeat) {
|
|
3730
|
+
document.removeEventListener("scroll", onScroll);
|
|
3731
|
+
}
|
|
3732
|
+
setTimeout(() => {
|
|
3733
|
+
pendingAnimation = false;
|
|
3734
|
+
if (!animation.repeat) {
|
|
3735
|
+
element.style.transition = "";
|
|
3736
|
+
element.style.transitionDelay = "";
|
|
3737
|
+
}
|
|
3738
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
3739
|
+
});
|
|
3740
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
3741
|
+
triggered = false;
|
|
3742
|
+
assign(element.style, animation.steps[0].styles);
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
3746
|
+
leading: false
|
|
3747
|
+
});
|
|
3748
|
+
function isScrolledIntoView(elem) {
|
|
3749
|
+
const rect = elem.getBoundingClientRect();
|
|
3750
|
+
const windowHeight = window.innerHeight;
|
|
3751
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
3752
|
+
const threshold = thresholdPercent * windowHeight;
|
|
3753
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
3754
|
+
}
|
|
3755
|
+
const defaultState = animation.steps[0].styles;
|
|
3756
|
+
function attachDefaultState() {
|
|
3757
|
+
assign(element.style, defaultState);
|
|
3758
|
+
}
|
|
3759
|
+
attachDefaultState();
|
|
3760
|
+
setTimeout(() => {
|
|
3761
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3762
|
+
if (animation.delay) {
|
|
3763
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3764
|
+
}
|
|
3765
|
+
});
|
|
3766
|
+
document.addEventListener("scroll", onScroll, {
|
|
3767
|
+
capture: true,
|
|
3768
|
+
passive: true
|
|
3769
|
+
});
|
|
3770
|
+
immediateOnScroll();
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3552
3774
|
// src/components/block/block.helpers.ts
|
|
3553
3775
|
var getComponent = ({
|
|
3554
3776
|
block,
|
|
@@ -4071,6 +4293,18 @@ function Block(props) {
|
|
|
4071
4293
|
isInteractive: !blockComponent()?.isRSC
|
|
4072
4294
|
};
|
|
4073
4295
|
}
|
|
4296
|
+
onMount(() => {
|
|
4297
|
+
const blockId = processedBlock().id;
|
|
4298
|
+
const animations = processedBlock().animations;
|
|
4299
|
+
if (animations && blockId) {
|
|
4300
|
+
bindAnimations(
|
|
4301
|
+
animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
4302
|
+
...animation,
|
|
4303
|
+
elementId: blockId
|
|
4304
|
+
}))
|
|
4305
|
+
);
|
|
4306
|
+
}
|
|
4307
|
+
});
|
|
4074
4308
|
return <Show4 when={canShowBlock()}>
|
|
4075
4309
|
<Block_styles_default block={props.block} context={props.context} />
|
|
4076
4310
|
<Show4
|
|
@@ -4519,10 +4753,10 @@ function SectionComponent(props) {
|
|
|
4519
4753
|
var section_default = SectionComponent;
|
|
4520
4754
|
|
|
4521
4755
|
// src/blocks/symbol/symbol.tsx
|
|
4522
|
-
import { onMount as
|
|
4756
|
+
import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
|
|
4523
4757
|
|
|
4524
4758
|
// src/components/content-variants/content-variants.tsx
|
|
4525
|
-
import { Show as Show11, For as For5, onMount as
|
|
4759
|
+
import { Show as Show11, For as For5, onMount as onMount4, createSignal as createSignal13 } from "solid-js";
|
|
4526
4760
|
|
|
4527
4761
|
// src/helpers/url.ts
|
|
4528
4762
|
var getTopLevelDomain = (host) => {
|
|
@@ -5000,12 +5234,12 @@ var componentInfo3 = {
|
|
|
5000
5234
|
};
|
|
5001
5235
|
|
|
5002
5236
|
// src/blocks/custom-code/custom-code.tsx
|
|
5003
|
-
import { onMount, createSignal as createSignal7 } from "solid-js";
|
|
5237
|
+
import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
|
|
5004
5238
|
function CustomCode(props) {
|
|
5005
5239
|
const [scriptsInserted, setScriptsInserted] = createSignal7([]);
|
|
5006
5240
|
const [scriptsRun, setScriptsRun] = createSignal7([]);
|
|
5007
5241
|
let elementRef;
|
|
5008
|
-
|
|
5242
|
+
onMount2(() => {
|
|
5009
5243
|
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
5010
5244
|
return;
|
|
5011
5245
|
}
|
|
@@ -5726,7 +5960,7 @@ function InlinedScript(props) {
|
|
|
5726
5960
|
var Inlined_script_default = InlinedScript;
|
|
5727
5961
|
|
|
5728
5962
|
// src/components/content/components/enable-editor.tsx
|
|
5729
|
-
import { Show as Show9, onMount as
|
|
5963
|
+
import { Show as Show9, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
5730
5964
|
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
5731
5965
|
|
|
5732
5966
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -6221,7 +6455,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
6221
6455
|
};
|
|
6222
6456
|
|
|
6223
6457
|
// src/constants/sdk-version.ts
|
|
6224
|
-
var SDK_VERSION = "0.12.
|
|
6458
|
+
var SDK_VERSION = "0.12.7";
|
|
6225
6459
|
|
|
6226
6460
|
// src/functions/register.ts
|
|
6227
6461
|
var registry = {};
|
|
@@ -6425,6 +6659,10 @@ function EnableEditor(props) {
|
|
|
6425
6659
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
6426
6660
|
break;
|
|
6427
6661
|
}
|
|
6662
|
+
case "builder.triggerAnimation": {
|
|
6663
|
+
triggerAnimation(data.data);
|
|
6664
|
+
break;
|
|
6665
|
+
}
|
|
6428
6666
|
case "builder.contentUpdate": {
|
|
6429
6667
|
const messageContent = data.data;
|
|
6430
6668
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -6522,7 +6760,7 @@ function EnableEditor(props) {
|
|
|
6522
6760
|
}
|
|
6523
6761
|
}
|
|
6524
6762
|
let elementRef;
|
|
6525
|
-
|
|
6763
|
+
onMount3(() => {
|
|
6526
6764
|
if (isBrowser()) {
|
|
6527
6765
|
if (isEditing() && true) {
|
|
6528
6766
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
@@ -6587,7 +6825,7 @@ function EnableEditor(props) {
|
|
|
6587
6825
|
}
|
|
6588
6826
|
}
|
|
6589
6827
|
});
|
|
6590
|
-
|
|
6828
|
+
onMount3(() => {
|
|
6591
6829
|
if (!props.apiKey) {
|
|
6592
6830
|
logger.error(
|
|
6593
6831
|
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
@@ -6610,13 +6848,7 @@ function EnableEditor(props) {
|
|
|
6610
6848
|
evaluateJsCode();
|
|
6611
6849
|
}
|
|
6612
6850
|
createEffect2(
|
|
6613
|
-
on2(
|
|
6614
|
-
() => [
|
|
6615
|
-
props.builderContextSignal.content?.data?.jsCode,
|
|
6616
|
-
props.builderContextSignal.rootState
|
|
6617
|
-
],
|
|
6618
|
-
onUpdateFn_2
|
|
6619
|
-
)
|
|
6851
|
+
on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
|
|
6620
6852
|
);
|
|
6621
6853
|
function onUpdateFn_3() {
|
|
6622
6854
|
runHttpRequests();
|
|
@@ -6933,7 +7165,7 @@ function ContentVariants(props) {
|
|
|
6933
7165
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
6934
7166
|
});
|
|
6935
7167
|
}
|
|
6936
|
-
|
|
7168
|
+
onMount4(() => {
|
|
6937
7169
|
setShouldRenderVariants(false);
|
|
6938
7170
|
});
|
|
6939
7171
|
return <>
|
|
@@ -7045,7 +7277,7 @@ function Symbol2(props) {
|
|
|
7045
7277
|
}
|
|
7046
7278
|
});
|
|
7047
7279
|
}
|
|
7048
|
-
|
|
7280
|
+
onMount5(() => {
|
|
7049
7281
|
setContent();
|
|
7050
7282
|
});
|
|
7051
7283
|
function onUpdateFn_0() {
|
package/lib/edge/index.js
CHANGED
|
@@ -248,27 +248,43 @@ var runInBrowser = ({
|
|
|
248
248
|
builder,
|
|
249
249
|
context,
|
|
250
250
|
event,
|
|
251
|
-
state: flattenState(
|
|
251
|
+
state: flattenState({
|
|
252
|
+
rootState,
|
|
253
|
+
localState,
|
|
254
|
+
rootSetState
|
|
255
|
+
})
|
|
252
256
|
});
|
|
253
257
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
254
258
|
};
|
|
255
|
-
function flattenState(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
function flattenState({
|
|
260
|
+
rootState,
|
|
261
|
+
localState,
|
|
262
|
+
rootSetState
|
|
263
|
+
}) {
|
|
259
264
|
return new Proxy(rootState, {
|
|
260
|
-
get: (
|
|
265
|
+
get: (target, prop) => {
|
|
261
266
|
if (localState && prop in localState) {
|
|
262
267
|
return localState[prop];
|
|
263
268
|
}
|
|
264
|
-
|
|
269
|
+
const val = target[prop];
|
|
270
|
+
if (typeof val === "object") {
|
|
271
|
+
return flattenState({
|
|
272
|
+
rootState: val,
|
|
273
|
+
localState: void 0,
|
|
274
|
+
rootSetState: rootSetState ? (subState) => {
|
|
275
|
+
target[prop] = subState;
|
|
276
|
+
rootSetState(target);
|
|
277
|
+
} : void 0
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return val;
|
|
265
281
|
},
|
|
266
|
-
set: (
|
|
282
|
+
set: (target, prop, value) => {
|
|
267
283
|
if (localState && prop in localState) {
|
|
268
284
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
269
285
|
}
|
|
270
|
-
|
|
271
|
-
rootSetState?.(
|
|
286
|
+
target[prop] = value;
|
|
287
|
+
rootSetState?.(target);
|
|
272
288
|
return true;
|
|
273
289
|
}
|
|
274
290
|
});
|
|
@@ -3558,6 +3574,211 @@ function getProcessedBlock({
|
|
|
3558
3574
|
}
|
|
3559
3575
|
}
|
|
3560
3576
|
|
|
3577
|
+
// src/components/block/animator.ts
|
|
3578
|
+
function throttle(func, wait, options = {}) {
|
|
3579
|
+
let context;
|
|
3580
|
+
let args;
|
|
3581
|
+
let result;
|
|
3582
|
+
let timeout = null;
|
|
3583
|
+
let previous = 0;
|
|
3584
|
+
const later = function() {
|
|
3585
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
3586
|
+
timeout = null;
|
|
3587
|
+
result = func.apply(context, args);
|
|
3588
|
+
if (!timeout)
|
|
3589
|
+
context = args = null;
|
|
3590
|
+
};
|
|
3591
|
+
return function() {
|
|
3592
|
+
const now = Date.now();
|
|
3593
|
+
if (!previous && options.leading === false)
|
|
3594
|
+
previous = now;
|
|
3595
|
+
const remaining = wait - (now - previous);
|
|
3596
|
+
context = this;
|
|
3597
|
+
args = arguments;
|
|
3598
|
+
if (remaining <= 0 || remaining > wait) {
|
|
3599
|
+
if (timeout) {
|
|
3600
|
+
clearTimeout(timeout);
|
|
3601
|
+
timeout = null;
|
|
3602
|
+
}
|
|
3603
|
+
previous = now;
|
|
3604
|
+
result = func.apply(context, args);
|
|
3605
|
+
if (!timeout)
|
|
3606
|
+
context = args = null;
|
|
3607
|
+
} else if (!timeout && options.trailing !== false) {
|
|
3608
|
+
timeout = setTimeout(later, remaining);
|
|
3609
|
+
}
|
|
3610
|
+
return result;
|
|
3611
|
+
};
|
|
3612
|
+
}
|
|
3613
|
+
function assign(target, ..._args) {
|
|
3614
|
+
const to = Object(target);
|
|
3615
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
3616
|
+
const nextSource = arguments[index];
|
|
3617
|
+
if (nextSource != null) {
|
|
3618
|
+
for (const nextKey in nextSource) {
|
|
3619
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
3620
|
+
to[nextKey] = nextSource[nextKey];
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
return to;
|
|
3626
|
+
}
|
|
3627
|
+
var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
3628
|
+
function bindAnimations(animations) {
|
|
3629
|
+
for (const animation of animations) {
|
|
3630
|
+
switch (animation.trigger) {
|
|
3631
|
+
case "pageLoad":
|
|
3632
|
+
triggerAnimation(animation);
|
|
3633
|
+
break;
|
|
3634
|
+
case "hover":
|
|
3635
|
+
bindHoverAnimation(animation);
|
|
3636
|
+
break;
|
|
3637
|
+
case "scrollInView":
|
|
3638
|
+
bindScrollInViewAnimation(animation);
|
|
3639
|
+
break;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
function warnElementNotPresent(id2) {
|
|
3644
|
+
}
|
|
3645
|
+
function augmentAnimation(animation, element) {
|
|
3646
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
3647
|
+
const computedStyle = getComputedStyle(element);
|
|
3648
|
+
const firstStyles = animation.steps[0].styles;
|
|
3649
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
3650
|
+
const bothStyles = [firstStyles, lastStyles];
|
|
3651
|
+
for (const styles of bothStyles) {
|
|
3652
|
+
for (const style of stylesUsed) {
|
|
3653
|
+
if (!(style in styles)) {
|
|
3654
|
+
styles[style] = computedStyle[style];
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
function getAllStylesUsed(animation) {
|
|
3660
|
+
const properties = [];
|
|
3661
|
+
for (const step of animation.steps) {
|
|
3662
|
+
for (const key in step.styles) {
|
|
3663
|
+
if (properties.indexOf(key) === -1) {
|
|
3664
|
+
properties.push(key);
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
return properties;
|
|
3669
|
+
}
|
|
3670
|
+
function triggerAnimation(animation) {
|
|
3671
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3672
|
+
if (!elements.length) {
|
|
3673
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3674
|
+
return;
|
|
3675
|
+
}
|
|
3676
|
+
Array.from(elements).forEach((element) => {
|
|
3677
|
+
augmentAnimation(animation, element);
|
|
3678
|
+
element.style.transition = "none";
|
|
3679
|
+
element.style.transitionDelay = "0";
|
|
3680
|
+
assign(element.style, animation.steps[0].styles);
|
|
3681
|
+
setTimeout(() => {
|
|
3682
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3683
|
+
if (animation.delay) {
|
|
3684
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3685
|
+
}
|
|
3686
|
+
assign(element.style, animation.steps[1].styles);
|
|
3687
|
+
setTimeout(() => {
|
|
3688
|
+
element.style.transition = "";
|
|
3689
|
+
element.style.transitionDelay = "";
|
|
3690
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
3691
|
+
});
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
function bindHoverAnimation(animation) {
|
|
3695
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3696
|
+
if (!elements.length) {
|
|
3697
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3698
|
+
return;
|
|
3699
|
+
}
|
|
3700
|
+
Array.from(elements).forEach((element) => {
|
|
3701
|
+
augmentAnimation(animation, element);
|
|
3702
|
+
const defaultState = animation.steps[0].styles;
|
|
3703
|
+
const hoverState = animation.steps[1].styles;
|
|
3704
|
+
function attachDefaultState() {
|
|
3705
|
+
assign(element.style, defaultState);
|
|
3706
|
+
}
|
|
3707
|
+
function attachHoverState() {
|
|
3708
|
+
assign(element.style, hoverState);
|
|
3709
|
+
}
|
|
3710
|
+
attachDefaultState();
|
|
3711
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
3712
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
3713
|
+
setTimeout(() => {
|
|
3714
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3715
|
+
if (animation.delay) {
|
|
3716
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3717
|
+
}
|
|
3718
|
+
});
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
function bindScrollInViewAnimation(animation) {
|
|
3722
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3723
|
+
if (!elements.length) {
|
|
3724
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
Array.from(elements).forEach((element) => {
|
|
3728
|
+
augmentAnimation(animation, element);
|
|
3729
|
+
let triggered = false;
|
|
3730
|
+
let pendingAnimation = false;
|
|
3731
|
+
function immediateOnScroll() {
|
|
3732
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
3733
|
+
triggered = true;
|
|
3734
|
+
pendingAnimation = true;
|
|
3735
|
+
setTimeout(() => {
|
|
3736
|
+
assign(element.style, animation.steps[1].styles);
|
|
3737
|
+
if (!animation.repeat) {
|
|
3738
|
+
document.removeEventListener("scroll", onScroll);
|
|
3739
|
+
}
|
|
3740
|
+
setTimeout(() => {
|
|
3741
|
+
pendingAnimation = false;
|
|
3742
|
+
if (!animation.repeat) {
|
|
3743
|
+
element.style.transition = "";
|
|
3744
|
+
element.style.transitionDelay = "";
|
|
3745
|
+
}
|
|
3746
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
3747
|
+
});
|
|
3748
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
3749
|
+
triggered = false;
|
|
3750
|
+
assign(element.style, animation.steps[0].styles);
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
3754
|
+
leading: false
|
|
3755
|
+
});
|
|
3756
|
+
function isScrolledIntoView(elem) {
|
|
3757
|
+
const rect = elem.getBoundingClientRect();
|
|
3758
|
+
const windowHeight = window.innerHeight;
|
|
3759
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
3760
|
+
const threshold = thresholdPercent * windowHeight;
|
|
3761
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
3762
|
+
}
|
|
3763
|
+
const defaultState = animation.steps[0].styles;
|
|
3764
|
+
function attachDefaultState() {
|
|
3765
|
+
assign(element.style, defaultState);
|
|
3766
|
+
}
|
|
3767
|
+
attachDefaultState();
|
|
3768
|
+
setTimeout(() => {
|
|
3769
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3770
|
+
if (animation.delay) {
|
|
3771
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3772
|
+
}
|
|
3773
|
+
});
|
|
3774
|
+
document.addEventListener("scroll", onScroll, {
|
|
3775
|
+
capture: true,
|
|
3776
|
+
passive: true
|
|
3777
|
+
});
|
|
3778
|
+
immediateOnScroll();
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3561
3782
|
// src/components/block/block.helpers.ts
|
|
3562
3783
|
var getComponent = ({
|
|
3563
3784
|
block,
|
|
@@ -4130,6 +4351,16 @@ function Block(props) {
|
|
|
4130
4351
|
isInteractive: !blockComponent()?.isRSC
|
|
4131
4352
|
};
|
|
4132
4353
|
}
|
|
4354
|
+
onMount(() => {
|
|
4355
|
+
const blockId = processedBlock().id;
|
|
4356
|
+
const animations = processedBlock().animations;
|
|
4357
|
+
if (animations && blockId) {
|
|
4358
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
4359
|
+
...animation,
|
|
4360
|
+
elementId: blockId
|
|
4361
|
+
})));
|
|
4362
|
+
}
|
|
4363
|
+
});
|
|
4133
4364
|
return createComponent(Show, {
|
|
4134
4365
|
get when() {
|
|
4135
4366
|
return canShowBlock();
|
|
@@ -6533,7 +6764,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
6533
6764
|
};
|
|
6534
6765
|
|
|
6535
6766
|
// src/constants/sdk-version.ts
|
|
6536
|
-
var SDK_VERSION = "0.12.
|
|
6767
|
+
var SDK_VERSION = "0.12.7";
|
|
6537
6768
|
|
|
6538
6769
|
// src/functions/register.ts
|
|
6539
6770
|
var registry = {};
|
|
@@ -6739,6 +6970,10 @@ function EnableEditor(props) {
|
|
|
6739
6970
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
6740
6971
|
break;
|
|
6741
6972
|
}
|
|
6973
|
+
case "builder.triggerAnimation": {
|
|
6974
|
+
triggerAnimation(data.data);
|
|
6975
|
+
break;
|
|
6976
|
+
}
|
|
6742
6977
|
case "builder.contentUpdate": {
|
|
6743
6978
|
const messageContent = data.data;
|
|
6744
6979
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -6908,7 +7143,7 @@ function EnableEditor(props) {
|
|
|
6908
7143
|
function onUpdateFn_2() {
|
|
6909
7144
|
evaluateJsCode();
|
|
6910
7145
|
}
|
|
6911
|
-
createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode
|
|
7146
|
+
createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2));
|
|
6912
7147
|
function onUpdateFn_3() {
|
|
6913
7148
|
runHttpRequests();
|
|
6914
7149
|
}
|