@weaverse/react 0.7.25 → 0.7.27
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 +10 -3
- package/dist/index.js +130 -51
- package/dist/index.mjs +119 -40
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -75,15 +75,22 @@ interface MapElementProps extends WeaverseElementProps {
|
|
|
75
75
|
interface TextElementProps extends WeaverseElementProps {
|
|
76
76
|
value: string;
|
|
77
77
|
}
|
|
78
|
-
interface
|
|
78
|
+
interface VideoCommonProps {
|
|
79
79
|
src: string;
|
|
80
|
+
type?: string;
|
|
80
81
|
poster: string;
|
|
81
82
|
loop: boolean;
|
|
82
|
-
type: string;
|
|
83
83
|
controls: boolean;
|
|
84
84
|
autoPlay: boolean;
|
|
85
85
|
muted: boolean;
|
|
86
86
|
}
|
|
87
|
+
declare type VideoElementProps = VideoCommonProps & WeaverseElementProps;
|
|
88
|
+
interface YoutubeElementProps extends VideoCommonProps {
|
|
89
|
+
youtubeId: string;
|
|
90
|
+
}
|
|
91
|
+
interface VimeoElementProps extends VideoCommonProps {
|
|
92
|
+
vimeoId: string;
|
|
93
|
+
}
|
|
87
94
|
declare type CountdownTimeKey = 'days' | 'hours' | 'minutes' | 'seconds';
|
|
88
95
|
declare type CountdownTimerType = 'fixed-time' | 'evergreen';
|
|
89
96
|
interface CountdownElementProps extends WeaverseElementProps {
|
|
@@ -117,4 +124,4 @@ declare type InstagramMedia = {
|
|
|
117
124
|
|
|
118
125
|
declare let WeaverseRoot: ({ context }: WeaverseRootPropsType) => JSX.Element | null;
|
|
119
126
|
|
|
120
|
-
export { ButtonElementProps, ContainerElementProps, CountdownElementProps, CountdownTimeKey, CountdownTimerType, Elements, GridContentElementProps, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutBackgroundProps, LayoutElementProps, MapElementProps, PlaceholderProps, SharedComponents, TextElementProps, TimerBlockProps, VideoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseRoot, WeaverseRootPropsType, createRootContext };
|
|
127
|
+
export { ButtonElementProps, ContainerElementProps, CountdownElementProps, CountdownTimeKey, CountdownTimerType, Elements, GridContentElementProps, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutBackgroundProps, LayoutElementProps, MapElementProps, PlaceholderProps, SharedComponents, TextElementProps, TimerBlockProps, VideoCommonProps, VideoElementProps, VimeoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseRoot, WeaverseRootPropsType, YoutubeElementProps, createRootContext };
|
package/dist/index.js
CHANGED
|
@@ -470,28 +470,107 @@ Text.defaultProps = {
|
|
|
470
470
|
};
|
|
471
471
|
var text_default = Text;
|
|
472
472
|
|
|
473
|
-
// src/elements/video.tsx
|
|
473
|
+
// src/elements/video/index.tsx
|
|
474
|
+
var import_react12 = __toESM(require("react"));
|
|
475
|
+
|
|
476
|
+
// src/elements/video/utils.ts
|
|
477
|
+
function getYoutubeEmbedId(url) {
|
|
478
|
+
const match = url.match(
|
|
479
|
+
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
|
|
480
|
+
);
|
|
481
|
+
return match ? match[1] : null;
|
|
482
|
+
}
|
|
483
|
+
function getVimeoId(url) {
|
|
484
|
+
const match = url.match(/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(.+)/);
|
|
485
|
+
return match ? match[1] : null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// src/elements/video/Youtube.tsx
|
|
474
489
|
var import_react9 = __toESM(require("react"));
|
|
475
|
-
|
|
476
|
-
let {
|
|
477
|
-
let {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
490
|
+
function Youtube(props) {
|
|
491
|
+
let { youtubeId, controls, autoPlay, loop, muted } = props;
|
|
492
|
+
let params = `autoplay=${autoPlay ? 1 : 0}&controls=${controls ? 1 : 0}&loop=${loop ? 1 : 0}&mute=${muted ? 1 : 0}`;
|
|
493
|
+
let youtubeSrc = `https://www.youtube.com/embed/${youtubeId}?${params}`;
|
|
494
|
+
let allow = `accelerometer;${autoPlay ? "autoplay;" : ""} clipboard-write; encrypted-media; gyroscope; picture-in-picture`;
|
|
495
|
+
return /* @__PURE__ */ import_react9.default.createElement("iframe", {
|
|
496
|
+
src: youtubeSrc,
|
|
497
|
+
width: "100%",
|
|
498
|
+
height: "100%",
|
|
499
|
+
allowFullScreen: true,
|
|
500
|
+
allow
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// src/elements/video/vimeo.tsx
|
|
505
|
+
var import_react10 = __toESM(require("react"));
|
|
506
|
+
function Vimeo(props) {
|
|
507
|
+
let { vimeoId, controls, autoPlay, loop, muted } = props;
|
|
508
|
+
let params = `autoplay=${autoPlay}&loop=${loop}&controls=${controls}&muted=${muted}`;
|
|
509
|
+
let vimeoSrc = `https://player.vimeo.com/video/${vimeoId}?${params}`;
|
|
510
|
+
return /* @__PURE__ */ import_react10.default.createElement("iframe", {
|
|
511
|
+
src: vimeoSrc,
|
|
512
|
+
width: "100%",
|
|
513
|
+
height: "100%",
|
|
514
|
+
allowFullScreen: true
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/elements/video/html-video.tsx
|
|
519
|
+
var import_react11 = __toESM(require("react"));
|
|
520
|
+
function HtmlVideo(props) {
|
|
521
|
+
let { src, type, controls, autoPlay, loop, muted } = props;
|
|
522
|
+
return /* @__PURE__ */ import_react11.default.createElement("video", {
|
|
523
|
+
controls,
|
|
524
|
+
autoPlay,
|
|
484
525
|
loop,
|
|
485
|
-
muted
|
|
526
|
+
muted,
|
|
486
527
|
controlsList: "nodownload",
|
|
487
528
|
disablePictureInPicture: true
|
|
488
|
-
}, /* @__PURE__ */
|
|
529
|
+
}, /* @__PURE__ */ import_react11.default.createElement("source", {
|
|
489
530
|
src,
|
|
490
531
|
type: type || "video/mp4"
|
|
491
|
-
}), /* @__PURE__ */
|
|
532
|
+
}), /* @__PURE__ */ import_react11.default.createElement("source", {
|
|
492
533
|
src,
|
|
493
534
|
type: "video/ogg"
|
|
494
|
-
}), "Your browser does not support the video tag.")
|
|
535
|
+
}), "Your browser does not support the video tag.");
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/elements/video/index.tsx
|
|
539
|
+
var Video = (0, import_react12.forwardRef)((props, ref) => {
|
|
540
|
+
let { isDesignMode } = (0, import_react12.useContext)(WeaverseContext);
|
|
541
|
+
let {
|
|
542
|
+
src,
|
|
543
|
+
controls,
|
|
544
|
+
poster,
|
|
545
|
+
autoPlay: originAutoPlay,
|
|
546
|
+
loop,
|
|
547
|
+
muted,
|
|
548
|
+
...rest
|
|
549
|
+
} = props;
|
|
550
|
+
let autoPlay = !isDesignMode && originAutoPlay;
|
|
551
|
+
let videoProps = { src, controls, poster, autoPlay, loop, muted };
|
|
552
|
+
let content;
|
|
553
|
+
let youtubeId = getYoutubeEmbedId(src);
|
|
554
|
+
let vimeoId = getVimeoId(src);
|
|
555
|
+
if (youtubeId) {
|
|
556
|
+
content = /* @__PURE__ */ import_react12.default.createElement(Youtube, {
|
|
557
|
+
...videoProps,
|
|
558
|
+
youtubeId
|
|
559
|
+
});
|
|
560
|
+
} else if (vimeoId) {
|
|
561
|
+
content = /* @__PURE__ */ import_react12.default.createElement(Vimeo, {
|
|
562
|
+
...videoProps,
|
|
563
|
+
vimeoId
|
|
564
|
+
});
|
|
565
|
+
} else {
|
|
566
|
+
content = /* @__PURE__ */ import_react12.default.createElement(HtmlVideo, {
|
|
567
|
+
...videoProps
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
571
|
+
ref,
|
|
572
|
+
...rest
|
|
573
|
+
}, content);
|
|
495
574
|
});
|
|
496
575
|
var css8 = {
|
|
497
576
|
"@desktop": {
|
|
@@ -506,7 +585,6 @@ Video.defaultProps = {
|
|
|
506
585
|
src: "https://youtu.be/wM-NT6hcw48",
|
|
507
586
|
poster: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/-/preview/-/quality/smart/-/format/auto/",
|
|
508
587
|
loop: false,
|
|
509
|
-
type: "video/mp4",
|
|
510
588
|
controls: false,
|
|
511
589
|
autoPlay: true,
|
|
512
590
|
muted: true
|
|
@@ -514,32 +592,32 @@ Video.defaultProps = {
|
|
|
514
592
|
var video_default = Video;
|
|
515
593
|
|
|
516
594
|
// src/elements/instagram.tsx
|
|
517
|
-
var
|
|
595
|
+
var import_react14 = __toESM(require("react"));
|
|
518
596
|
|
|
519
597
|
// src/elements/shared/Placeholder.tsx
|
|
520
|
-
var
|
|
521
|
-
var Placeholder = (0,
|
|
598
|
+
var import_react13 = __toESM(require("react"));
|
|
599
|
+
var Placeholder = (0, import_react13.forwardRef)(
|
|
522
600
|
(props, ref) => {
|
|
523
601
|
let { element, children, ...rest } = props;
|
|
524
|
-
return /* @__PURE__ */
|
|
602
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
525
603
|
"data-wv-placeholder": true,
|
|
526
604
|
ref,
|
|
527
605
|
...rest
|
|
528
|
-
}, /* @__PURE__ */
|
|
606
|
+
}, /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
529
607
|
style: { fontWeight: 600, marginBottom: "10px" }
|
|
530
|
-
}, element), /* @__PURE__ */
|
|
608
|
+
}, element), /* @__PURE__ */ import_react13.default.createElement("div", null, children));
|
|
531
609
|
}
|
|
532
610
|
);
|
|
533
611
|
var Placeholder_default = Placeholder;
|
|
534
612
|
|
|
535
613
|
// src/elements/instagram.tsx
|
|
536
614
|
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
537
|
-
var Instagram = (0,
|
|
615
|
+
var Instagram = (0, import_react14.forwardRef)(
|
|
538
616
|
(props, ref) => {
|
|
539
617
|
let { token, username, numberOfImages, imagesPerRow, gap, ...rest } = props;
|
|
540
|
-
let [media, setMedia] = (0,
|
|
541
|
-
let [error, setError] = (0,
|
|
542
|
-
(0,
|
|
618
|
+
let [media, setMedia] = (0, import_react14.useState)([]);
|
|
619
|
+
let [error, setError] = (0, import_react14.useState)(null);
|
|
620
|
+
(0, import_react14.useEffect)(() => {
|
|
543
621
|
if (token) {
|
|
544
622
|
let params = new URLSearchParams({
|
|
545
623
|
access_token: token,
|
|
@@ -556,10 +634,10 @@ var Instagram = (0, import_react11.forwardRef)(
|
|
|
556
634
|
}
|
|
557
635
|
}, [token]);
|
|
558
636
|
if (!token || error) {
|
|
559
|
-
return /* @__PURE__ */
|
|
637
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
560
638
|
ref,
|
|
561
639
|
...rest
|
|
562
|
-
}, /* @__PURE__ */
|
|
640
|
+
}, /* @__PURE__ */ import_react14.default.createElement(Placeholder_default, {
|
|
563
641
|
element: "Instagram"
|
|
564
642
|
}, !token ? "Connect to Instagram to display photos on your site." : "Invalid or expired token!"));
|
|
565
643
|
}
|
|
@@ -567,27 +645,28 @@ var Instagram = (0, import_react11.forwardRef)(
|
|
|
567
645
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
568
646
|
"--wv-ig-images-gap": gap + "px"
|
|
569
647
|
};
|
|
570
|
-
return /* @__PURE__ */
|
|
648
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
571
649
|
ref,
|
|
572
650
|
...rest,
|
|
573
651
|
style
|
|
574
|
-
}, /* @__PURE__ */
|
|
652
|
+
}, /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
575
653
|
className: "wv-ig-media-container"
|
|
576
654
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
577
655
|
let { id, permalink, caption, media_url } = item;
|
|
578
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ import_react14.default.createElement("a", {
|
|
579
657
|
key: id,
|
|
580
658
|
href: permalink,
|
|
581
659
|
target: "_blank",
|
|
582
660
|
rel: "noreferrer"
|
|
583
|
-
}, /* @__PURE__ */
|
|
661
|
+
}, /* @__PURE__ */ import_react14.default.createElement("img", {
|
|
584
662
|
alt: caption,
|
|
585
663
|
src: media_url
|
|
586
664
|
}));
|
|
587
665
|
})));
|
|
588
666
|
}
|
|
589
667
|
);
|
|
590
|
-
var css9 = {
|
|
668
|
+
var css9 = {};
|
|
669
|
+
var permanentCss2 = {
|
|
591
670
|
"@desktop": {
|
|
592
671
|
".wv-ig-media-container": {
|
|
593
672
|
overflow: "hidden",
|
|
@@ -597,9 +676,8 @@ var css9 = {
|
|
|
597
676
|
gridTemplateColumns: "repeat(var(--wv-ig-images-per-row, 4), 1fr)",
|
|
598
677
|
gap: "var(--wv-ig-images-gap, 0px)",
|
|
599
678
|
img: {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
height: "100%",
|
|
679
|
+
maxWidth: "100%",
|
|
680
|
+
maxHeight: "100%",
|
|
603
681
|
objectFit: "cover"
|
|
604
682
|
}
|
|
605
683
|
}
|
|
@@ -642,7 +720,8 @@ var Elements = {
|
|
|
642
720
|
Instagram: {
|
|
643
721
|
Component: instagram_default,
|
|
644
722
|
type: "instagram",
|
|
645
|
-
defaultCss: css9
|
|
723
|
+
defaultCss: css9,
|
|
724
|
+
permanentCss: permanentCss2
|
|
646
725
|
},
|
|
647
726
|
Layout: {
|
|
648
727
|
Component: layout_default,
|
|
@@ -669,7 +748,7 @@ var Elements = {
|
|
|
669
748
|
|
|
670
749
|
// src/renderer.tsx
|
|
671
750
|
var import_core2 = require("@weaverse/core");
|
|
672
|
-
var
|
|
751
|
+
var import_react15 = __toESM(require("react"));
|
|
673
752
|
|
|
674
753
|
// src/utils/index.ts
|
|
675
754
|
function shortCssObject(css10) {
|
|
@@ -707,10 +786,10 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
707
786
|
|
|
708
787
|
// src/renderer.tsx
|
|
709
788
|
var WeaverseRoot = ({ context }) => {
|
|
710
|
-
let [, setData] = (0,
|
|
711
|
-
let rootRef = (0,
|
|
789
|
+
let [, setData] = (0, import_react15.useState)(context.projectData);
|
|
790
|
+
let rootRef = (0, import_react15.useRef)();
|
|
712
791
|
let renderRoot = () => setData({});
|
|
713
|
-
(0,
|
|
792
|
+
(0, import_react15.useEffect)(() => {
|
|
714
793
|
context.subscribe(renderRoot);
|
|
715
794
|
context.contentRootElement = rootRef.current;
|
|
716
795
|
return () => {
|
|
@@ -720,23 +799,23 @@ var WeaverseRoot = ({ context }) => {
|
|
|
720
799
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
721
800
|
let themeClass = context.stitchesInstance.theme.className;
|
|
722
801
|
if (context.projectData?.rootId) {
|
|
723
|
-
return /* @__PURE__ */
|
|
802
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
724
803
|
className: `weaverse-content-root ${themeClass}`,
|
|
725
804
|
...eventHandlers,
|
|
726
805
|
ref: rootRef
|
|
727
|
-
}, /* @__PURE__ */
|
|
806
|
+
}, /* @__PURE__ */ import_react15.default.createElement(WeaverseContextProvider, {
|
|
728
807
|
value: context
|
|
729
|
-
}, /* @__PURE__ */
|
|
808
|
+
}, /* @__PURE__ */ import_react15.default.createElement(ItemInstance, {
|
|
730
809
|
id: context.projectData.rootId
|
|
731
810
|
})));
|
|
732
811
|
}
|
|
733
812
|
return null;
|
|
734
813
|
};
|
|
735
814
|
var ItemComponent = ({ instance }) => {
|
|
736
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
737
|
-
let [data, setData] = (0,
|
|
815
|
+
let { stitchesInstance, elementInstances } = (0, import_react15.useContext)(WeaverseContext);
|
|
816
|
+
let [data, setData] = (0, import_react15.useState)(instance.data);
|
|
738
817
|
let { id, type, childIds = [], css: css10, className, ...rest } = data;
|
|
739
|
-
(0,
|
|
818
|
+
(0, import_react15.useEffect)(() => {
|
|
740
819
|
let render = (data2) => setData({ ...data2 });
|
|
741
820
|
instance.subscribe(render);
|
|
742
821
|
if (import_core2.isBrowser && !instance.ref.current) {
|
|
@@ -752,13 +831,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
752
831
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
753
832
|
rest.ref = instance.ref;
|
|
754
833
|
}
|
|
755
|
-
return /* @__PURE__ */
|
|
834
|
+
return /* @__PURE__ */ import_react15.default.createElement(Component, {
|
|
756
835
|
key: id,
|
|
757
836
|
"data-wv-type": type,
|
|
758
837
|
"data-wv-id": id,
|
|
759
838
|
className: generateItemClass(instance, stitchesInstance),
|
|
760
839
|
...rest
|
|
761
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
840
|
+
}, childIds.map((id2) => /* @__PURE__ */ import_react15.default.createElement(ItemInstance, {
|
|
762
841
|
key: id2,
|
|
763
842
|
id: id2
|
|
764
843
|
})));
|
|
@@ -768,15 +847,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
768
847
|
}
|
|
769
848
|
};
|
|
770
849
|
var ItemInstance = ({ id }) => {
|
|
771
|
-
let context = (0,
|
|
850
|
+
let context = (0, import_react15.useContext)(WeaverseContext);
|
|
772
851
|
let { itemInstances } = context;
|
|
773
852
|
let instance = itemInstances.get(id);
|
|
774
853
|
if (!instance) {
|
|
775
|
-
return /* @__PURE__ */
|
|
854
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
776
855
|
style: { display: "none" }
|
|
777
856
|
}, "Item instance ", id, " not found");
|
|
778
857
|
}
|
|
779
|
-
return /* @__PURE__ */
|
|
858
|
+
return /* @__PURE__ */ import_react15.default.createElement(ItemComponent, {
|
|
780
859
|
key: id,
|
|
781
860
|
instance
|
|
782
861
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -431,28 +431,107 @@ Text.defaultProps = {
|
|
|
431
431
|
};
|
|
432
432
|
var text_default = Text;
|
|
433
433
|
|
|
434
|
-
// src/elements/video.tsx
|
|
435
|
-
import
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
434
|
+
// src/elements/video/index.tsx
|
|
435
|
+
import React12, { forwardRef as forwardRef7, useContext as useContext3 } from "react";
|
|
436
|
+
|
|
437
|
+
// src/elements/video/utils.ts
|
|
438
|
+
function getYoutubeEmbedId(url) {
|
|
439
|
+
const match = url.match(
|
|
440
|
+
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
|
|
441
|
+
);
|
|
442
|
+
return match ? match[1] : null;
|
|
443
|
+
}
|
|
444
|
+
function getVimeoId(url) {
|
|
445
|
+
const match = url.match(/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(.+)/);
|
|
446
|
+
return match ? match[1] : null;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// src/elements/video/Youtube.tsx
|
|
450
|
+
import React9 from "react";
|
|
451
|
+
function Youtube(props) {
|
|
452
|
+
let { youtubeId, controls, autoPlay, loop, muted } = props;
|
|
453
|
+
let params = `autoplay=${autoPlay ? 1 : 0}&controls=${controls ? 1 : 0}&loop=${loop ? 1 : 0}&mute=${muted ? 1 : 0}`;
|
|
454
|
+
let youtubeSrc = `https://www.youtube.com/embed/${youtubeId}?${params}`;
|
|
455
|
+
let allow = `accelerometer;${autoPlay ? "autoplay;" : ""} clipboard-write; encrypted-media; gyroscope; picture-in-picture`;
|
|
456
|
+
return /* @__PURE__ */ React9.createElement("iframe", {
|
|
457
|
+
src: youtubeSrc,
|
|
458
|
+
width: "100%",
|
|
459
|
+
height: "100%",
|
|
460
|
+
allowFullScreen: true,
|
|
461
|
+
allow
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// src/elements/video/vimeo.tsx
|
|
466
|
+
import React10 from "react";
|
|
467
|
+
function Vimeo(props) {
|
|
468
|
+
let { vimeoId, controls, autoPlay, loop, muted } = props;
|
|
469
|
+
let params = `autoplay=${autoPlay}&loop=${loop}&controls=${controls}&muted=${muted}`;
|
|
470
|
+
let vimeoSrc = `https://player.vimeo.com/video/${vimeoId}?${params}`;
|
|
471
|
+
return /* @__PURE__ */ React10.createElement("iframe", {
|
|
472
|
+
src: vimeoSrc,
|
|
473
|
+
width: "100%",
|
|
474
|
+
height: "100%",
|
|
475
|
+
allowFullScreen: true
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/elements/video/html-video.tsx
|
|
480
|
+
import React11 from "react";
|
|
481
|
+
function HtmlVideo(props) {
|
|
482
|
+
let { src, type, controls, autoPlay, loop, muted } = props;
|
|
483
|
+
return /* @__PURE__ */ React11.createElement("video", {
|
|
484
|
+
controls,
|
|
485
|
+
autoPlay,
|
|
445
486
|
loop,
|
|
446
|
-
muted
|
|
487
|
+
muted,
|
|
447
488
|
controlsList: "nodownload",
|
|
448
489
|
disablePictureInPicture: true
|
|
449
|
-
}, /* @__PURE__ */
|
|
490
|
+
}, /* @__PURE__ */ React11.createElement("source", {
|
|
450
491
|
src,
|
|
451
492
|
type: type || "video/mp4"
|
|
452
|
-
}), /* @__PURE__ */
|
|
493
|
+
}), /* @__PURE__ */ React11.createElement("source", {
|
|
453
494
|
src,
|
|
454
495
|
type: "video/ogg"
|
|
455
|
-
}), "Your browser does not support the video tag.")
|
|
496
|
+
}), "Your browser does not support the video tag.");
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// src/elements/video/index.tsx
|
|
500
|
+
var Video = forwardRef7((props, ref) => {
|
|
501
|
+
let { isDesignMode } = useContext3(WeaverseContext);
|
|
502
|
+
let {
|
|
503
|
+
src,
|
|
504
|
+
controls,
|
|
505
|
+
poster,
|
|
506
|
+
autoPlay: originAutoPlay,
|
|
507
|
+
loop,
|
|
508
|
+
muted,
|
|
509
|
+
...rest
|
|
510
|
+
} = props;
|
|
511
|
+
let autoPlay = !isDesignMode && originAutoPlay;
|
|
512
|
+
let videoProps = { src, controls, poster, autoPlay, loop, muted };
|
|
513
|
+
let content;
|
|
514
|
+
let youtubeId = getYoutubeEmbedId(src);
|
|
515
|
+
let vimeoId = getVimeoId(src);
|
|
516
|
+
if (youtubeId) {
|
|
517
|
+
content = /* @__PURE__ */ React12.createElement(Youtube, {
|
|
518
|
+
...videoProps,
|
|
519
|
+
youtubeId
|
|
520
|
+
});
|
|
521
|
+
} else if (vimeoId) {
|
|
522
|
+
content = /* @__PURE__ */ React12.createElement(Vimeo, {
|
|
523
|
+
...videoProps,
|
|
524
|
+
vimeoId
|
|
525
|
+
});
|
|
526
|
+
} else {
|
|
527
|
+
content = /* @__PURE__ */ React12.createElement(HtmlVideo, {
|
|
528
|
+
...videoProps
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
532
|
+
ref,
|
|
533
|
+
...rest
|
|
534
|
+
}, content);
|
|
456
535
|
});
|
|
457
536
|
var css8 = {
|
|
458
537
|
"@desktop": {
|
|
@@ -467,7 +546,6 @@ Video.defaultProps = {
|
|
|
467
546
|
src: "https://youtu.be/wM-NT6hcw48",
|
|
468
547
|
poster: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/-/preview/-/quality/smart/-/format/auto/",
|
|
469
548
|
loop: false,
|
|
470
|
-
type: "video/mp4",
|
|
471
549
|
controls: false,
|
|
472
550
|
autoPlay: true,
|
|
473
551
|
muted: true
|
|
@@ -475,20 +553,20 @@ Video.defaultProps = {
|
|
|
475
553
|
var video_default = Video;
|
|
476
554
|
|
|
477
555
|
// src/elements/instagram.tsx
|
|
478
|
-
import
|
|
556
|
+
import React14, { forwardRef as forwardRef9, useEffect as useEffect2, useState } from "react";
|
|
479
557
|
|
|
480
558
|
// src/elements/shared/Placeholder.tsx
|
|
481
|
-
import
|
|
559
|
+
import React13, { forwardRef as forwardRef8 } from "react";
|
|
482
560
|
var Placeholder = forwardRef8(
|
|
483
561
|
(props, ref) => {
|
|
484
562
|
let { element, children, ...rest } = props;
|
|
485
|
-
return /* @__PURE__ */
|
|
563
|
+
return /* @__PURE__ */ React13.createElement("div", {
|
|
486
564
|
"data-wv-placeholder": true,
|
|
487
565
|
ref,
|
|
488
566
|
...rest
|
|
489
|
-
}, /* @__PURE__ */
|
|
567
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
490
568
|
style: { fontWeight: 600, marginBottom: "10px" }
|
|
491
|
-
}, element), /* @__PURE__ */
|
|
569
|
+
}, element), /* @__PURE__ */ React13.createElement("div", null, children));
|
|
492
570
|
}
|
|
493
571
|
);
|
|
494
572
|
var Placeholder_default = Placeholder;
|
|
@@ -517,10 +595,10 @@ var Instagram = forwardRef9(
|
|
|
517
595
|
}
|
|
518
596
|
}, [token]);
|
|
519
597
|
if (!token || error) {
|
|
520
|
-
return /* @__PURE__ */
|
|
598
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
521
599
|
ref,
|
|
522
600
|
...rest
|
|
523
|
-
}, /* @__PURE__ */
|
|
601
|
+
}, /* @__PURE__ */ React14.createElement(Placeholder_default, {
|
|
524
602
|
element: "Instagram"
|
|
525
603
|
}, !token ? "Connect to Instagram to display photos on your site." : "Invalid or expired token!"));
|
|
526
604
|
}
|
|
@@ -528,27 +606,28 @@ var Instagram = forwardRef9(
|
|
|
528
606
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
529
607
|
"--wv-ig-images-gap": gap + "px"
|
|
530
608
|
};
|
|
531
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
532
610
|
ref,
|
|
533
611
|
...rest,
|
|
534
612
|
style
|
|
535
|
-
}, /* @__PURE__ */
|
|
613
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
536
614
|
className: "wv-ig-media-container"
|
|
537
615
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
538
616
|
let { id, permalink, caption, media_url } = item;
|
|
539
|
-
return /* @__PURE__ */
|
|
617
|
+
return /* @__PURE__ */ React14.createElement("a", {
|
|
540
618
|
key: id,
|
|
541
619
|
href: permalink,
|
|
542
620
|
target: "_blank",
|
|
543
621
|
rel: "noreferrer"
|
|
544
|
-
}, /* @__PURE__ */
|
|
622
|
+
}, /* @__PURE__ */ React14.createElement("img", {
|
|
545
623
|
alt: caption,
|
|
546
624
|
src: media_url
|
|
547
625
|
}));
|
|
548
626
|
})));
|
|
549
627
|
}
|
|
550
628
|
);
|
|
551
|
-
var css9 = {
|
|
629
|
+
var css9 = {};
|
|
630
|
+
var permanentCss2 = {
|
|
552
631
|
"@desktop": {
|
|
553
632
|
".wv-ig-media-container": {
|
|
554
633
|
overflow: "hidden",
|
|
@@ -558,9 +637,8 @@ var css9 = {
|
|
|
558
637
|
gridTemplateColumns: "repeat(var(--wv-ig-images-per-row, 4), 1fr)",
|
|
559
638
|
gap: "var(--wv-ig-images-gap, 0px)",
|
|
560
639
|
img: {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
height: "100%",
|
|
640
|
+
maxWidth: "100%",
|
|
641
|
+
maxHeight: "100%",
|
|
564
642
|
objectFit: "cover"
|
|
565
643
|
}
|
|
566
644
|
}
|
|
@@ -603,7 +681,8 @@ var Elements = {
|
|
|
603
681
|
Instagram: {
|
|
604
682
|
Component: instagram_default,
|
|
605
683
|
type: "instagram",
|
|
606
|
-
defaultCss: css9
|
|
684
|
+
defaultCss: css9,
|
|
685
|
+
permanentCss: permanentCss2
|
|
607
686
|
},
|
|
608
687
|
Layout: {
|
|
609
688
|
Component: layout_default,
|
|
@@ -630,7 +709,7 @@ var Elements = {
|
|
|
630
709
|
|
|
631
710
|
// src/renderer.tsx
|
|
632
711
|
import { isBrowser } from "@weaverse/core";
|
|
633
|
-
import
|
|
712
|
+
import React15, { useContext as useContext4, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
634
713
|
|
|
635
714
|
// src/utils/index.ts
|
|
636
715
|
function shortCssObject(css10) {
|
|
@@ -681,13 +760,13 @@ var WeaverseRoot = ({ context }) => {
|
|
|
681
760
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
682
761
|
let themeClass = context.stitchesInstance.theme.className;
|
|
683
762
|
if (context.projectData?.rootId) {
|
|
684
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
685
764
|
className: `weaverse-content-root ${themeClass}`,
|
|
686
765
|
...eventHandlers,
|
|
687
766
|
ref: rootRef
|
|
688
|
-
}, /* @__PURE__ */
|
|
767
|
+
}, /* @__PURE__ */ React15.createElement(WeaverseContextProvider, {
|
|
689
768
|
value: context
|
|
690
|
-
}, /* @__PURE__ */
|
|
769
|
+
}, /* @__PURE__ */ React15.createElement(ItemInstance, {
|
|
691
770
|
id: context.projectData.rootId
|
|
692
771
|
})));
|
|
693
772
|
}
|
|
@@ -713,13 +792,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
713
792
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
714
793
|
rest.ref = instance.ref;
|
|
715
794
|
}
|
|
716
|
-
return /* @__PURE__ */
|
|
795
|
+
return /* @__PURE__ */ React15.createElement(Component, {
|
|
717
796
|
key: id,
|
|
718
797
|
"data-wv-type": type,
|
|
719
798
|
"data-wv-id": id,
|
|
720
799
|
className: generateItemClass(instance, stitchesInstance),
|
|
721
800
|
...rest
|
|
722
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
801
|
+
}, childIds.map((id2) => /* @__PURE__ */ React15.createElement(ItemInstance, {
|
|
723
802
|
key: id2,
|
|
724
803
|
id: id2
|
|
725
804
|
})));
|
|
@@ -733,11 +812,11 @@ var ItemInstance = ({ id }) => {
|
|
|
733
812
|
let { itemInstances } = context;
|
|
734
813
|
let instance = itemInstances.get(id);
|
|
735
814
|
if (!instance) {
|
|
736
|
-
return /* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
737
816
|
style: { display: "none" }
|
|
738
817
|
}, "Item instance ", id, " not found");
|
|
739
818
|
}
|
|
740
|
-
return /* @__PURE__ */
|
|
819
|
+
return /* @__PURE__ */ React15.createElement(ItemComponent, {
|
|
741
820
|
key: id,
|
|
742
821
|
instance
|
|
743
822
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.27",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"name": "@weaverse/react",
|
|
32
32
|
"author": "Weaverse Team",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@weaverse/core": "0.7.
|
|
34
|
+
"@weaverse/core": "0.7.27",
|
|
35
35
|
"nuka-carousel": "^5.4.0"
|
|
36
36
|
}
|
|
37
37
|
}
|