@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) {
@@ -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
  });
@@ -394,6 +410,212 @@ function getProcessedBlock({
394
410
  }
395
411
  }
396
412
 
413
+ // src/components/block/animator.ts
414
+ function throttle(func, wait, options = {}) {
415
+ let context;
416
+ let args;
417
+ let result;
418
+ let timeout = null;
419
+ let previous = 0;
420
+ const later = function() {
421
+ previous = options.leading === false ? 0 : Date.now();
422
+ timeout = null;
423
+ result = func.apply(context, args);
424
+ if (!timeout)
425
+ context = args = null;
426
+ };
427
+ return function() {
428
+ const now = Date.now();
429
+ if (!previous && options.leading === false)
430
+ previous = now;
431
+ const remaining = wait - (now - previous);
432
+ context = this;
433
+ args = arguments;
434
+ if (remaining <= 0 || remaining > wait) {
435
+ if (timeout) {
436
+ clearTimeout(timeout);
437
+ timeout = null;
438
+ }
439
+ previous = now;
440
+ result = func.apply(context, args);
441
+ if (!timeout)
442
+ context = args = null;
443
+ } else if (!timeout && options.trailing !== false) {
444
+ timeout = setTimeout(later, remaining);
445
+ }
446
+ return result;
447
+ };
448
+ }
449
+ function assign(target, ..._args) {
450
+ const to = Object(target);
451
+ for (let index = 1; index < arguments.length; index++) {
452
+ const nextSource = arguments[index];
453
+ if (nextSource != null) {
454
+ for (const nextKey in nextSource) {
455
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
456
+ to[nextKey] = nextSource[nextKey];
457
+ }
458
+ }
459
+ }
460
+ }
461
+ return to;
462
+ }
463
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
464
+ function bindAnimations(animations) {
465
+ for (const animation of animations) {
466
+ switch (animation.trigger) {
467
+ case "pageLoad":
468
+ triggerAnimation(animation);
469
+ break;
470
+ case "hover":
471
+ bindHoverAnimation(animation);
472
+ break;
473
+ case "scrollInView":
474
+ bindScrollInViewAnimation(animation);
475
+ break;
476
+ }
477
+ }
478
+ }
479
+ function warnElementNotPresent(id) {
480
+ console.warn(`Cannot animate element: element with ID ${id} not found!`);
481
+ }
482
+ function augmentAnimation(animation, element) {
483
+ const stylesUsed = getAllStylesUsed(animation);
484
+ const computedStyle = getComputedStyle(element);
485
+ const firstStyles = animation.steps[0].styles;
486
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
487
+ const bothStyles = [firstStyles, lastStyles];
488
+ for (const styles of bothStyles) {
489
+ for (const style of stylesUsed) {
490
+ if (!(style in styles)) {
491
+ styles[style] = computedStyle[style];
492
+ }
493
+ }
494
+ }
495
+ }
496
+ function getAllStylesUsed(animation) {
497
+ const properties = [];
498
+ for (const step of animation.steps) {
499
+ for (const key in step.styles) {
500
+ if (properties.indexOf(key) === -1) {
501
+ properties.push(key);
502
+ }
503
+ }
504
+ }
505
+ return properties;
506
+ }
507
+ function triggerAnimation(animation) {
508
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
509
+ if (!elements.length) {
510
+ warnElementNotPresent(animation.elementId || animation.id || "");
511
+ return;
512
+ }
513
+ Array.from(elements).forEach((element) => {
514
+ augmentAnimation(animation, element);
515
+ element.style.transition = "none";
516
+ element.style.transitionDelay = "0";
517
+ assign(element.style, animation.steps[0].styles);
518
+ setTimeout(() => {
519
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
520
+ if (animation.delay) {
521
+ element.style.transitionDelay = animation.delay + "s";
522
+ }
523
+ assign(element.style, animation.steps[1].styles);
524
+ setTimeout(() => {
525
+ element.style.transition = "";
526
+ element.style.transitionDelay = "";
527
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
528
+ });
529
+ });
530
+ }
531
+ function bindHoverAnimation(animation) {
532
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
533
+ if (!elements.length) {
534
+ warnElementNotPresent(animation.elementId || animation.id || "");
535
+ return;
536
+ }
537
+ Array.from(elements).forEach((element) => {
538
+ augmentAnimation(animation, element);
539
+ const defaultState = animation.steps[0].styles;
540
+ const hoverState = animation.steps[1].styles;
541
+ function attachDefaultState() {
542
+ assign(element.style, defaultState);
543
+ }
544
+ function attachHoverState() {
545
+ assign(element.style, hoverState);
546
+ }
547
+ attachDefaultState();
548
+ element.addEventListener("mouseenter", attachHoverState);
549
+ element.addEventListener("mouseleave", attachDefaultState);
550
+ setTimeout(() => {
551
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
552
+ if (animation.delay) {
553
+ element.style.transitionDelay = animation.delay + "s";
554
+ }
555
+ });
556
+ });
557
+ }
558
+ function bindScrollInViewAnimation(animation) {
559
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
560
+ if (!elements.length) {
561
+ warnElementNotPresent(animation.elementId || animation.id || "");
562
+ return;
563
+ }
564
+ Array.from(elements).forEach((element) => {
565
+ augmentAnimation(animation, element);
566
+ let triggered = false;
567
+ let pendingAnimation = false;
568
+ function immediateOnScroll() {
569
+ if (!triggered && isScrolledIntoView(element)) {
570
+ triggered = true;
571
+ pendingAnimation = true;
572
+ setTimeout(() => {
573
+ assign(element.style, animation.steps[1].styles);
574
+ if (!animation.repeat) {
575
+ document.removeEventListener("scroll", onScroll);
576
+ }
577
+ setTimeout(() => {
578
+ pendingAnimation = false;
579
+ if (!animation.repeat) {
580
+ element.style.transition = "";
581
+ element.style.transitionDelay = "";
582
+ }
583
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
584
+ });
585
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
586
+ triggered = false;
587
+ assign(element.style, animation.steps[0].styles);
588
+ }
589
+ }
590
+ const onScroll = throttle(immediateOnScroll, 200, {
591
+ leading: false
592
+ });
593
+ function isScrolledIntoView(elem) {
594
+ const rect = elem.getBoundingClientRect();
595
+ const windowHeight = window.innerHeight;
596
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
597
+ const threshold = thresholdPercent * windowHeight;
598
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
599
+ }
600
+ const defaultState = animation.steps[0].styles;
601
+ function attachDefaultState() {
602
+ assign(element.style, defaultState);
603
+ }
604
+ attachDefaultState();
605
+ setTimeout(() => {
606
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
607
+ if (animation.delay) {
608
+ element.style.transitionDelay = animation.delay + "s";
609
+ }
610
+ });
611
+ document.addEventListener("scroll", onScroll, {
612
+ capture: true,
613
+ passive: true
614
+ });
615
+ immediateOnScroll();
616
+ });
617
+ }
618
+
397
619
  // src/components/block/block.helpers.ts
398
620
  var getComponent = ({
399
621
  block,
@@ -916,6 +1138,18 @@ function Block(props) {
916
1138
  isInteractive: !blockComponent()?.isRSC
917
1139
  };
918
1140
  }
1141
+ onMount(() => {
1142
+ const blockId = processedBlock().id;
1143
+ const animations = processedBlock().animations;
1144
+ if (animations && blockId) {
1145
+ bindAnimations(
1146
+ animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1147
+ ...animation,
1148
+ elementId: blockId
1149
+ }))
1150
+ );
1151
+ }
1152
+ });
919
1153
  return <Show4 when={canShowBlock()}>
920
1154
  <Block_styles_default block={props.block} context={props.context} />
921
1155
  <Show4
@@ -1364,10 +1598,10 @@ function SectionComponent(props) {
1364
1598
  var section_default = SectionComponent;
1365
1599
 
1366
1600
  // src/blocks/symbol/symbol.tsx
1367
- import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1601
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
1368
1602
 
1369
1603
  // src/components/content-variants/content-variants.tsx
1370
- import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal13 } from "solid-js";
1604
+ import { Show as Show11, For as For5, onMount as onMount4, createSignal as createSignal13 } from "solid-js";
1371
1605
 
1372
1606
  // src/helpers/url.ts
1373
1607
  var getTopLevelDomain = (host) => {
@@ -1845,12 +2079,12 @@ var componentInfo3 = {
1845
2079
  };
1846
2080
 
1847
2081
  // src/blocks/custom-code/custom-code.tsx
1848
- import { onMount, createSignal as createSignal7 } from "solid-js";
2082
+ import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
1849
2083
  function CustomCode(props) {
1850
2084
  const [scriptsInserted, setScriptsInserted] = createSignal7([]);
1851
2085
  const [scriptsRun, setScriptsRun] = createSignal7([]);
1852
2086
  let elementRef;
1853
- onMount(() => {
2087
+ onMount2(() => {
1854
2088
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
1855
2089
  return;
1856
2090
  }
@@ -2571,7 +2805,7 @@ function InlinedScript(props) {
2571
2805
  var Inlined_script_default = InlinedScript;
2572
2806
 
2573
2807
  // src/components/content/components/enable-editor.tsx
2574
- import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2808
+ import { Show as Show9, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2575
2809
  import { Dynamic as Dynamic5 } from "solid-js/web";
2576
2810
 
2577
2811
  // src/helpers/preview-lru-cache/get.ts
@@ -3066,7 +3300,7 @@ var getInteractionPropertiesForEvent = (event) => {
3066
3300
  };
3067
3301
 
3068
3302
  // src/constants/sdk-version.ts
3069
- var SDK_VERSION = "0.12.5";
3303
+ var SDK_VERSION = "0.12.7";
3070
3304
 
3071
3305
  // src/functions/register.ts
3072
3306
  var registry = {};
@@ -3270,6 +3504,10 @@ function EnableEditor(props) {
3270
3504
  setForceReRenderCount(forceReRenderCount() + 1);
3271
3505
  break;
3272
3506
  }
3507
+ case "builder.triggerAnimation": {
3508
+ triggerAnimation(data.data);
3509
+ break;
3510
+ }
3273
3511
  case "builder.contentUpdate": {
3274
3512
  const messageContent = data.data;
3275
3513
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -3367,7 +3605,7 @@ function EnableEditor(props) {
3367
3605
  }
3368
3606
  }
3369
3607
  let elementRef;
3370
- onMount2(() => {
3608
+ onMount3(() => {
3371
3609
  if (isBrowser()) {
3372
3610
  if (isEditing() && true) {
3373
3611
  setForceReRenderCount(forceReRenderCount() + 1);
@@ -3432,7 +3670,7 @@ function EnableEditor(props) {
3432
3670
  }
3433
3671
  }
3434
3672
  });
3435
- onMount2(() => {
3673
+ onMount3(() => {
3436
3674
  if (!props.apiKey) {
3437
3675
  logger.error(
3438
3676
  "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
@@ -3455,13 +3693,7 @@ function EnableEditor(props) {
3455
3693
  evaluateJsCode();
3456
3694
  }
3457
3695
  createEffect2(
3458
- on2(
3459
- () => [
3460
- props.builderContextSignal.content?.data?.jsCode,
3461
- props.builderContextSignal.rootState
3462
- ],
3463
- onUpdateFn_2
3464
- )
3696
+ on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
3465
3697
  );
3466
3698
  function onUpdateFn_3() {
3467
3699
  runHttpRequests();
@@ -3778,7 +4010,7 @@ function ContentVariants(props) {
3778
4010
  canTrack: getDefaultCanTrack(props.canTrack)
3779
4011
  });
3780
4012
  }
3781
- onMount3(() => {
4013
+ onMount4(() => {
3782
4014
  setShouldRenderVariants(false);
3783
4015
  });
3784
4016
  return <>
@@ -3890,7 +4122,7 @@ function Symbol(props) {
3890
4122
  }
3891
4123
  });
3892
4124
  }
3893
- onMount4(() => {
4125
+ onMount5(() => {
3894
4126
  setContent();
3895
4127
  });
3896
4128
  function onUpdateFn_0() {
@@ -242,27 +242,43 @@ var runInBrowser = ({
242
242
  builder,
243
243
  context,
244
244
  event,
245
- state: flattenState(rootState, localState, rootSetState)
245
+ state: flattenState({
246
+ rootState,
247
+ localState,
248
+ rootSetState
249
+ })
246
250
  });
247
251
  return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
248
252
  };
249
- function flattenState(rootState, localState, rootSetState) {
250
- if (rootState === localState) {
251
- throw new Error("rootState === localState");
252
- }
253
+ function flattenState({
254
+ rootState,
255
+ localState,
256
+ rootSetState
257
+ }) {
253
258
  return new Proxy(rootState, {
254
- get: (_, prop) => {
259
+ get: (target, prop) => {
255
260
  if (localState && prop in localState) {
256
261
  return localState[prop];
257
262
  }
258
- return rootState[prop];
263
+ const val = target[prop];
264
+ if (typeof val === "object") {
265
+ return flattenState({
266
+ rootState: val,
267
+ localState: void 0,
268
+ rootSetState: rootSetState ? (subState) => {
269
+ target[prop] = subState;
270
+ rootSetState(target);
271
+ } : void 0
272
+ });
273
+ }
274
+ return val;
259
275
  },
260
- set: (_, prop, value) => {
276
+ set: (target, prop, value) => {
261
277
  if (localState && prop in localState) {
262
278
  throw new Error("Writing to local state is not allowed as it is read-only.");
263
279
  }
264
- rootState[prop] = value;
265
- rootSetState?.(rootState);
280
+ target[prop] = value;
281
+ rootSetState?.(target);
266
282
  return true;
267
283
  }
268
284
  });
@@ -405,6 +421,211 @@ function getProcessedBlock({
405
421
  }
406
422
  }
407
423
 
424
+ // src/components/block/animator.ts
425
+ function throttle(func, wait, options = {}) {
426
+ let context;
427
+ let args;
428
+ let result;
429
+ let timeout = null;
430
+ let previous = 0;
431
+ const later = function() {
432
+ previous = options.leading === false ? 0 : Date.now();
433
+ timeout = null;
434
+ result = func.apply(context, args);
435
+ if (!timeout)
436
+ context = args = null;
437
+ };
438
+ return function() {
439
+ const now = Date.now();
440
+ if (!previous && options.leading === false)
441
+ previous = now;
442
+ const remaining = wait - (now - previous);
443
+ context = this;
444
+ args = arguments;
445
+ if (remaining <= 0 || remaining > wait) {
446
+ if (timeout) {
447
+ clearTimeout(timeout);
448
+ timeout = null;
449
+ }
450
+ previous = now;
451
+ result = func.apply(context, args);
452
+ if (!timeout)
453
+ context = args = null;
454
+ } else if (!timeout && options.trailing !== false) {
455
+ timeout = setTimeout(later, remaining);
456
+ }
457
+ return result;
458
+ };
459
+ }
460
+ function assign(target, ..._args) {
461
+ const to = Object(target);
462
+ for (let index = 1; index < arguments.length; index++) {
463
+ const nextSource = arguments[index];
464
+ if (nextSource != null) {
465
+ for (const nextKey in nextSource) {
466
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
467
+ to[nextKey] = nextSource[nextKey];
468
+ }
469
+ }
470
+ }
471
+ }
472
+ return to;
473
+ }
474
+ var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
475
+ function bindAnimations(animations) {
476
+ for (const animation of animations) {
477
+ switch (animation.trigger) {
478
+ case "pageLoad":
479
+ triggerAnimation(animation);
480
+ break;
481
+ case "hover":
482
+ bindHoverAnimation(animation);
483
+ break;
484
+ case "scrollInView":
485
+ bindScrollInViewAnimation(animation);
486
+ break;
487
+ }
488
+ }
489
+ }
490
+ function warnElementNotPresent(id) {
491
+ }
492
+ function augmentAnimation(animation, element) {
493
+ const stylesUsed = getAllStylesUsed(animation);
494
+ const computedStyle = getComputedStyle(element);
495
+ const firstStyles = animation.steps[0].styles;
496
+ const lastStyles = animation.steps[animation.steps.length - 1].styles;
497
+ const bothStyles = [firstStyles, lastStyles];
498
+ for (const styles of bothStyles) {
499
+ for (const style of stylesUsed) {
500
+ if (!(style in styles)) {
501
+ styles[style] = computedStyle[style];
502
+ }
503
+ }
504
+ }
505
+ }
506
+ function getAllStylesUsed(animation) {
507
+ const properties = [];
508
+ for (const step of animation.steps) {
509
+ for (const key in step.styles) {
510
+ if (properties.indexOf(key) === -1) {
511
+ properties.push(key);
512
+ }
513
+ }
514
+ }
515
+ return properties;
516
+ }
517
+ function triggerAnimation(animation) {
518
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
519
+ if (!elements.length) {
520
+ warnElementNotPresent(animation.elementId || animation.id || "");
521
+ return;
522
+ }
523
+ Array.from(elements).forEach((element) => {
524
+ augmentAnimation(animation, element);
525
+ element.style.transition = "none";
526
+ element.style.transitionDelay = "0";
527
+ assign(element.style, animation.steps[0].styles);
528
+ setTimeout(() => {
529
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
530
+ if (animation.delay) {
531
+ element.style.transitionDelay = animation.delay + "s";
532
+ }
533
+ assign(element.style, animation.steps[1].styles);
534
+ setTimeout(() => {
535
+ element.style.transition = "";
536
+ element.style.transitionDelay = "";
537
+ }, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
538
+ });
539
+ });
540
+ }
541
+ function bindHoverAnimation(animation) {
542
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
543
+ if (!elements.length) {
544
+ warnElementNotPresent(animation.elementId || animation.id || "");
545
+ return;
546
+ }
547
+ Array.from(elements).forEach((element) => {
548
+ augmentAnimation(animation, element);
549
+ const defaultState = animation.steps[0].styles;
550
+ const hoverState = animation.steps[1].styles;
551
+ function attachDefaultState() {
552
+ assign(element.style, defaultState);
553
+ }
554
+ function attachHoverState() {
555
+ assign(element.style, hoverState);
556
+ }
557
+ attachDefaultState();
558
+ element.addEventListener("mouseenter", attachHoverState);
559
+ element.addEventListener("mouseleave", attachDefaultState);
560
+ setTimeout(() => {
561
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
562
+ if (animation.delay) {
563
+ element.style.transitionDelay = animation.delay + "s";
564
+ }
565
+ });
566
+ });
567
+ }
568
+ function bindScrollInViewAnimation(animation) {
569
+ const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
570
+ if (!elements.length) {
571
+ warnElementNotPresent(animation.elementId || animation.id || "");
572
+ return;
573
+ }
574
+ Array.from(elements).forEach((element) => {
575
+ augmentAnimation(animation, element);
576
+ let triggered = false;
577
+ let pendingAnimation = false;
578
+ function immediateOnScroll() {
579
+ if (!triggered && isScrolledIntoView(element)) {
580
+ triggered = true;
581
+ pendingAnimation = true;
582
+ setTimeout(() => {
583
+ assign(element.style, animation.steps[1].styles);
584
+ if (!animation.repeat) {
585
+ document.removeEventListener("scroll", onScroll);
586
+ }
587
+ setTimeout(() => {
588
+ pendingAnimation = false;
589
+ if (!animation.repeat) {
590
+ element.style.transition = "";
591
+ element.style.transitionDelay = "";
592
+ }
593
+ }, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
594
+ });
595
+ } else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
596
+ triggered = false;
597
+ assign(element.style, animation.steps[0].styles);
598
+ }
599
+ }
600
+ const onScroll = throttle(immediateOnScroll, 200, {
601
+ leading: false
602
+ });
603
+ function isScrolledIntoView(elem) {
604
+ const rect = elem.getBoundingClientRect();
605
+ const windowHeight = window.innerHeight;
606
+ const thresholdPercent = (animation.thresholdPercent || 0) / 100;
607
+ const threshold = thresholdPercent * windowHeight;
608
+ return rect.bottom > threshold && rect.top < windowHeight - threshold;
609
+ }
610
+ const defaultState = animation.steps[0].styles;
611
+ function attachDefaultState() {
612
+ assign(element.style, defaultState);
613
+ }
614
+ attachDefaultState();
615
+ setTimeout(() => {
616
+ element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
617
+ if (animation.delay) {
618
+ element.style.transitionDelay = animation.delay + "s";
619
+ }
620
+ });
621
+ document.addEventListener("scroll", onScroll, {
622
+ capture: true,
623
+ passive: true
624
+ });
625
+ immediateOnScroll();
626
+ });
627
+ }
628
+
408
629
  // src/components/block/block.helpers.ts
409
630
  var getComponent = ({
410
631
  block,
@@ -977,6 +1198,16 @@ function Block(props) {
977
1198
  isInteractive: !blockComponent()?.isRSC
978
1199
  };
979
1200
  }
1201
+ onMount(() => {
1202
+ const blockId = processedBlock().id;
1203
+ const animations = processedBlock().animations;
1204
+ if (animations && blockId) {
1205
+ bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1206
+ ...animation,
1207
+ elementId: blockId
1208
+ })));
1209
+ }
1210
+ });
980
1211
  return createComponent(Show, {
981
1212
  get when() {
982
1213
  return canShowBlock();
@@ -3380,7 +3611,7 @@ var getInteractionPropertiesForEvent = (event) => {
3380
3611
  };
3381
3612
 
3382
3613
  // src/constants/sdk-version.ts
3383
- var SDK_VERSION = "0.12.5";
3614
+ var SDK_VERSION = "0.12.7";
3384
3615
 
3385
3616
  // src/functions/register.ts
3386
3617
  var registry = {};
@@ -3586,6 +3817,10 @@ function EnableEditor(props) {
3586
3817
  setForceReRenderCount(forceReRenderCount() + 1);
3587
3818
  break;
3588
3819
  }
3820
+ case "builder.triggerAnimation": {
3821
+ triggerAnimation(data.data);
3822
+ break;
3823
+ }
3589
3824
  case "builder.contentUpdate": {
3590
3825
  const messageContent = data.data;
3591
3826
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -3755,7 +3990,7 @@ function EnableEditor(props) {
3755
3990
  function onUpdateFn_2() {
3756
3991
  evaluateJsCode();
3757
3992
  }
3758
- createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode, props.builderContextSignal.rootState], onUpdateFn_2));
3993
+ createEffect(on(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2));
3759
3994
  function onUpdateFn_3() {
3760
3995
  runHttpRequests();
3761
3996
  }