@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/lib/node/dev.jsx CHANGED
@@ -99,7 +99,7 @@ import { createContext as createContext2 } from "solid-js";
99
99
  var components_context_default = createContext2({ registeredComponents: {} });
100
100
 
101
101
  // src/components/block/block.tsx
102
- import { Show as Show4, For as For2, createSignal as createSignal4 } from "solid-js";
102
+ import { Show as Show4, For as For2, onMount, createSignal as createSignal4 } from "solid-js";
103
103
 
104
104
  // src/functions/get-block-component-options.ts
105
105
  function getBlockComponentOptions(block) {
@@ -231,27 +231,43 @@ var runInBrowser = ({
231
231
  builder,
232
232
  context,
233
233
  event,
234
- state: flattenState(rootState, localState, rootSetState)
234
+ state: flattenState({
235
+ rootState,
236
+ localState,
237
+ rootSetState
238
+ })
235
239
  });
236
240
  return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
237
241
  };
238
- function flattenState(rootState, localState, rootSetState) {
239
- if (rootState === localState) {
240
- throw new Error("rootState === localState");
241
- }
242
+ function flattenState({
243
+ rootState,
244
+ localState,
245
+ rootSetState
246
+ }) {
242
247
  return new Proxy(rootState, {
243
- get: (_, prop) => {
248
+ get: (target, prop) => {
244
249
  if (localState && prop in localState) {
245
250
  return localState[prop];
246
251
  }
247
- return rootState[prop];
252
+ const val = target[prop];
253
+ if (typeof val === "object") {
254
+ return flattenState({
255
+ rootState: val,
256
+ localState: void 0,
257
+ rootSetState: rootSetState ? (subState) => {
258
+ target[prop] = subState;
259
+ rootSetState(target);
260
+ } : void 0
261
+ });
262
+ }
263
+ return val;
248
264
  },
249
- set: (_, prop, value) => {
265
+ set: (target, prop, value) => {
250
266
  if (localState && prop in localState) {
251
267
  throw new Error("Writing to local state is not allowed as it is read-only.");
252
268
  }
253
- rootState[prop] = value;
254
- rootSetState?.(rootState);
269
+ target[prop] = value;
270
+ rootSetState?.(target);
255
271
  return true;
256
272
  }
257
273
  });
@@ -520,6 +536,212 @@ function getProcessedBlock({
520
536
  }
521
537
  }
522
538
 
539
+ // src/components/block/animator.ts
540
+ function throttle(func, wait, options = {}) {
541
+ let context;
542
+ let args;
543
+ let result;
544
+ let timeout = null;
545
+ let previous = 0;
546
+ const later = function() {
547
+ previous = options.leading === false ? 0 : Date.now();
548
+ timeout = null;
549
+ result = func.apply(context, args);
550
+ if (!timeout)
551
+ context = args = null;
552
+ };
553
+ return function() {
554
+ const now = Date.now();
555
+ if (!previous && options.leading === false)
556
+ previous = now;
557
+ const remaining = wait - (now - previous);
558
+ context = this;
559
+ args = arguments;
560
+ if (remaining <= 0 || remaining > wait) {
561
+ if (timeout) {
562
+ clearTimeout(timeout);
563
+ timeout = null;
564
+ }
565
+ previous = now;
566
+ result = func.apply(context, args);
567
+ if (!timeout)
568
+ context = args = null;
569
+ } else if (!timeout && options.trailing !== false) {
570
+ timeout = setTimeout(later, remaining);
571
+ }
572
+ return result;
573
+ };
574
+ }
575
+ function assign(target, ..._args) {
576
+ const to = Object(target);
577
+ for (let index = 1; index < arguments.length; index++) {
578
+ const nextSource = arguments[index];
579
+ if (nextSource != null) {
580
+ for (const nextKey in nextSource) {
581
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
582
+ to[nextKey] = nextSource[nextKey];
583
+ }
584
+ }
585
+ }
586
+ }
587
+ return to;
588
+ }
589
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
590
+ function bindAnimations(animations) {
591
+ for (const animation of animations) {
592
+ switch (animation.trigger) {
593
+ case "pageLoad":
594
+ triggerAnimation(animation);
595
+ break;
596
+ case "hover":
597
+ bindHoverAnimation(animation);
598
+ break;
599
+ case "scrollInView":
600
+ bindScrollInViewAnimation(animation);
601
+ break;
602
+ }
603
+ }
604
+ }
605
+ function warnElementNotPresent(id) {
606
+ console.warn(`Cannot animate element: element with ID ${id} not found!`);
607
+ }
608
+ function augmentAnimation(animation, element) {
609
+ const stylesUsed = getAllStylesUsed(animation);
610
+ const computedStyle = getComputedStyle(element);
611
+ const firstStyles = animation.steps[0].styles;
612
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
613
+ const bothStyles = [firstStyles, lastStyles];
614
+ for (const styles of bothStyles) {
615
+ for (const style of stylesUsed) {
616
+ if (!(style in styles)) {
617
+ styles[style] = computedStyle[style];
618
+ }
619
+ }
620
+ }
621
+ }
622
+ function getAllStylesUsed(animation) {
623
+ const properties = [];
624
+ for (const step of animation.steps) {
625
+ for (const key in step.styles) {
626
+ if (properties.indexOf(key) === -1) {
627
+ properties.push(key);
628
+ }
629
+ }
630
+ }
631
+ return properties;
632
+ }
633
+ function triggerAnimation(animation) {
634
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
635
+ if (!elements.length) {
636
+ warnElementNotPresent(animation.elementId || animation.id || "");
637
+ return;
638
+ }
639
+ Array.from(elements).forEach((element) => {
640
+ augmentAnimation(animation, element);
641
+ element.style.transition = "none";
642
+ element.style.transitionDelay = "0";
643
+ assign(element.style, animation.steps[0].styles);
644
+ setTimeout(() => {
645
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
646
+ if (animation.delay) {
647
+ element.style.transitionDelay = animation.delay + "s";
648
+ }
649
+ assign(element.style, animation.steps[1].styles);
650
+ setTimeout(() => {
651
+ element.style.transition = "";
652
+ element.style.transitionDelay = "";
653
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
654
+ });
655
+ });
656
+ }
657
+ function bindHoverAnimation(animation) {
658
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
659
+ if (!elements.length) {
660
+ warnElementNotPresent(animation.elementId || animation.id || "");
661
+ return;
662
+ }
663
+ Array.from(elements).forEach((element) => {
664
+ augmentAnimation(animation, element);
665
+ const defaultState = animation.steps[0].styles;
666
+ const hoverState = animation.steps[1].styles;
667
+ function attachDefaultState() {
668
+ assign(element.style, defaultState);
669
+ }
670
+ function attachHoverState() {
671
+ assign(element.style, hoverState);
672
+ }
673
+ attachDefaultState();
674
+ element.addEventListener("mouseenter", attachHoverState);
675
+ element.addEventListener("mouseleave", attachDefaultState);
676
+ setTimeout(() => {
677
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
678
+ if (animation.delay) {
679
+ element.style.transitionDelay = animation.delay + "s";
680
+ }
681
+ });
682
+ });
683
+ }
684
+ function bindScrollInViewAnimation(animation) {
685
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
686
+ if (!elements.length) {
687
+ warnElementNotPresent(animation.elementId || animation.id || "");
688
+ return;
689
+ }
690
+ Array.from(elements).forEach((element) => {
691
+ augmentAnimation(animation, element);
692
+ let triggered = false;
693
+ let pendingAnimation = false;
694
+ function immediateOnScroll() {
695
+ if (!triggered && isScrolledIntoView(element)) {
696
+ triggered = true;
697
+ pendingAnimation = true;
698
+ setTimeout(() => {
699
+ assign(element.style, animation.steps[1].styles);
700
+ if (!animation.repeat) {
701
+ document.removeEventListener("scroll", onScroll);
702
+ }
703
+ setTimeout(() => {
704
+ pendingAnimation = false;
705
+ if (!animation.repeat) {
706
+ element.style.transition = "";
707
+ element.style.transitionDelay = "";
708
+ }
709
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
710
+ });
711
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
712
+ triggered = false;
713
+ assign(element.style, animation.steps[0].styles);
714
+ }
715
+ }
716
+ const onScroll = throttle(immediateOnScroll, 200, {
717
+ leading: false
718
+ });
719
+ function isScrolledIntoView(elem) {
720
+ const rect = elem.getBoundingClientRect();
721
+ const windowHeight = window.innerHeight;
722
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
723
+ const threshold = thresholdPercent * windowHeight;
724
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
725
+ }
726
+ const defaultState = animation.steps[0].styles;
727
+ function attachDefaultState() {
728
+ assign(element.style, defaultState);
729
+ }
730
+ attachDefaultState();
731
+ setTimeout(() => {
732
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
733
+ if (animation.delay) {
734
+ element.style.transitionDelay = animation.delay + "s";
735
+ }
736
+ });
737
+ document.addEventListener("scroll", onScroll, {
738
+ capture: true,
739
+ passive: true
740
+ });
741
+ immediateOnScroll();
742
+ });
743
+ }
744
+
523
745
  // src/components/block/block.helpers.ts
524
746
  var getComponent = ({
525
747
  block,
@@ -1042,6 +1264,18 @@ function Block(props) {
1042
1264
  isInteractive: !blockComponent()?.isRSC
1043
1265
  };
1044
1266
  }
1267
+ onMount(() => {
1268
+ const blockId = processedBlock().id;
1269
+ const animations = processedBlock().animations;
1270
+ if (animations && blockId) {
1271
+ bindAnimations(
1272
+ animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1273
+ ...animation,
1274
+ elementId: blockId
1275
+ }))
1276
+ );
1277
+ }
1278
+ });
1045
1279
  return <Show4 when={canShowBlock()}>
1046
1280
  <Block_styles_default block={props.block} context={props.context} />
1047
1281
  <Show4
@@ -1490,10 +1724,10 @@ function SectionComponent(props) {
1490
1724
  var section_default = SectionComponent;
1491
1725
 
1492
1726
  // src/blocks/symbol/symbol.tsx
1493
- import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1727
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1494
1728
 
1495
1729
  // src/components/content-variants/content-variants.tsx
1496
- import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal13 } from "solid-js";
1730
+ import { Show as Show11, For as For5, onMount as onMount4, createSignal as createSignal13 } from "solid-js";
1497
1731
 
1498
1732
  // src/helpers/url.ts
1499
1733
  var getTopLevelDomain = (host) => {
@@ -1971,12 +2205,12 @@ var componentInfo3 = {
1971
2205
  };
1972
2206
 
1973
2207
  // src/blocks/custom-code/custom-code.tsx
1974
- import { onMount, createSignal as createSignal7 } from "solid-js";
2208
+ import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
1975
2209
  function CustomCode(props) {
1976
2210
  const [scriptsInserted, setScriptsInserted] = createSignal7([]);
1977
2211
  const [scriptsRun, setScriptsRun] = createSignal7([]);
1978
2212
  let elementRef;
1979
- onMount(() => {
2213
+ onMount2(() => {
1980
2214
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
1981
2215
  return;
1982
2216
  }
@@ -2697,7 +2931,7 @@ function InlinedScript(props) {
2697
2931
  var Inlined_script_default = InlinedScript;
2698
2932
 
2699
2933
  // src/components/content/components/enable-editor.tsx
2700
- import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2934
+ import { Show as Show9, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2701
2935
  import { Dynamic as Dynamic5 } from "solid-js/web";
2702
2936
 
2703
2937
  // src/helpers/preview-lru-cache/get.ts
@@ -3192,7 +3426,7 @@ var getInteractionPropertiesForEvent = (event) => {
3192
3426
  };
3193
3427
 
3194
3428
  // src/constants/sdk-version.ts
3195
- var SDK_VERSION = "0.12.5";
3429
+ var SDK_VERSION = "0.12.7";
3196
3430
 
3197
3431
  // src/functions/register.ts
3198
3432
  var registry = {};
@@ -3396,6 +3630,10 @@ function EnableEditor(props) {
3396
3630
  setForceReRenderCount(forceReRenderCount() + 1);
3397
3631
  break;
3398
3632
  }
3633
+ case "builder.triggerAnimation": {
3634
+ triggerAnimation(data.data);
3635
+ break;
3636
+ }
3399
3637
  case "builder.contentUpdate": {
3400
3638
  const messageContent = data.data;
3401
3639
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -3493,7 +3731,7 @@ function EnableEditor(props) {
3493
3731
  }
3494
3732
  }
3495
3733
  let elementRef;
3496
- onMount2(() => {
3734
+ onMount3(() => {
3497
3735
  if (isBrowser()) {
3498
3736
  if (isEditing() && true) {
3499
3737
  setForceReRenderCount(forceReRenderCount() + 1);
@@ -3558,7 +3796,7 @@ function EnableEditor(props) {
3558
3796
  }
3559
3797
  }
3560
3798
  });
3561
- onMount2(() => {
3799
+ onMount3(() => {
3562
3800
  if (!props.apiKey) {
3563
3801
  logger.error(
3564
3802
  "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
@@ -3581,13 +3819,7 @@ function EnableEditor(props) {
3581
3819
  evaluateJsCode();
3582
3820
  }
3583
3821
  createEffect2(
3584
- on2(
3585
- () => [
3586
- props.builderContextSignal.content?.data?.jsCode,
3587
- props.builderContextSignal.rootState
3588
- ],
3589
- onUpdateFn_2
3590
- )
3822
+ on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
3591
3823
  );
3592
3824
  function onUpdateFn_3() {
3593
3825
  runHttpRequests();
@@ -3904,7 +4136,7 @@ function ContentVariants(props) {
3904
4136
  canTrack: getDefaultCanTrack(props.canTrack)
3905
4137
  });
3906
4138
  }
3907
- onMount3(() => {
4139
+ onMount4(() => {
3908
4140
  setShouldRenderVariants(false);
3909
4141
  });
3910
4142
  return <>
@@ -4016,7 +4248,7 @@ function Symbol(props) {
4016
4248
  }
4017
4249
  });
4018
4250
  }
4019
- onMount4(() => {
4251
+ onMount5(() => {
4020
4252
  setContent();
4021
4253
  });
4022
4254
  function onUpdateFn_0() {
package/lib/node/index.js CHANGED
@@ -243,27 +243,43 @@ var runInBrowser = ({
243
243
  builder,
244
244
  context,
245
245
  event,
246
- state: flattenState(rootState, localState, rootSetState)
246
+ state: flattenState({
247
+ rootState,
248
+ localState,
249
+ rootSetState
250
+ })
247
251
  });
248
252
  return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
249
253
  };
250
- function flattenState(rootState, localState, rootSetState) {
251
- if (rootState === localState) {
252
- throw new Error("rootState === localState");
253
- }
254
+ function flattenState({
255
+ rootState,
256
+ localState,
257
+ rootSetState
258
+ }) {
254
259
  return new Proxy(rootState, {
255
- get: (_, prop) => {
260
+ get: (target, prop) => {
256
261
  if (localState && prop in localState) {
257
262
  return localState[prop];
258
263
  }
259
- return rootState[prop];
264
+ const val = target[prop];
265
+ if (typeof val === "object") {
266
+ return flattenState({
267
+ rootState: val,
268
+ localState: void 0,
269
+ rootSetState: rootSetState ? (subState) => {
270
+ target[prop] = subState;
271
+ rootSetState(target);
272
+ } : void 0
273
+ });
274
+ }
275
+ return val;
260
276
  },
261
- set: (_, prop, value) => {
277
+ set: (target, prop, value) => {
262
278
  if (localState && prop in localState) {
263
279
  throw new Error("Writing to local state is not allowed as it is read-only.");
264
280
  }
265
- rootState[prop] = value;
266
- rootSetState?.(rootState);
281
+ target[prop] = value;
282
+ rootSetState?.(target);
267
283
  return true;
268
284
  }
269
285
  });
@@ -528,6 +544,211 @@ function getProcessedBlock({
528
544
  }
529
545
  }
530
546
 
547
+ // src/components/block/animator.ts
548
+ function throttle(func, wait, options = {}) {
549
+ let context;
550
+ let args;
551
+ let result;
552
+ let timeout = null;
553
+ let previous = 0;
554
+ const later = function() {
555
+ previous = options.leading === false ? 0 : Date.now();
556
+ timeout = null;
557
+ result = func.apply(context, args);
558
+ if (!timeout)
559
+ context = args = null;
560
+ };
561
+ return function() {
562
+ const now = Date.now();
563
+ if (!previous && options.leading === false)
564
+ previous = now;
565
+ const remaining = wait - (now - previous);
566
+ context = this;
567
+ args = arguments;
568
+ if (remaining <= 0 || remaining > wait) {
569
+ if (timeout) {
570
+ clearTimeout(timeout);
571
+ timeout = null;
572
+ }
573
+ previous = now;
574
+ result = func.apply(context, args);
575
+ if (!timeout)
576
+ context = args = null;
577
+ } else if (!timeout && options.trailing !== false) {
578
+ timeout = setTimeout(later, remaining);
579
+ }
580
+ return result;
581
+ };
582
+ }
583
+ function assign(target, ..._args) {
584
+ const to = Object(target);
585
+ for (let index = 1; index < arguments.length; index++) {
586
+ const nextSource = arguments[index];
587
+ if (nextSource != null) {
588
+ for (const nextKey in nextSource) {
589
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
590
+ to[nextKey] = nextSource[nextKey];
591
+ }
592
+ }
593
+ }
594
+ }
595
+ return to;
596
+ }
597
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
598
+ function bindAnimations(animations) {
599
+ for (const animation of animations) {
600
+ switch (animation.trigger) {
601
+ case "pageLoad":
602
+ triggerAnimation(animation);
603
+ break;
604
+ case "hover":
605
+ bindHoverAnimation(animation);
606
+ break;
607
+ case "scrollInView":
608
+ bindScrollInViewAnimation(animation);
609
+ break;
610
+ }
611
+ }
612
+ }
613
+ function warnElementNotPresent(id) {
614
+ }
615
+ function augmentAnimation(animation, element) {
616
+ const stylesUsed = getAllStylesUsed(animation);
617
+ const computedStyle = getComputedStyle(element);
618
+ const firstStyles = animation.steps[0].styles;
619
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
620
+ const bothStyles = [firstStyles, lastStyles];
621
+ for (const styles of bothStyles) {
622
+ for (const style of stylesUsed) {
623
+ if (!(style in styles)) {
624
+ styles[style] = computedStyle[style];
625
+ }
626
+ }
627
+ }
628
+ }
629
+ function getAllStylesUsed(animation) {
630
+ const properties = [];
631
+ for (const step of animation.steps) {
632
+ for (const key in step.styles) {
633
+ if (properties.indexOf(key) === -1) {
634
+ properties.push(key);
635
+ }
636
+ }
637
+ }
638
+ return properties;
639
+ }
640
+ function triggerAnimation(animation) {
641
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
642
+ if (!elements.length) {
643
+ warnElementNotPresent(animation.elementId || animation.id || "");
644
+ return;
645
+ }
646
+ Array.from(elements).forEach((element) => {
647
+ augmentAnimation(animation, element);
648
+ element.style.transition = "none";
649
+ element.style.transitionDelay = "0";
650
+ assign(element.style, animation.steps[0].styles);
651
+ setTimeout(() => {
652
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
653
+ if (animation.delay) {
654
+ element.style.transitionDelay = animation.delay + "s";
655
+ }
656
+ assign(element.style, animation.steps[1].styles);
657
+ setTimeout(() => {
658
+ element.style.transition = "";
659
+ element.style.transitionDelay = "";
660
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
661
+ });
662
+ });
663
+ }
664
+ function bindHoverAnimation(animation) {
665
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
666
+ if (!elements.length) {
667
+ warnElementNotPresent(animation.elementId || animation.id || "");
668
+ return;
669
+ }
670
+ Array.from(elements).forEach((element) => {
671
+ augmentAnimation(animation, element);
672
+ const defaultState = animation.steps[0].styles;
673
+ const hoverState = animation.steps[1].styles;
674
+ function attachDefaultState() {
675
+ assign(element.style, defaultState);
676
+ }
677
+ function attachHoverState() {
678
+ assign(element.style, hoverState);
679
+ }
680
+ attachDefaultState();
681
+ element.addEventListener("mouseenter", attachHoverState);
682
+ element.addEventListener("mouseleave", attachDefaultState);
683
+ setTimeout(() => {
684
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
685
+ if (animation.delay) {
686
+ element.style.transitionDelay = animation.delay + "s";
687
+ }
688
+ });
689
+ });
690
+ }
691
+ function bindScrollInViewAnimation(animation) {
692
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
693
+ if (!elements.length) {
694
+ warnElementNotPresent(animation.elementId || animation.id || "");
695
+ return;
696
+ }
697
+ Array.from(elements).forEach((element) => {
698
+ augmentAnimation(animation, element);
699
+ let triggered = false;
700
+ let pendingAnimation = false;
701
+ function immediateOnScroll() {
702
+ if (!triggered && isScrolledIntoView(element)) {
703
+ triggered = true;
704
+ pendingAnimation = true;
705
+ setTimeout(() => {
706
+ assign(element.style, animation.steps[1].styles);
707
+ if (!animation.repeat) {
708
+ document.removeEventListener("scroll", onScroll);
709
+ }
710
+ setTimeout(() => {
711
+ pendingAnimation = false;
712
+ if (!animation.repeat) {
713
+ element.style.transition = "";
714
+ element.style.transitionDelay = "";
715
+ }
716
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
717
+ });
718
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
719
+ triggered = false;
720
+ assign(element.style, animation.steps[0].styles);
721
+ }
722
+ }
723
+ const onScroll = throttle(immediateOnScroll, 200, {
724
+ leading: false
725
+ });
726
+ function isScrolledIntoView(elem) {
727
+ const rect = elem.getBoundingClientRect();
728
+ const windowHeight = window.innerHeight;
729
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
730
+ const threshold = thresholdPercent * windowHeight;
731
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
732
+ }
733
+ const defaultState = animation.steps[0].styles;
734
+ function attachDefaultState() {
735
+ assign(element.style, defaultState);
736
+ }
737
+ attachDefaultState();
738
+ setTimeout(() => {
739
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
740
+ if (animation.delay) {
741
+ element.style.transitionDelay = animation.delay + "s";
742
+ }
743
+ });
744
+ document.addEventListener("scroll", onScroll, {
745
+ capture: true,
746
+ passive: true
747
+ });
748
+ immediateOnScroll();
749
+ });
750
+ }
751
+
531
752
  // src/components/block/block.helpers.ts
532
753
  var getComponent = ({
533
754
  block,
@@ -1100,6 +1321,16 @@ function Block(props) {
1100
1321
  isInteractive: !blockComponent()?.isRSC
1101
1322
  };
1102
1323
  }
1324
+ onMount(() => {
1325
+ const blockId = processedBlock().id;
1326
+ const animations = processedBlock().animations;
1327
+ if (animations && blockId) {
1328
+ bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1329
+ ...animation,
1330
+ elementId: blockId
1331
+ })));
1332
+ }
1333
+ });
1103
1334
  return createComponent(Show, {
1104
1335
  get when() {
1105
1336
  return canShowBlock();
@@ -3503,7 +3734,7 @@ var getInteractionPropertiesForEvent = (event) => {
3503
3734
  };
3504
3735
 
3505
3736
  // src/constants/sdk-version.ts
3506
- var SDK_VERSION = "0.12.5";
3737
+ var SDK_VERSION = "0.12.7";
3507
3738
 
3508
3739
  // src/functions/register.ts
3509
3740
  var registry = {};
@@ -3709,6 +3940,10 @@ function EnableEditor(props) {
3709
3940
  setForceReRenderCount(forceReRenderCount() + 1);
3710
3941
  break;
3711
3942
  }
3943
+ case "builder.triggerAnimation": {
3944
+ triggerAnimation(data.data);
3945
+ break;
3946
+ }
3712
3947
  case "builder.contentUpdate": {
3713
3948
  const messageContent = data.data;
3714
3949
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -3878,7 +4113,7 @@ function EnableEditor(props) {
3878
4113
  function onUpdateFn_2() {
3879
4114
  evaluateJsCode();
3880
4115
  }
3881
- createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode, props.builderContextSignal.rootState], onUpdateFn_2));
4116
+ createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2));
3882
4117
  function onUpdateFn_3() {
3883
4118
  runHttpRequests();
3884
4119
  }