@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.
@@ -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) {
@@ -229,27 +229,43 @@ var runInBrowser = ({
229
229
  builder,
230
230
  context,
231
231
  event,
232
- state: flattenState(rootState, localState, rootSetState)
232
+ state: flattenState({
233
+ rootState,
234
+ localState,
235
+ rootSetState
236
+ })
233
237
  });
234
238
  return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
235
239
  };
236
- function flattenState(rootState, localState, rootSetState) {
237
- if (rootState === localState) {
238
- throw new Error("rootState === localState");
239
- }
240
+ function flattenState({
241
+ rootState,
242
+ localState,
243
+ rootSetState
244
+ }) {
240
245
  return new Proxy(rootState, {
241
- get: (_, prop) => {
246
+ get: (target, prop) => {
242
247
  if (localState && prop in localState) {
243
248
  return localState[prop];
244
249
  }
245
- return rootState[prop];
250
+ const val = target[prop];
251
+ if (typeof val === "object") {
252
+ return flattenState({
253
+ rootState: val,
254
+ localState: void 0,
255
+ rootSetState: rootSetState ? (subState) => {
256
+ target[prop] = subState;
257
+ rootSetState(target);
258
+ } : void 0
259
+ });
260
+ }
261
+ return val;
246
262
  },
247
- set: (_, prop, value) => {
263
+ set: (target, prop, value) => {
248
264
  if (localState && prop in localState) {
249
265
  throw new Error("Writing to local state is not allowed as it is read-only.");
250
266
  }
251
- rootState[prop] = value;
252
- rootSetState?.(rootState);
267
+ target[prop] = value;
268
+ rootSetState?.(target);
253
269
  return true;
254
270
  }
255
271
  });
@@ -392,6 +408,211 @@ function getProcessedBlock({
392
408
  }
393
409
  }
394
410
 
411
+ // src/components/block/animator.ts
412
+ function throttle(func, wait, options = {}) {
413
+ let context;
414
+ let args;
415
+ let result;
416
+ let timeout = null;
417
+ let previous = 0;
418
+ const later = function() {
419
+ previous = options.leading === false ? 0 : Date.now();
420
+ timeout = null;
421
+ result = func.apply(context, args);
422
+ if (!timeout)
423
+ context = args = null;
424
+ };
425
+ return function() {
426
+ const now = Date.now();
427
+ if (!previous && options.leading === false)
428
+ previous = now;
429
+ const remaining = wait - (now - previous);
430
+ context = this;
431
+ args = arguments;
432
+ if (remaining <= 0 || remaining > wait) {
433
+ if (timeout) {
434
+ clearTimeout(timeout);
435
+ timeout = null;
436
+ }
437
+ previous = now;
438
+ result = func.apply(context, args);
439
+ if (!timeout)
440
+ context = args = null;
441
+ } else if (!timeout && options.trailing !== false) {
442
+ timeout = setTimeout(later, remaining);
443
+ }
444
+ return result;
445
+ };
446
+ }
447
+ function assign(target, ..._args) {
448
+ const to = Object(target);
449
+ for (let index = 1; index < arguments.length; index++) {
450
+ const nextSource = arguments[index];
451
+ if (nextSource != null) {
452
+ for (const nextKey in nextSource) {
453
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
454
+ to[nextKey] = nextSource[nextKey];
455
+ }
456
+ }
457
+ }
458
+ }
459
+ return to;
460
+ }
461
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
462
+ function bindAnimations(animations) {
463
+ for (const animation of animations) {
464
+ switch (animation.trigger) {
465
+ case "pageLoad":
466
+ triggerAnimation(animation);
467
+ break;
468
+ case "hover":
469
+ bindHoverAnimation(animation);
470
+ break;
471
+ case "scrollInView":
472
+ bindScrollInViewAnimation(animation);
473
+ break;
474
+ }
475
+ }
476
+ }
477
+ function warnElementNotPresent(id) {
478
+ }
479
+ function augmentAnimation(animation, element) {
480
+ const stylesUsed = getAllStylesUsed(animation);
481
+ const computedStyle = getComputedStyle(element);
482
+ const firstStyles = animation.steps[0].styles;
483
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
484
+ const bothStyles = [firstStyles, lastStyles];
485
+ for (const styles of bothStyles) {
486
+ for (const style of stylesUsed) {
487
+ if (!(style in styles)) {
488
+ styles[style] = computedStyle[style];
489
+ }
490
+ }
491
+ }
492
+ }
493
+ function getAllStylesUsed(animation) {
494
+ const properties = [];
495
+ for (const step of animation.steps) {
496
+ for (const key in step.styles) {
497
+ if (properties.indexOf(key) === -1) {
498
+ properties.push(key);
499
+ }
500
+ }
501
+ }
502
+ return properties;
503
+ }
504
+ function triggerAnimation(animation) {
505
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
506
+ if (!elements.length) {
507
+ warnElementNotPresent(animation.elementId || animation.id || "");
508
+ return;
509
+ }
510
+ Array.from(elements).forEach((element) => {
511
+ augmentAnimation(animation, element);
512
+ element.style.transition = "none";
513
+ element.style.transitionDelay = "0";
514
+ assign(element.style, animation.steps[0].styles);
515
+ setTimeout(() => {
516
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
517
+ if (animation.delay) {
518
+ element.style.transitionDelay = animation.delay + "s";
519
+ }
520
+ assign(element.style, animation.steps[1].styles);
521
+ setTimeout(() => {
522
+ element.style.transition = "";
523
+ element.style.transitionDelay = "";
524
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
525
+ });
526
+ });
527
+ }
528
+ function bindHoverAnimation(animation) {
529
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
530
+ if (!elements.length) {
531
+ warnElementNotPresent(animation.elementId || animation.id || "");
532
+ return;
533
+ }
534
+ Array.from(elements).forEach((element) => {
535
+ augmentAnimation(animation, element);
536
+ const defaultState = animation.steps[0].styles;
537
+ const hoverState = animation.steps[1].styles;
538
+ function attachDefaultState() {
539
+ assign(element.style, defaultState);
540
+ }
541
+ function attachHoverState() {
542
+ assign(element.style, hoverState);
543
+ }
544
+ attachDefaultState();
545
+ element.addEventListener("mouseenter", attachHoverState);
546
+ element.addEventListener("mouseleave", attachDefaultState);
547
+ setTimeout(() => {
548
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
549
+ if (animation.delay) {
550
+ element.style.transitionDelay = animation.delay + "s";
551
+ }
552
+ });
553
+ });
554
+ }
555
+ function bindScrollInViewAnimation(animation) {
556
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
557
+ if (!elements.length) {
558
+ warnElementNotPresent(animation.elementId || animation.id || "");
559
+ return;
560
+ }
561
+ Array.from(elements).forEach((element) => {
562
+ augmentAnimation(animation, element);
563
+ let triggered = false;
564
+ let pendingAnimation = false;
565
+ function immediateOnScroll() {
566
+ if (!triggered && isScrolledIntoView(element)) {
567
+ triggered = true;
568
+ pendingAnimation = true;
569
+ setTimeout(() => {
570
+ assign(element.style, animation.steps[1].styles);
571
+ if (!animation.repeat) {
572
+ document.removeEventListener("scroll", onScroll);
573
+ }
574
+ setTimeout(() => {
575
+ pendingAnimation = false;
576
+ if (!animation.repeat) {
577
+ element.style.transition = "";
578
+ element.style.transitionDelay = "";
579
+ }
580
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
581
+ });
582
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
583
+ triggered = false;
584
+ assign(element.style, animation.steps[0].styles);
585
+ }
586
+ }
587
+ const onScroll = throttle(immediateOnScroll, 200, {
588
+ leading: false
589
+ });
590
+ function isScrolledIntoView(elem) {
591
+ const rect = elem.getBoundingClientRect();
592
+ const windowHeight = window.innerHeight;
593
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
594
+ const threshold = thresholdPercent * windowHeight;
595
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
596
+ }
597
+ const defaultState = animation.steps[0].styles;
598
+ function attachDefaultState() {
599
+ assign(element.style, defaultState);
600
+ }
601
+ attachDefaultState();
602
+ setTimeout(() => {
603
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
604
+ if (animation.delay) {
605
+ element.style.transitionDelay = animation.delay + "s";
606
+ }
607
+ });
608
+ document.addEventListener("scroll", onScroll, {
609
+ capture: true,
610
+ passive: true
611
+ });
612
+ immediateOnScroll();
613
+ });
614
+ }
615
+
395
616
  // src/components/block/block.helpers.ts
396
617
  var getComponent = ({
397
618
  block,
@@ -911,6 +1132,18 @@ function Block(props) {
911
1132
  isInteractive: !blockComponent()?.isRSC
912
1133
  };
913
1134
  }
1135
+ onMount(() => {
1136
+ const blockId = processedBlock().id;
1137
+ const animations = processedBlock().animations;
1138
+ if (animations && blockId) {
1139
+ bindAnimations(
1140
+ animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1141
+ ...animation,
1142
+ elementId: blockId
1143
+ }))
1144
+ );
1145
+ }
1146
+ });
914
1147
  return <Show4 when={canShowBlock()}>
915
1148
  <Block_styles_default block={props.block} context={props.context} />
916
1149
  <Show4
@@ -1358,10 +1591,10 @@ function SectionComponent(props) {
1358
1591
  var section_default = SectionComponent;
1359
1592
 
1360
1593
  // src/blocks/symbol/symbol.tsx
1361
- import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1594
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1362
1595
 
1363
1596
  // src/components/content-variants/content-variants.tsx
1364
- import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal13 } from "solid-js";
1597
+ import { Show as Show11, For as For5, onMount as onMount4, createSignal as createSignal13 } from "solid-js";
1365
1598
 
1366
1599
  // src/helpers/url.ts
1367
1600
  var getTopLevelDomain = (host) => {
@@ -1839,12 +2072,12 @@ var componentInfo3 = {
1839
2072
  };
1840
2073
 
1841
2074
  // src/blocks/custom-code/custom-code.tsx
1842
- import { onMount, createSignal as createSignal7 } from "solid-js";
2075
+ import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
1843
2076
  function CustomCode(props) {
1844
2077
  const [scriptsInserted, setScriptsInserted] = createSignal7([]);
1845
2078
  const [scriptsRun, setScriptsRun] = createSignal7([]);
1846
2079
  let elementRef;
1847
- onMount(() => {
2080
+ onMount2(() => {
1848
2081
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
1849
2082
  return;
1850
2083
  }
@@ -2562,7 +2795,7 @@ function InlinedScript(props) {
2562
2795
  var Inlined_script_default = InlinedScript;
2563
2796
 
2564
2797
  // src/components/content/components/enable-editor.tsx
2565
- import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2798
+ import { Show as Show9, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2566
2799
  import { Dynamic as Dynamic5 } from "solid-js/web";
2567
2800
 
2568
2801
  // src/helpers/preview-lru-cache/get.ts
@@ -3052,7 +3285,7 @@ var getInteractionPropertiesForEvent = (event) => {
3052
3285
  };
3053
3286
 
3054
3287
  // src/constants/sdk-version.ts
3055
- var SDK_VERSION = "0.12.5";
3288
+ var SDK_VERSION = "0.12.7";
3056
3289
 
3057
3290
  // src/functions/register.ts
3058
3291
  var registry = {};
@@ -3255,6 +3488,10 @@ function EnableEditor(props) {
3255
3488
  setForceReRenderCount(forceReRenderCount() + 1);
3256
3489
  break;
3257
3490
  }
3491
+ case "builder.triggerAnimation": {
3492
+ triggerAnimation(data.data);
3493
+ break;
3494
+ }
3258
3495
  case "builder.contentUpdate": {
3259
3496
  const messageContent = data.data;
3260
3497
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -3351,7 +3588,7 @@ function EnableEditor(props) {
3351
3588
  }
3352
3589
  }
3353
3590
  let elementRef;
3354
- onMount2(() => {
3591
+ onMount3(() => {
3355
3592
  if (isBrowser()) {
3356
3593
  if (isEditing() && true) {
3357
3594
  setForceReRenderCount(forceReRenderCount() + 1);
@@ -3416,7 +3653,7 @@ function EnableEditor(props) {
3416
3653
  }
3417
3654
  }
3418
3655
  });
3419
- onMount2(() => {
3656
+ onMount3(() => {
3420
3657
  if (!props.apiKey) {
3421
3658
  logger.error(
3422
3659
  "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
@@ -3439,13 +3676,7 @@ function EnableEditor(props) {
3439
3676
  evaluateJsCode();
3440
3677
  }
3441
3678
  createEffect2(
3442
- on2(
3443
- () => [
3444
- props.builderContextSignal.content?.data?.jsCode,
3445
- props.builderContextSignal.rootState
3446
- ],
3447
- onUpdateFn_2
3448
- )
3679
+ on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
3449
3680
  );
3450
3681
  function onUpdateFn_3() {
3451
3682
  runHttpRequests();
@@ -3762,7 +3993,7 @@ function ContentVariants(props) {
3762
3993
  canTrack: getDefaultCanTrack(props.canTrack)
3763
3994
  });
3764
3995
  }
3765
- onMount3(() => {
3996
+ onMount4(() => {
3766
3997
  setShouldRenderVariants(false);
3767
3998
  });
3768
3999
  return <>
@@ -3874,7 +4105,7 @@ function Symbol(props) {
3874
4105
  }
3875
4106
  });
3876
4107
  }
3877
- onMount4(() => {
4108
+ onMount5(() => {
3878
4109
  setContent();
3879
4110
  });
3880
4111
  function onUpdateFn_0() {
package/lib/edge/dev.js CHANGED
@@ -250,27 +250,43 @@ var runInBrowser = ({
250
250
  builder,
251
251
  context,
252
252
  event,
253
- state: flattenState(rootState, localState, rootSetState)
253
+ state: flattenState({
254
+ rootState,
255
+ localState,
256
+ rootSetState
257
+ })
254
258
  });
255
259
  return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
256
260
  };
257
- function flattenState(rootState, localState, rootSetState) {
258
- if (rootState === localState) {
259
- throw new Error("rootState === localState");
260
- }
261
+ function flattenState({
262
+ rootState,
263
+ localState,
264
+ rootSetState
265
+ }) {
261
266
  return new Proxy(rootState, {
262
- get: (_, prop) => {
267
+ get: (target, prop) => {
263
268
  if (localState && prop in localState) {
264
269
  return localState[prop];
265
270
  }
266
- return rootState[prop];
271
+ const val = target[prop];
272
+ if (typeof val === "object") {
273
+ return flattenState({
274
+ rootState: val,
275
+ localState: void 0,
276
+ rootSetState: rootSetState ? (subState) => {
277
+ target[prop] = subState;
278
+ rootSetState(target);
279
+ } : void 0
280
+ });
281
+ }
282
+ return val;
267
283
  },
268
- set: (_, prop, value) => {
284
+ set: (target, prop, value) => {
269
285
  if (localState && prop in localState) {
270
286
  throw new Error("Writing to local state is not allowed as it is read-only.");
271
287
  }
272
- rootState[prop] = value;
273
- rootSetState?.(rootState);
288
+ target[prop] = value;
289
+ rootSetState?.(target);
274
290
  return true;
275
291
  }
276
292
  });
@@ -3560,6 +3576,212 @@ function getProcessedBlock({
3560
3576
  }
3561
3577
  }
3562
3578
 
3579
+ // src/components/block/animator.ts
3580
+ function throttle(func, wait, options = {}) {
3581
+ let context;
3582
+ let args;
3583
+ let result;
3584
+ let timeout = null;
3585
+ let previous = 0;
3586
+ const later = function() {
3587
+ previous = options.leading === false ? 0 : Date.now();
3588
+ timeout = null;
3589
+ result = func.apply(context, args);
3590
+ if (!timeout)
3591
+ context = args = null;
3592
+ };
3593
+ return function() {
3594
+ const now = Date.now();
3595
+ if (!previous && options.leading === false)
3596
+ previous = now;
3597
+ const remaining = wait - (now - previous);
3598
+ context = this;
3599
+ args = arguments;
3600
+ if (remaining <= 0 || remaining > wait) {
3601
+ if (timeout) {
3602
+ clearTimeout(timeout);
3603
+ timeout = null;
3604
+ }
3605
+ previous = now;
3606
+ result = func.apply(context, args);
3607
+ if (!timeout)
3608
+ context = args = null;
3609
+ } else if (!timeout && options.trailing !== false) {
3610
+ timeout = setTimeout(later, remaining);
3611
+ }
3612
+ return result;
3613
+ };
3614
+ }
3615
+ function assign(target, ..._args) {
3616
+ const to = Object(target);
3617
+ for (let index = 1; index < arguments.length; index++) {
3618
+ const nextSource = arguments[index];
3619
+ if (nextSource != null) {
3620
+ for (const nextKey in nextSource) {
3621
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
3622
+ to[nextKey] = nextSource[nextKey];
3623
+ }
3624
+ }
3625
+ }
3626
+ }
3627
+ return to;
3628
+ }
3629
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
3630
+ function bindAnimations(animations) {
3631
+ for (const animation of animations) {
3632
+ switch (animation.trigger) {
3633
+ case "pageLoad":
3634
+ triggerAnimation(animation);
3635
+ break;
3636
+ case "hover":
3637
+ bindHoverAnimation(animation);
3638
+ break;
3639
+ case "scrollInView":
3640
+ bindScrollInViewAnimation(animation);
3641
+ break;
3642
+ }
3643
+ }
3644
+ }
3645
+ function warnElementNotPresent(id2) {
3646
+ console.warn(`Cannot animate element: element with ID ${id2} not found!`);
3647
+ }
3648
+ function augmentAnimation(animation, element) {
3649
+ const stylesUsed = getAllStylesUsed(animation);
3650
+ const computedStyle = getComputedStyle(element);
3651
+ const firstStyles = animation.steps[0].styles;
3652
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
3653
+ const bothStyles = [firstStyles, lastStyles];
3654
+ for (const styles of bothStyles) {
3655
+ for (const style of stylesUsed) {
3656
+ if (!(style in styles)) {
3657
+ styles[style] = computedStyle[style];
3658
+ }
3659
+ }
3660
+ }
3661
+ }
3662
+ function getAllStylesUsed(animation) {
3663
+ const properties = [];
3664
+ for (const step of animation.steps) {
3665
+ for (const key in step.styles) {
3666
+ if (properties.indexOf(key) === -1) {
3667
+ properties.push(key);
3668
+ }
3669
+ }
3670
+ }
3671
+ return properties;
3672
+ }
3673
+ function triggerAnimation(animation) {
3674
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
3675
+ if (!elements.length) {
3676
+ warnElementNotPresent(animation.elementId || animation.id || "");
3677
+ return;
3678
+ }
3679
+ Array.from(elements).forEach((element) => {
3680
+ augmentAnimation(animation, element);
3681
+ element.style.transition = "none";
3682
+ element.style.transitionDelay = "0";
3683
+ assign(element.style, animation.steps[0].styles);
3684
+ setTimeout(() => {
3685
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
3686
+ if (animation.delay) {
3687
+ element.style.transitionDelay = animation.delay + "s";
3688
+ }
3689
+ assign(element.style, animation.steps[1].styles);
3690
+ setTimeout(() => {
3691
+ element.style.transition = "";
3692
+ element.style.transitionDelay = "";
3693
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
3694
+ });
3695
+ });
3696
+ }
3697
+ function bindHoverAnimation(animation) {
3698
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
3699
+ if (!elements.length) {
3700
+ warnElementNotPresent(animation.elementId || animation.id || "");
3701
+ return;
3702
+ }
3703
+ Array.from(elements).forEach((element) => {
3704
+ augmentAnimation(animation, element);
3705
+ const defaultState = animation.steps[0].styles;
3706
+ const hoverState = animation.steps[1].styles;
3707
+ function attachDefaultState() {
3708
+ assign(element.style, defaultState);
3709
+ }
3710
+ function attachHoverState() {
3711
+ assign(element.style, hoverState);
3712
+ }
3713
+ attachDefaultState();
3714
+ element.addEventListener("mouseenter", attachHoverState);
3715
+ element.addEventListener("mouseleave", attachDefaultState);
3716
+ setTimeout(() => {
3717
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
3718
+ if (animation.delay) {
3719
+ element.style.transitionDelay = animation.delay + "s";
3720
+ }
3721
+ });
3722
+ });
3723
+ }
3724
+ function bindScrollInViewAnimation(animation) {
3725
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
3726
+ if (!elements.length) {
3727
+ warnElementNotPresent(animation.elementId || animation.id || "");
3728
+ return;
3729
+ }
3730
+ Array.from(elements).forEach((element) => {
3731
+ augmentAnimation(animation, element);
3732
+ let triggered = false;
3733
+ let pendingAnimation = false;
3734
+ function immediateOnScroll() {
3735
+ if (!triggered && isScrolledIntoView(element)) {
3736
+ triggered = true;
3737
+ pendingAnimation = true;
3738
+ setTimeout(() => {
3739
+ assign(element.style, animation.steps[1].styles);
3740
+ if (!animation.repeat) {
3741
+ document.removeEventListener("scroll", onScroll);
3742
+ }
3743
+ setTimeout(() => {
3744
+ pendingAnimation = false;
3745
+ if (!animation.repeat) {
3746
+ element.style.transition = "";
3747
+ element.style.transitionDelay = "";
3748
+ }
3749
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
3750
+ });
3751
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
3752
+ triggered = false;
3753
+ assign(element.style, animation.steps[0].styles);
3754
+ }
3755
+ }
3756
+ const onScroll = throttle(immediateOnScroll, 200, {
3757
+ leading: false
3758
+ });
3759
+ function isScrolledIntoView(elem) {
3760
+ const rect = elem.getBoundingClientRect();
3761
+ const windowHeight = window.innerHeight;
3762
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
3763
+ const threshold = thresholdPercent * windowHeight;
3764
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
3765
+ }
3766
+ const defaultState = animation.steps[0].styles;
3767
+ function attachDefaultState() {
3768
+ assign(element.style, defaultState);
3769
+ }
3770
+ attachDefaultState();
3771
+ setTimeout(() => {
3772
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
3773
+ if (animation.delay) {
3774
+ element.style.transitionDelay = animation.delay + "s";
3775
+ }
3776
+ });
3777
+ document.addEventListener("scroll", onScroll, {
3778
+ capture: true,
3779
+ passive: true
3780
+ });
3781
+ immediateOnScroll();
3782
+ });
3783
+ }
3784
+
3563
3785
  // src/components/block/block.helpers.ts
3564
3786
  var getComponent = ({
3565
3787
  block,
@@ -4135,6 +4357,16 @@ function Block(props) {
4135
4357
  isInteractive: !blockComponent()?.isRSC
4136
4358
  };
4137
4359
  }
4360
+ onMount(() => {
4361
+ const blockId = processedBlock().id;
4362
+ const animations = processedBlock().animations;
4363
+ if (animations && blockId) {
4364
+ bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
4365
+ ...animation,
4366
+ elementId: blockId
4367
+ })));
4368
+ }
4369
+ });
4138
4370
  return createComponent(Show, {
4139
4371
  get when() {
4140
4372
  return canShowBlock();
@@ -6547,7 +6779,7 @@ var getInteractionPropertiesForEvent = (event) => {
6547
6779
  };
6548
6780
 
6549
6781
  // src/constants/sdk-version.ts
6550
- var SDK_VERSION = "0.12.5";
6782
+ var SDK_VERSION = "0.12.7";
6551
6783
 
6552
6784
  // src/functions/register.ts
6553
6785
  var registry = {};
@@ -6754,6 +6986,10 @@ function EnableEditor(props) {
6754
6986
  setForceReRenderCount(forceReRenderCount() + 1);
6755
6987
  break;
6756
6988
  }
6989
+ case "builder.triggerAnimation": {
6990
+ triggerAnimation(data.data);
6991
+ break;
6992
+ }
6757
6993
  case "builder.contentUpdate": {
6758
6994
  const messageContent = data.data;
6759
6995
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -6924,7 +7160,7 @@ function EnableEditor(props) {
6924
7160
  function onUpdateFn_2() {
6925
7161
  evaluateJsCode();
6926
7162
  }
6927
- createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode, props.builderContextSignal.rootState], onUpdateFn_2));
7163
+ createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2));
6928
7164
  function onUpdateFn_3() {
6929
7165
  runHttpRequests();
6930
7166
  }