@builder.io/sdk-solid 0.12.6 → 0.12.8
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 +125 -84
- package/lib/browser/dev.js +298 -31
- package/lib/browser/dev.jsx +310 -38
- package/lib/browser/index.js +297 -31
- package/lib/browser/index.jsx +309 -38
- package/lib/edge/dev.js +298 -31
- package/lib/edge/dev.jsx +310 -38
- package/lib/edge/index.js +297 -31
- package/lib/edge/index.jsx +309 -38
- package/lib/node/dev.js +298 -31
- package/lib/node/dev.jsx +310 -38
- package/lib/node/index.js +297 -31
- package/lib/node/index.jsx +309 -38
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,23 @@ interface JSONObject$1 {
|
|
|
6
6
|
}
|
|
7
7
|
interface JSONArray$1 extends Array<JSONValue$1> {
|
|
8
8
|
}
|
|
9
|
+
interface AnimationStep {
|
|
10
|
+
styles: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
delay?: number;
|
|
14
|
+
}
|
|
15
|
+
interface BuilderAnimation {
|
|
16
|
+
elementId: string;
|
|
17
|
+
trigger: string;
|
|
18
|
+
steps: AnimationStep[];
|
|
19
|
+
duration: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
easing?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
repeat?: boolean;
|
|
24
|
+
thresholdPercent?: number;
|
|
25
|
+
}
|
|
9
26
|
/** @todo typedoc this */
|
|
10
27
|
interface BuilderBlock {
|
|
11
28
|
'@type': '@builder.io/sdk:Element';
|
|
@@ -54,7 +71,7 @@ interface BuilderBlock {
|
|
|
54
71
|
collection: string;
|
|
55
72
|
itemName?: string;
|
|
56
73
|
} | null;
|
|
57
|
-
animations?:
|
|
74
|
+
animations?: BuilderAnimation[];
|
|
58
75
|
style?: Partial<CSSStyleDeclaration>;
|
|
59
76
|
href?: string;
|
|
60
77
|
/**
|
|
@@ -701,6 +718,86 @@ type Settings = {
|
|
|
701
718
|
};
|
|
702
719
|
declare function setEditorSettings(newSettings: Settings): void;
|
|
703
720
|
|
|
721
|
+
type QueryObject = Record<string, string | string[]>;
|
|
722
|
+
/**
|
|
723
|
+
* Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
|
|
724
|
+
* relevant to the Builder SDK.
|
|
725
|
+
*
|
|
726
|
+
* @returns
|
|
727
|
+
*/
|
|
728
|
+
declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
|
|
729
|
+
|
|
730
|
+
interface Event {
|
|
731
|
+
/**
|
|
732
|
+
* The type of your event.
|
|
733
|
+
*
|
|
734
|
+
* Examples: `click`, `conversion`, `pageview`, `impression`
|
|
735
|
+
*/
|
|
736
|
+
type: string;
|
|
737
|
+
data: {
|
|
738
|
+
/**
|
|
739
|
+
* (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
|
|
740
|
+
*/
|
|
741
|
+
contentId?: string;
|
|
742
|
+
/**
|
|
743
|
+
* This is the ID of the space that the content belongs to.
|
|
744
|
+
*/
|
|
745
|
+
ownerId: string;
|
|
746
|
+
/**
|
|
747
|
+
* (Optional) metadata that you want to provide with your event.
|
|
748
|
+
*/
|
|
749
|
+
metadata?: Dictionary<any>;
|
|
750
|
+
/**
|
|
751
|
+
* Session ID of the user. This is provided by the SDK by checking session storage.
|
|
752
|
+
*/
|
|
753
|
+
sessionId: string | undefined;
|
|
754
|
+
/**
|
|
755
|
+
* Visitor ID of the user. This is provided by the SDK by checking cookies.
|
|
756
|
+
*/
|
|
757
|
+
visitorId: string | undefined;
|
|
758
|
+
/**
|
|
759
|
+
* (Optional) If running an A/B test, the ID of the variation that the user is in.
|
|
760
|
+
*/
|
|
761
|
+
variationId?: string;
|
|
762
|
+
[index: string]: any;
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId' | 'metadata'> & {
|
|
766
|
+
/**
|
|
767
|
+
* Your organization's API key.
|
|
768
|
+
*/
|
|
769
|
+
apiKey: Event['data']['ownerId'];
|
|
770
|
+
/**
|
|
771
|
+
* (Optional) Any additional (non-metadata) properties to add to the event.
|
|
772
|
+
*/
|
|
773
|
+
[index: string]: any;
|
|
774
|
+
};
|
|
775
|
+
declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
776
|
+
|
|
777
|
+
type SubscribeToEditor = (
|
|
778
|
+
/**
|
|
779
|
+
* The Builder `model` to subscribe to
|
|
780
|
+
*/
|
|
781
|
+
model: string,
|
|
782
|
+
/**
|
|
783
|
+
* The callback function to call when the content is updated.
|
|
784
|
+
*/
|
|
785
|
+
callback: (updatedContent: BuilderContent) => void,
|
|
786
|
+
/**
|
|
787
|
+
* Extra options for the listener.
|
|
788
|
+
*/
|
|
789
|
+
options?: {
|
|
790
|
+
/**
|
|
791
|
+
* List of hosts to allow editing content from.
|
|
792
|
+
*/
|
|
793
|
+
trustedHosts?: string[] | undefined;
|
|
794
|
+
}) => () => void;
|
|
795
|
+
/**
|
|
796
|
+
* Subscribes to the Builder editor and listens to `content` updates of a certain `model`.
|
|
797
|
+
* Sends the updated `content` to the `callback` function.
|
|
798
|
+
*/
|
|
799
|
+
declare const subscribeToEditor: SubscribeToEditor;
|
|
800
|
+
|
|
704
801
|
interface GetContentOptions {
|
|
705
802
|
/** The model to get content for (required) */
|
|
706
803
|
model: string;
|
|
@@ -844,88 +941,6 @@ interface GetContentOptions {
|
|
|
844
941
|
includeUnpublished?: boolean;
|
|
845
942
|
}
|
|
846
943
|
|
|
847
|
-
/**
|
|
848
|
-
* Returns the first content entry that matches the given options.
|
|
849
|
-
*/
|
|
850
|
-
declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
851
|
-
/**
|
|
852
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
853
|
-
*
|
|
854
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
855
|
-
*/
|
|
856
|
-
declare const getContent: typeof fetchOneEntry;
|
|
857
|
-
type ContentResults = {
|
|
858
|
-
results: BuilderContent[];
|
|
859
|
-
};
|
|
860
|
-
/**
|
|
861
|
-
* @internal Exported only for testing purposes. Do not use.
|
|
862
|
-
*/
|
|
863
|
-
declare const _processContentResult: (options: GetContentOptions, content: ContentResults, url?: URL) => Promise<BuilderContent[]>;
|
|
864
|
-
/**
|
|
865
|
-
* Returns a paginated array of entries that match the given options.
|
|
866
|
-
*/
|
|
867
|
-
declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
868
|
-
/**
|
|
869
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
870
|
-
*/
|
|
871
|
-
declare const getAllContent: typeof fetchEntries;
|
|
872
|
-
|
|
873
|
-
type QueryObject = Record<string, string | string[]>;
|
|
874
|
-
/**
|
|
875
|
-
* Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
|
|
876
|
-
* relevant to the Builder SDK.
|
|
877
|
-
*
|
|
878
|
-
* @returns
|
|
879
|
-
*/
|
|
880
|
-
declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
|
|
881
|
-
|
|
882
|
-
interface Event {
|
|
883
|
-
/**
|
|
884
|
-
* The type of your event.
|
|
885
|
-
*
|
|
886
|
-
* Examples: `click`, `conversion`, `pageview`, `impression`
|
|
887
|
-
*/
|
|
888
|
-
type: string;
|
|
889
|
-
data: {
|
|
890
|
-
/**
|
|
891
|
-
* (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
|
|
892
|
-
*/
|
|
893
|
-
contentId?: string;
|
|
894
|
-
/**
|
|
895
|
-
* This is the ID of the space that the content belongs to.
|
|
896
|
-
*/
|
|
897
|
-
ownerId: string;
|
|
898
|
-
/**
|
|
899
|
-
* (Optional) metadata that you want to provide with your event.
|
|
900
|
-
*/
|
|
901
|
-
metadata?: Dictionary<any>;
|
|
902
|
-
/**
|
|
903
|
-
* Session ID of the user. This is provided by the SDK by checking session storage.
|
|
904
|
-
*/
|
|
905
|
-
sessionId: string | undefined;
|
|
906
|
-
/**
|
|
907
|
-
* Visitor ID of the user. This is provided by the SDK by checking cookies.
|
|
908
|
-
*/
|
|
909
|
-
visitorId: string | undefined;
|
|
910
|
-
/**
|
|
911
|
-
* (Optional) If running an A/B test, the ID of the variation that the user is in.
|
|
912
|
-
*/
|
|
913
|
-
variationId?: string;
|
|
914
|
-
[index: string]: any;
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId' | 'metadata'> & {
|
|
918
|
-
/**
|
|
919
|
-
* Your organization's API key.
|
|
920
|
-
*/
|
|
921
|
-
apiKey: Event['data']['ownerId'];
|
|
922
|
-
/**
|
|
923
|
-
* (Optional) Any additional (non-metadata) properties to add to the event.
|
|
924
|
-
*/
|
|
925
|
-
[index: string]: any;
|
|
926
|
-
};
|
|
927
|
-
declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
928
|
-
|
|
929
944
|
type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
930
945
|
model?: string;
|
|
931
946
|
}) & ({
|
|
@@ -976,4 +991,30 @@ type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
|
976
991
|
*/
|
|
977
992
|
declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<ContentVariantsPrps>;
|
|
978
993
|
|
|
979
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Returns the first content entry that matches the given options.
|
|
996
|
+
*/
|
|
997
|
+
declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
998
|
+
/**
|
|
999
|
+
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
1000
|
+
*
|
|
1001
|
+
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
1002
|
+
*/
|
|
1003
|
+
declare const getContent: typeof fetchOneEntry;
|
|
1004
|
+
type ContentResults = {
|
|
1005
|
+
results: BuilderContent[];
|
|
1006
|
+
};
|
|
1007
|
+
/**
|
|
1008
|
+
* @internal Exported only for testing purposes. Do not use.
|
|
1009
|
+
*/
|
|
1010
|
+
declare const _processContentResult: (options: GetContentOptions, content: ContentResults, url?: URL) => Promise<BuilderContent[]>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Returns a paginated array of entries that match the given options.
|
|
1013
|
+
*/
|
|
1014
|
+
declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
1015
|
+
/**
|
|
1016
|
+
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
1017
|
+
*/
|
|
1018
|
+
declare const getAllContent: typeof fetchEntries;
|
|
1019
|
+
|
|
1020
|
+
export { Blocks, BlocksProps, BuilderBlock, BuilderContent, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RenderBlocks, RenderContent, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|
package/lib/browser/dev.js
CHANGED
|
@@ -423,6 +423,212 @@ function getProcessedBlock({
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
// src/components/block/animator.ts
|
|
427
|
+
function throttle(func, wait, options = {}) {
|
|
428
|
+
let context;
|
|
429
|
+
let args;
|
|
430
|
+
let result;
|
|
431
|
+
let timeout = null;
|
|
432
|
+
let previous = 0;
|
|
433
|
+
const later = function() {
|
|
434
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
435
|
+
timeout = null;
|
|
436
|
+
result = func.apply(context, args);
|
|
437
|
+
if (!timeout)
|
|
438
|
+
context = args = null;
|
|
439
|
+
};
|
|
440
|
+
return function() {
|
|
441
|
+
const now = Date.now();
|
|
442
|
+
if (!previous && options.leading === false)
|
|
443
|
+
previous = now;
|
|
444
|
+
const remaining = wait - (now - previous);
|
|
445
|
+
context = this;
|
|
446
|
+
args = arguments;
|
|
447
|
+
if (remaining <= 0 || remaining > wait) {
|
|
448
|
+
if (timeout) {
|
|
449
|
+
clearTimeout(timeout);
|
|
450
|
+
timeout = null;
|
|
451
|
+
}
|
|
452
|
+
previous = now;
|
|
453
|
+
result = func.apply(context, args);
|
|
454
|
+
if (!timeout)
|
|
455
|
+
context = args = null;
|
|
456
|
+
} else if (!timeout && options.trailing !== false) {
|
|
457
|
+
timeout = setTimeout(later, remaining);
|
|
458
|
+
}
|
|
459
|
+
return result;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function assign(target, ..._args) {
|
|
463
|
+
const to = Object(target);
|
|
464
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
465
|
+
const nextSource = arguments[index];
|
|
466
|
+
if (nextSource != null) {
|
|
467
|
+
for (const nextKey in nextSource) {
|
|
468
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
469
|
+
to[nextKey] = nextSource[nextKey];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return to;
|
|
475
|
+
}
|
|
476
|
+
var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
477
|
+
function bindAnimations(animations) {
|
|
478
|
+
for (const animation of animations) {
|
|
479
|
+
switch (animation.trigger) {
|
|
480
|
+
case "pageLoad":
|
|
481
|
+
triggerAnimation(animation);
|
|
482
|
+
break;
|
|
483
|
+
case "hover":
|
|
484
|
+
bindHoverAnimation(animation);
|
|
485
|
+
break;
|
|
486
|
+
case "scrollInView":
|
|
487
|
+
bindScrollInViewAnimation(animation);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function warnElementNotPresent(id) {
|
|
493
|
+
console.warn(`Cannot animate element: element with ID ${id} not found!`);
|
|
494
|
+
}
|
|
495
|
+
function augmentAnimation(animation, element) {
|
|
496
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
497
|
+
const computedStyle = getComputedStyle(element);
|
|
498
|
+
const firstStyles = animation.steps[0].styles;
|
|
499
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
500
|
+
const bothStyles = [firstStyles, lastStyles];
|
|
501
|
+
for (const styles of bothStyles) {
|
|
502
|
+
for (const style of stylesUsed) {
|
|
503
|
+
if (!(style in styles)) {
|
|
504
|
+
styles[style] = computedStyle[style];
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function getAllStylesUsed(animation) {
|
|
510
|
+
const properties = [];
|
|
511
|
+
for (const step of animation.steps) {
|
|
512
|
+
for (const key in step.styles) {
|
|
513
|
+
if (properties.indexOf(key) === -1) {
|
|
514
|
+
properties.push(key);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return properties;
|
|
519
|
+
}
|
|
520
|
+
function triggerAnimation(animation) {
|
|
521
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
522
|
+
if (!elements.length) {
|
|
523
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
Array.from(elements).forEach((element) => {
|
|
527
|
+
augmentAnimation(animation, element);
|
|
528
|
+
element.style.transition = "none";
|
|
529
|
+
element.style.transitionDelay = "0";
|
|
530
|
+
assign(element.style, animation.steps[0].styles);
|
|
531
|
+
setTimeout(() => {
|
|
532
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
533
|
+
if (animation.delay) {
|
|
534
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
535
|
+
}
|
|
536
|
+
assign(element.style, animation.steps[1].styles);
|
|
537
|
+
setTimeout(() => {
|
|
538
|
+
element.style.transition = "";
|
|
539
|
+
element.style.transitionDelay = "";
|
|
540
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function bindHoverAnimation(animation) {
|
|
545
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
546
|
+
if (!elements.length) {
|
|
547
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
Array.from(elements).forEach((element) => {
|
|
551
|
+
augmentAnimation(animation, element);
|
|
552
|
+
const defaultState = animation.steps[0].styles;
|
|
553
|
+
const hoverState = animation.steps[1].styles;
|
|
554
|
+
function attachDefaultState() {
|
|
555
|
+
assign(element.style, defaultState);
|
|
556
|
+
}
|
|
557
|
+
function attachHoverState() {
|
|
558
|
+
assign(element.style, hoverState);
|
|
559
|
+
}
|
|
560
|
+
attachDefaultState();
|
|
561
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
562
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
563
|
+
setTimeout(() => {
|
|
564
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
565
|
+
if (animation.delay) {
|
|
566
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function bindScrollInViewAnimation(animation) {
|
|
572
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
573
|
+
if (!elements.length) {
|
|
574
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
Array.from(elements).forEach((element) => {
|
|
578
|
+
augmentAnimation(animation, element);
|
|
579
|
+
let triggered = false;
|
|
580
|
+
let pendingAnimation = false;
|
|
581
|
+
function immediateOnScroll() {
|
|
582
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
583
|
+
triggered = true;
|
|
584
|
+
pendingAnimation = true;
|
|
585
|
+
setTimeout(() => {
|
|
586
|
+
assign(element.style, animation.steps[1].styles);
|
|
587
|
+
if (!animation.repeat) {
|
|
588
|
+
document.removeEventListener("scroll", onScroll);
|
|
589
|
+
}
|
|
590
|
+
setTimeout(() => {
|
|
591
|
+
pendingAnimation = false;
|
|
592
|
+
if (!animation.repeat) {
|
|
593
|
+
element.style.transition = "";
|
|
594
|
+
element.style.transitionDelay = "";
|
|
595
|
+
}
|
|
596
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
597
|
+
});
|
|
598
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
599
|
+
triggered = false;
|
|
600
|
+
assign(element.style, animation.steps[0].styles);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
604
|
+
leading: false
|
|
605
|
+
});
|
|
606
|
+
function isScrolledIntoView(elem) {
|
|
607
|
+
const rect = elem.getBoundingClientRect();
|
|
608
|
+
const windowHeight = window.innerHeight;
|
|
609
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
610
|
+
const threshold = thresholdPercent * windowHeight;
|
|
611
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
612
|
+
}
|
|
613
|
+
const defaultState = animation.steps[0].styles;
|
|
614
|
+
function attachDefaultState() {
|
|
615
|
+
assign(element.style, defaultState);
|
|
616
|
+
}
|
|
617
|
+
attachDefaultState();
|
|
618
|
+
setTimeout(() => {
|
|
619
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
620
|
+
if (animation.delay) {
|
|
621
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
document.addEventListener("scroll", onScroll, {
|
|
625
|
+
capture: true,
|
|
626
|
+
passive: true
|
|
627
|
+
});
|
|
628
|
+
immediateOnScroll();
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
426
632
|
// src/components/block/block.helpers.ts
|
|
427
633
|
var getComponent = ({
|
|
428
634
|
block,
|
|
@@ -998,6 +1204,16 @@ function Block(props) {
|
|
|
998
1204
|
isInteractive: !blockComponent()?.isRSC
|
|
999
1205
|
};
|
|
1000
1206
|
}
|
|
1207
|
+
onMount(() => {
|
|
1208
|
+
const blockId = processedBlock().id;
|
|
1209
|
+
const animations = processedBlock().animations;
|
|
1210
|
+
if (animations && blockId) {
|
|
1211
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
1212
|
+
...animation,
|
|
1213
|
+
elementId: blockId
|
|
1214
|
+
})));
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1001
1217
|
return createComponent(Show, {
|
|
1002
1218
|
get when() {
|
|
1003
1219
|
return canShowBlock();
|
|
@@ -3152,13 +3368,6 @@ async function fetchEntries(options) {
|
|
|
3152
3368
|
}
|
|
3153
3369
|
var getAllContent = fetchEntries;
|
|
3154
3370
|
|
|
3155
|
-
// src/functions/is-from-trusted-host.ts
|
|
3156
|
-
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3157
|
-
function isFromTrustedHost(trustedHosts, e) {
|
|
3158
|
-
const url = new URL(e.origin), hostname = url.hostname;
|
|
3159
|
-
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3162
3371
|
// src/functions/is-previewing.ts
|
|
3163
3372
|
function isPreviewing() {
|
|
3164
3373
|
if (!isBrowser()) {
|
|
@@ -3409,8 +3618,15 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3409
3618
|
};
|
|
3410
3619
|
};
|
|
3411
3620
|
|
|
3621
|
+
// src/functions/is-from-trusted-host.ts
|
|
3622
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3623
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
3624
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
3625
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3412
3628
|
// src/constants/sdk-version.ts
|
|
3413
|
-
var SDK_VERSION = "0.12.
|
|
3629
|
+
var SDK_VERSION = "0.12.8";
|
|
3414
3630
|
|
|
3415
3631
|
// src/functions/register.ts
|
|
3416
3632
|
var registry = {};
|
|
@@ -3547,6 +3763,66 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3547
3763
|
}
|
|
3548
3764
|
};
|
|
3549
3765
|
|
|
3766
|
+
// src/helpers/subscribe-to-editor.ts
|
|
3767
|
+
var createEditorListener = ({
|
|
3768
|
+
model,
|
|
3769
|
+
trustedHosts,
|
|
3770
|
+
callbacks
|
|
3771
|
+
}) => {
|
|
3772
|
+
return (event) => {
|
|
3773
|
+
if (!isFromTrustedHost(trustedHosts, event)) {
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3776
|
+
const {
|
|
3777
|
+
data
|
|
3778
|
+
} = event;
|
|
3779
|
+
if (data) {
|
|
3780
|
+
switch (data.type) {
|
|
3781
|
+
case "builder.configureSdk": {
|
|
3782
|
+
callbacks.configureSdk(data.data);
|
|
3783
|
+
break;
|
|
3784
|
+
}
|
|
3785
|
+
case "builder.triggerAnimation": {
|
|
3786
|
+
callbacks.animation(data.data);
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
case "builder.contentUpdate": {
|
|
3790
|
+
const messageContent = data.data;
|
|
3791
|
+
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
3792
|
+
const contentData = messageContent.data;
|
|
3793
|
+
if (key === model) {
|
|
3794
|
+
callbacks.contentUpdate(contentData);
|
|
3795
|
+
}
|
|
3796
|
+
break;
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
};
|
|
3801
|
+
};
|
|
3802
|
+
var subscribeToEditor = (model, callback, options) => {
|
|
3803
|
+
if (!isBrowser) {
|
|
3804
|
+
logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
|
|
3805
|
+
return () => {
|
|
3806
|
+
};
|
|
3807
|
+
}
|
|
3808
|
+
setupBrowserForEditing();
|
|
3809
|
+
const listener = createEditorListener({
|
|
3810
|
+
callbacks: {
|
|
3811
|
+
contentUpdate: callback,
|
|
3812
|
+
animation: () => {
|
|
3813
|
+
},
|
|
3814
|
+
configureSdk: () => {
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
model,
|
|
3818
|
+
trustedHosts: options?.trustedHosts
|
|
3819
|
+
});
|
|
3820
|
+
window.addEventListener("message", listener);
|
|
3821
|
+
return () => {
|
|
3822
|
+
window.removeEventListener("message", listener);
|
|
3823
|
+
};
|
|
3824
|
+
};
|
|
3825
|
+
|
|
3550
3826
|
// src/components/content/components/enable-editor.tsx
|
|
3551
3827
|
function EnableEditor(props) {
|
|
3552
3828
|
const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
|
|
@@ -3590,16 +3866,11 @@ function EnableEditor(props) {
|
|
|
3590
3866
|
}));
|
|
3591
3867
|
}
|
|
3592
3868
|
function processMessage(event) {
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
} = event;
|
|
3599
|
-
if (data) {
|
|
3600
|
-
switch (data.type) {
|
|
3601
|
-
case "builder.configureSdk": {
|
|
3602
|
-
const messageContent = data.data;
|
|
3869
|
+
return createEditorListener({
|
|
3870
|
+
model: props.model,
|
|
3871
|
+
trustedHosts: props.trustedHosts,
|
|
3872
|
+
callbacks: {
|
|
3873
|
+
configureSdk: (messageContent) => {
|
|
3603
3874
|
const {
|
|
3604
3875
|
breakpoints,
|
|
3605
3876
|
contentId
|
|
@@ -3613,22 +3884,18 @@ function EnableEditor(props) {
|
|
|
3613
3884
|
breakpoints
|
|
3614
3885
|
}
|
|
3615
3886
|
});
|
|
3616
|
-
}
|
|
3617
|
-
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3618
|
-
break;
|
|
3619
|
-
}
|
|
3620
|
-
case "builder.contentUpdate": {
|
|
3621
|
-
const messageContent = data.data;
|
|
3622
|
-
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
3623
|
-
const contentData = messageContent.data;
|
|
3624
|
-
if (key === props.model) {
|
|
3625
|
-
mergeNewContent(contentData);
|
|
3626
3887
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3627
3888
|
}
|
|
3628
|
-
|
|
3889
|
+
},
|
|
3890
|
+
animation: (animation) => {
|
|
3891
|
+
triggerAnimation(animation);
|
|
3892
|
+
},
|
|
3893
|
+
contentUpdate: (newContent) => {
|
|
3894
|
+
mergeNewContent(newContent);
|
|
3895
|
+
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3629
3896
|
}
|
|
3630
3897
|
}
|
|
3631
|
-
}
|
|
3898
|
+
})(event);
|
|
3632
3899
|
}
|
|
3633
3900
|
function evaluateJsCode() {
|
|
3634
3901
|
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
@@ -4472,4 +4739,4 @@ var fetchBuilderProps = async (_args) => {
|
|
|
4472
4739
|
};
|
|
4473
4740
|
};
|
|
4474
4741
|
|
|
4475
|
-
export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
|
|
4742
|
+
export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|