@webstudio-is/sdk-components-react 0.206.0 → 0.207.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/types/vimeo.d.ts +1 -0
- package/lib/vimeo.js +121 -114
- package/lib/vimeo.ws.js +8 -7
- package/lib/webhook-form.ws.js +9 -1
- package/lib/youtube.js +98 -93
- package/package.json +9 -8
package/lib/types/vimeo.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export type VimeoOptions = Omit<VimeoPlayerOptions, "dnt" | "interactive_params"
|
|
|
66
66
|
/** Whether to display the video owner's portrait. Only works if either title or byline are also enabled */
|
|
67
67
|
showPortrait?: VimeoPlayerOptions["portrait"];
|
|
68
68
|
};
|
|
69
|
+
export declare const requestFullscreen: (element: HTMLIFrameElement) => void;
|
|
69
70
|
type PlayerStatus = "initial" | "loading" | "ready";
|
|
70
71
|
export declare const VimeoContext: import("react").Context<{
|
|
71
72
|
previewImageUrl?: URL;
|
package/lib/vimeo.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import { colord as
|
|
3
|
-
import { createContext as T, forwardRef as
|
|
4
|
-
import { ReactSdkContext as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as s, jsxs as q, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { colord as B } from "colord";
|
|
3
|
+
import { createContext as T, forwardRef as z, useState as y, useContext as G, useRef as H, useEffect as v } from "react";
|
|
4
|
+
import { ReactSdkContext as Y } from "@webstudio-is/react-sdk/runtime";
|
|
5
|
+
const J = (e) => {
|
|
6
6
|
if (e.url === void 0)
|
|
7
7
|
return;
|
|
8
8
|
let t;
|
|
9
9
|
try {
|
|
10
|
-
const
|
|
11
|
-
t = new URL(
|
|
10
|
+
const n = new URL(e.url);
|
|
11
|
+
t = new URL(M), t.pathname = `/video${n.pathname}`;
|
|
12
12
|
} catch {
|
|
13
13
|
}
|
|
14
14
|
if (t === void 0)
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
16
|
+
const r = {
|
|
17
17
|
showPortrait: "portrait",
|
|
18
18
|
showByline: "byline",
|
|
19
19
|
showTitle: "title",
|
|
@@ -23,36 +23,36 @@ const Y = (e) => {
|
|
|
23
23
|
backgroundMode: "background",
|
|
24
24
|
doNotTrack: "dnt"
|
|
25
25
|
};
|
|
26
|
-
let
|
|
27
|
-
for (
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
26
|
+
let o;
|
|
27
|
+
for (o in e) {
|
|
28
|
+
const n = e[o];
|
|
29
|
+
if (o === "url" || n === void 0)
|
|
30
30
|
continue;
|
|
31
|
-
const i =
|
|
32
|
-
t.searchParams.append(i,
|
|
31
|
+
const i = r[o] ?? o;
|
|
32
|
+
t.searchParams.append(i, n.toString());
|
|
33
33
|
}
|
|
34
34
|
if (t.searchParams.set("autoplay", "true"), typeof e.controlsColor == "string") {
|
|
35
|
-
const
|
|
36
|
-
t.searchParams.set("color",
|
|
35
|
+
const n = B(e.controlsColor).toHex().replace("#", "");
|
|
36
|
+
t.searchParams.set("color", n);
|
|
37
37
|
}
|
|
38
38
|
return e.showPortrait && t.searchParams.set("title", "true"), e.showByline && (t.searchParams.set("portrait", "true"), t.searchParams.set("title", "true")), t.toString();
|
|
39
|
-
},
|
|
39
|
+
}, w = (e) => {
|
|
40
40
|
const t = document.createElement("link");
|
|
41
41
|
t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
|
|
42
42
|
};
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
},
|
|
43
|
+
let U = !1;
|
|
44
|
+
const K = "https://f.vimeocdn.com", M = "https://player.vimeo.com", S = "https://i.vimeocdn.com", Q = () => {
|
|
45
|
+
U || window.matchMedia("(hover: none)").matches || (w(K), w(M), w(S), U = !0);
|
|
46
|
+
}, W = (e) => {
|
|
47
47
|
try {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
48
|
+
const r = new URL(e).pathname.split("/")[2];
|
|
49
|
+
return r === "" || r == null ? void 0 : r;
|
|
50
50
|
} catch {
|
|
51
51
|
}
|
|
52
|
-
},
|
|
53
|
-
const
|
|
54
|
-
return
|
|
55
|
-
},
|
|
52
|
+
}, X = async (e) => {
|
|
53
|
+
const r = `https://vimeo.com/api/v2/video/${W(e)}.json`, n = (await (await fetch(r)).json())[0].thumbnail_large, i = n.substr(n.lastIndexOf("/") + 1).split("_")[0], a = new URL(S);
|
|
54
|
+
return a.pathname = `/video/${i}.webp`, a.searchParams.append("mw", "1100"), a.searchParams.append("mh", "619"), a.searchParams.append("q", "70"), a;
|
|
55
|
+
}, Z = () => /* @__PURE__ */ s(
|
|
56
56
|
"div",
|
|
57
57
|
{
|
|
58
58
|
style: {
|
|
@@ -65,141 +65,147 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
|
|
|
65
65
|
},
|
|
66
66
|
children: 'Open the "Settings" panel and paste a video URL, e.g. https://vimeo.com/831343124.'
|
|
67
67
|
}
|
|
68
|
-
),
|
|
68
|
+
), tt = (e) => {
|
|
69
|
+
const t = "ontouchstart" in window;
|
|
70
|
+
(window.matchMedia("(max-width: 1024px)").matches || t) && e.requestFullscreen();
|
|
71
|
+
}, et = ({
|
|
69
72
|
title: e,
|
|
70
73
|
status: t,
|
|
71
|
-
loading:
|
|
72
|
-
videoUrl:
|
|
73
|
-
previewImageUrl:
|
|
74
|
+
loading: r,
|
|
75
|
+
videoUrl: o,
|
|
76
|
+
previewImageUrl: n,
|
|
74
77
|
autoplay: i,
|
|
75
|
-
renderer:
|
|
76
|
-
showPreview:
|
|
78
|
+
renderer: a,
|
|
79
|
+
showPreview: u,
|
|
80
|
+
playsinline: f,
|
|
77
81
|
onStatusChange: c,
|
|
78
82
|
onPreviewImageUrlChange: l
|
|
79
83
|
}) => {
|
|
80
|
-
const [
|
|
81
|
-
if (
|
|
82
|
-
i &&
|
|
83
|
-
}, [i, t,
|
|
84
|
-
|
|
85
|
-
}, [
|
|
86
|
-
if (
|
|
87
|
-
if (
|
|
84
|
+
const [m, h] = y(0), d = H(null);
|
|
85
|
+
if (v(() => {
|
|
86
|
+
i && a !== "canvas" && t === "initial" && c("loading");
|
|
87
|
+
}, [i, t, a, c]), v(() => {
|
|
88
|
+
a !== "canvas" && Q();
|
|
89
|
+
}, [a]), v(() => {
|
|
90
|
+
if (o !== void 0) {
|
|
91
|
+
if (u === !1) {
|
|
88
92
|
l(void 0);
|
|
89
93
|
return;
|
|
90
94
|
}
|
|
91
|
-
|
|
92
|
-
console.error(`Could not load preview image for ${
|
|
95
|
+
n === void 0 && X(o).then(l).catch(() => {
|
|
96
|
+
console.error(`Could not load preview image for ${o}`);
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
|
-
}, [l,
|
|
99
|
+
}, [l, u, o, n]), !(a === "canvas" || t === "initial"))
|
|
96
100
|
return /* @__PURE__ */ s(
|
|
97
101
|
"iframe",
|
|
98
102
|
{
|
|
103
|
+
ref: d,
|
|
99
104
|
title: e,
|
|
100
|
-
src:
|
|
101
|
-
loading:
|
|
105
|
+
src: o,
|
|
106
|
+
loading: r,
|
|
102
107
|
allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;",
|
|
103
108
|
allowFullScreen: !0,
|
|
104
109
|
style: {
|
|
105
110
|
position: "absolute",
|
|
106
111
|
width: "100%",
|
|
107
112
|
height: "100%",
|
|
108
|
-
opacity:
|
|
113
|
+
opacity: m,
|
|
109
114
|
transition: "opacity 1s",
|
|
110
115
|
border: "none"
|
|
111
116
|
},
|
|
112
117
|
onLoad: () => {
|
|
113
|
-
c("ready"),
|
|
118
|
+
c("ready"), h(1), d.current && !f && !i && tt(d.current);
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
);
|
|
117
|
-
},
|
|
122
|
+
}, ot = T({
|
|
118
123
|
onInitPlayer: () => {
|
|
119
124
|
},
|
|
120
125
|
status: "initial"
|
|
121
|
-
}),
|
|
126
|
+
}), rt = z(
|
|
122
127
|
({
|
|
123
128
|
url: e,
|
|
124
129
|
loading: t = "lazy",
|
|
125
|
-
autoplay:
|
|
126
|
-
autopause:
|
|
127
|
-
showByline:
|
|
130
|
+
autoplay: r = !1,
|
|
131
|
+
autopause: o = !0,
|
|
132
|
+
showByline: n = !1,
|
|
128
133
|
showControls: i = !0,
|
|
129
|
-
doNotTrack:
|
|
130
|
-
keyboard:
|
|
131
|
-
loop:
|
|
132
|
-
muted:
|
|
133
|
-
pip:
|
|
134
|
-
playsinline:
|
|
135
|
-
showPortrait:
|
|
136
|
-
quality:
|
|
137
|
-
responsive:
|
|
138
|
-
speed:
|
|
139
|
-
showTitle:
|
|
140
|
-
transparent:
|
|
141
|
-
showPreview:
|
|
142
|
-
autopip:
|
|
143
|
-
controlsColor:
|
|
144
|
-
interactiveParams:
|
|
145
|
-
texttrack:
|
|
146
|
-
children:
|
|
147
|
-
...
|
|
148
|
-
},
|
|
149
|
-
const [
|
|
134
|
+
doNotTrack: a = !1,
|
|
135
|
+
keyboard: u = !0,
|
|
136
|
+
loop: f = !1,
|
|
137
|
+
muted: c = !1,
|
|
138
|
+
pip: l = !1,
|
|
139
|
+
playsinline: m = !1,
|
|
140
|
+
showPortrait: h = !0,
|
|
141
|
+
quality: d = "auto",
|
|
142
|
+
responsive: L = !0,
|
|
143
|
+
speed: k = !1,
|
|
144
|
+
showTitle: E = !1,
|
|
145
|
+
transparent: _ = !0,
|
|
146
|
+
showPreview: j = !1,
|
|
147
|
+
autopip: F,
|
|
148
|
+
controlsColor: N,
|
|
149
|
+
interactiveParams: O,
|
|
150
|
+
texttrack: V,
|
|
151
|
+
children: D,
|
|
152
|
+
...g
|
|
153
|
+
}, p) => {
|
|
154
|
+
const [P, C] = y("initial"), [x, $] = y(), { renderer: R } = G(Y), b = J({
|
|
150
155
|
url: e,
|
|
151
|
-
autoplay:
|
|
152
|
-
autopause:
|
|
156
|
+
autoplay: r,
|
|
157
|
+
autopause: o,
|
|
153
158
|
showControls: i,
|
|
154
|
-
controlsColor:
|
|
155
|
-
doNotTrack:
|
|
156
|
-
interactiveParams:
|
|
157
|
-
keyboard:
|
|
158
|
-
loop:
|
|
159
|
-
muted:
|
|
160
|
-
pip:
|
|
161
|
-
playsinline:
|
|
162
|
-
quality:
|
|
163
|
-
responsive:
|
|
164
|
-
speed:
|
|
165
|
-
texttrack:
|
|
166
|
-
showTitle:
|
|
167
|
-
transparent:
|
|
168
|
-
showPortrait:
|
|
169
|
-
autopip:
|
|
159
|
+
controlsColor: N,
|
|
160
|
+
doNotTrack: a,
|
|
161
|
+
interactiveParams: O,
|
|
162
|
+
keyboard: u,
|
|
163
|
+
loop: f,
|
|
164
|
+
muted: c,
|
|
165
|
+
pip: l,
|
|
166
|
+
playsinline: m,
|
|
167
|
+
quality: d,
|
|
168
|
+
responsive: L,
|
|
169
|
+
speed: k,
|
|
170
|
+
texttrack: V,
|
|
171
|
+
showTitle: E,
|
|
172
|
+
transparent: _,
|
|
173
|
+
showPortrait: h,
|
|
174
|
+
autopip: F
|
|
170
175
|
});
|
|
171
176
|
return /* @__PURE__ */ s(
|
|
172
|
-
|
|
177
|
+
ot.Provider,
|
|
173
178
|
{
|
|
174
179
|
value: {
|
|
175
|
-
status:
|
|
176
|
-
previewImageUrl:
|
|
180
|
+
status: P,
|
|
181
|
+
previewImageUrl: x,
|
|
177
182
|
onInitPlayer() {
|
|
178
|
-
|
|
183
|
+
R !== "canvas" && C("loading");
|
|
179
184
|
}
|
|
180
185
|
},
|
|
181
186
|
children: /* @__PURE__ */ s(
|
|
182
187
|
"div",
|
|
183
188
|
{
|
|
184
|
-
...
|
|
185
|
-
ref: (
|
|
186
|
-
|
|
189
|
+
...g,
|
|
190
|
+
ref: (I) => {
|
|
191
|
+
p !== null && (typeof p == "function" ? p(I) : p.current = I);
|
|
187
192
|
},
|
|
188
|
-
children:
|
|
189
|
-
|
|
193
|
+
children: b === void 0 ? /* @__PURE__ */ s(Z, {}) : /* @__PURE__ */ q(A, { children: [
|
|
194
|
+
D,
|
|
190
195
|
/* @__PURE__ */ s(
|
|
191
|
-
|
|
196
|
+
et,
|
|
192
197
|
{
|
|
193
|
-
title:
|
|
194
|
-
autoplay:
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
title: g.title,
|
|
199
|
+
autoplay: r,
|
|
200
|
+
playsinline: m,
|
|
201
|
+
videoUrl: b,
|
|
202
|
+
previewImageUrl: x,
|
|
197
203
|
loading: t,
|
|
198
|
-
showPreview:
|
|
199
|
-
renderer:
|
|
200
|
-
status:
|
|
201
|
-
onStatusChange:
|
|
202
|
-
onPreviewImageUrlChange:
|
|
204
|
+
showPreview: j,
|
|
205
|
+
renderer: R,
|
|
206
|
+
status: P,
|
|
207
|
+
onStatusChange: C,
|
|
208
|
+
onPreviewImageUrlChange: $
|
|
203
209
|
}
|
|
204
210
|
)
|
|
205
211
|
] })
|
|
@@ -209,8 +215,9 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
|
|
|
209
215
|
);
|
|
210
216
|
}
|
|
211
217
|
);
|
|
212
|
-
|
|
218
|
+
rt.displayName = "Vimeo";
|
|
213
219
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
rt as Vimeo,
|
|
221
|
+
ot as VimeoContext,
|
|
222
|
+
tt as requestFullscreen
|
|
216
223
|
};
|
package/lib/vimeo.ws.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { VimeoIcon as o } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { defaultStates as t } from "@webstudio-is/sdk";
|
|
3
|
-
import { div as
|
|
4
|
-
import { props as
|
|
5
|
-
const
|
|
6
|
-
div:
|
|
3
|
+
import { div as i } from "@webstudio-is/sdk/normalize.css";
|
|
4
|
+
import { props as n } from "./__generated__/vimeo.props.js";
|
|
5
|
+
const r = {
|
|
6
|
+
div: i
|
|
7
7
|
}, c = {
|
|
8
8
|
type: "container",
|
|
9
9
|
icon: o,
|
|
10
10
|
states: t,
|
|
11
|
-
presetStyle:
|
|
11
|
+
presetStyle: r,
|
|
12
12
|
constraints: {
|
|
13
13
|
relation: "ancestor",
|
|
14
14
|
component: { $nin: ["Button", "Link", "Heading"] }
|
|
@@ -29,9 +29,10 @@ const n = {
|
|
|
29
29
|
"showByline",
|
|
30
30
|
"showTitle",
|
|
31
31
|
"showControls",
|
|
32
|
-
"controlsColor"
|
|
32
|
+
"controlsColor",
|
|
33
|
+
"playsinline"
|
|
33
34
|
], m = {
|
|
34
|
-
props:
|
|
35
|
+
props: n,
|
|
35
36
|
initialProps: e
|
|
36
37
|
};
|
|
37
38
|
export {
|
package/lib/webhook-form.ws.js
CHANGED
|
@@ -17,7 +17,15 @@ const n = {
|
|
|
17
17
|
{ selector: "[data-state=success]", label: "Success" }
|
|
18
18
|
]
|
|
19
19
|
}, c = {
|
|
20
|
-
props:
|
|
20
|
+
props: {
|
|
21
|
+
...e,
|
|
22
|
+
action: {
|
|
23
|
+
type: "resource",
|
|
24
|
+
control: "resource",
|
|
25
|
+
description: "The URI of a program that processes the information submitted via the form.",
|
|
26
|
+
required: !0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
21
29
|
initialProps: ["id", "className", "state", "action"]
|
|
22
30
|
};
|
|
23
31
|
export {
|
package/lib/youtube.js
CHANGED
|
@@ -1,137 +1,139 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { ReactSdkContext as
|
|
4
|
-
import { VimeoContext as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as m, jsxs as _, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as C, useState as p, useContext as I, useRef as E, useEffect as h } from "react";
|
|
3
|
+
import { ReactSdkContext as O } from "@webstudio-is/react-sdk/runtime";
|
|
4
|
+
import { VimeoContext as x, requestFullscreen as S } from "./vimeo.js";
|
|
5
|
+
const T = "https://www.youtube-nocookie.com", j = "https://www.youtube.com", v = "https://img.youtube.com", R = (e) => {
|
|
6
6
|
if (e)
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
const a = new URL(e);
|
|
9
|
+
return a.pathname === "/embed" ? void 0 : a.hostname === "youtu.be" ? a.pathname.slice(1) : a.searchParams.get("v") || a.pathname.split("/").pop();
|
|
10
10
|
} catch {
|
|
11
11
|
return e;
|
|
12
12
|
}
|
|
13
|
-
},
|
|
14
|
-
var
|
|
15
|
-
const l =
|
|
13
|
+
}, A = (e, a) => {
|
|
14
|
+
var i, c;
|
|
15
|
+
const l = R(e.url), r = new URL(a);
|
|
16
16
|
if (l)
|
|
17
17
|
r.pathname = `/embed/${l}`;
|
|
18
18
|
else if (e.url)
|
|
19
19
|
try {
|
|
20
|
-
const
|
|
21
|
-
r.pathname =
|
|
20
|
+
const n = new URL(e.url);
|
|
21
|
+
r.pathname = n.pathname, r.search = n.search;
|
|
22
22
|
} catch {
|
|
23
23
|
}
|
|
24
|
-
const o = Object.keys(e),
|
|
25
|
-
for (const
|
|
26
|
-
switch (
|
|
24
|
+
const o = Object.keys(e), t = {};
|
|
25
|
+
for (const n of o)
|
|
26
|
+
switch (n) {
|
|
27
27
|
case "autoplay":
|
|
28
|
-
|
|
28
|
+
t.autoplay = e.autoplay ? "1" : "0", e.autoplay && e.muted === void 0 && (t.mute = "1");
|
|
29
29
|
break;
|
|
30
30
|
case "muted":
|
|
31
|
-
|
|
31
|
+
t.mute = e.muted ? "1" : "0";
|
|
32
32
|
break;
|
|
33
33
|
case "showControls":
|
|
34
|
-
|
|
34
|
+
t.controls = e.showControls ? "1" : "0";
|
|
35
35
|
break;
|
|
36
36
|
case "showRelatedVideos":
|
|
37
|
-
|
|
37
|
+
t.rel = e.showRelatedVideos ? "1" : "0";
|
|
38
38
|
break;
|
|
39
39
|
case "keyboard":
|
|
40
|
-
|
|
40
|
+
t.keyboard = e.keyboard ? "1" : "0";
|
|
41
41
|
break;
|
|
42
42
|
case "loop":
|
|
43
|
-
|
|
43
|
+
t.loop = e.loop ? "1" : "0", e.loop && (e.playlist ?? "").trim() === "" && (t.playlist = l);
|
|
44
44
|
break;
|
|
45
45
|
case "inline":
|
|
46
|
-
|
|
46
|
+
t.playsinline = e.inline ? "1" : "0";
|
|
47
47
|
break;
|
|
48
48
|
case "allowFullscreen":
|
|
49
|
-
|
|
49
|
+
t.fs = e.allowFullscreen ? "1" : "0";
|
|
50
50
|
break;
|
|
51
51
|
case "captionLanguage":
|
|
52
|
-
|
|
52
|
+
t.cc_lang_pref = e.captionLanguage;
|
|
53
53
|
break;
|
|
54
54
|
case "showCaptions":
|
|
55
|
-
|
|
55
|
+
t.cc_load_policy = e.showCaptions ? "1" : "0";
|
|
56
56
|
break;
|
|
57
57
|
case "showAnnotations":
|
|
58
|
-
|
|
58
|
+
t.iv_load_policy = e.showAnnotations ? "1" : "3";
|
|
59
59
|
break;
|
|
60
60
|
case "startTime":
|
|
61
|
-
|
|
61
|
+
t.start = (i = e.startTime) == null ? void 0 : i.toString();
|
|
62
62
|
break;
|
|
63
63
|
case "endTime":
|
|
64
|
-
|
|
64
|
+
t.end = (c = e.endTime) == null ? void 0 : c.toString();
|
|
65
65
|
break;
|
|
66
66
|
case "disableKeyboard":
|
|
67
|
-
|
|
67
|
+
t.disablekb = e.disableKeyboard ? "1" : "0";
|
|
68
68
|
break;
|
|
69
69
|
case "language":
|
|
70
|
-
|
|
70
|
+
t.hl = e.language;
|
|
71
71
|
break;
|
|
72
72
|
case "listId":
|
|
73
|
-
|
|
73
|
+
t.list = e.listId;
|
|
74
74
|
break;
|
|
75
75
|
case "listType":
|
|
76
|
-
|
|
76
|
+
t.listType = e.listType;
|
|
77
77
|
break;
|
|
78
78
|
case "color":
|
|
79
|
-
|
|
79
|
+
t.color = e.color;
|
|
80
80
|
break;
|
|
81
81
|
case "origin":
|
|
82
|
-
|
|
82
|
+
t.origin = e.origin;
|
|
83
83
|
break;
|
|
84
84
|
case "referrer":
|
|
85
|
-
|
|
85
|
+
t.widget_referrer = e.referrer;
|
|
86
86
|
break;
|
|
87
87
|
case "playlist":
|
|
88
|
-
|
|
88
|
+
t.playlist = e.playlist;
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
|
-
return Object.entries(
|
|
92
|
-
s !== void 0 && r.searchParams.append(
|
|
91
|
+
return Object.entries(t).forEach(([n, s]) => {
|
|
92
|
+
s !== void 0 && r.searchParams.append(n, s.toString());
|
|
93
93
|
}), r.toString();
|
|
94
|
-
},
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
}, w = (e) => {
|
|
95
|
+
const a = document.createElement("link");
|
|
96
|
+
a.rel = "preconnect", a.href = e, a.crossOrigin = "true", document.head.appendChild(a);
|
|
97
97
|
};
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
if (!(
|
|
98
|
+
let k = !1;
|
|
99
|
+
const N = (e) => {
|
|
100
|
+
if (!(k || window.matchMedia("(hover: none)").matches)) {
|
|
101
101
|
try {
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const a = new URL(e);
|
|
103
|
+
w(a.origin);
|
|
104
104
|
} catch {
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
w(v), k = !0;
|
|
107
107
|
}
|
|
108
|
-
},
|
|
108
|
+
}, P = (e) => new URL(`${v}/vi/${e}/maxresdefault.jpg`), U = () => /* @__PURE__ */ m("div", { className: "flex w-full h-full items-center justify-center text-lg", children: 'Open the "Settings" panel and paste a video URL, e.g. https://youtube.com/watch?v=dQw4w9WgXcQ' }), V = ({
|
|
109
109
|
title: e,
|
|
110
|
-
status:
|
|
110
|
+
status: a,
|
|
111
111
|
loading: l,
|
|
112
112
|
videoUrl: r,
|
|
113
113
|
previewImageUrl: o,
|
|
114
|
-
autoplay:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
autoplay: t,
|
|
115
|
+
inline: i,
|
|
116
|
+
renderer: c,
|
|
117
|
+
showPreview: n,
|
|
118
|
+
onStatusChange: s,
|
|
119
|
+
onPreviewImageUrlChange: u
|
|
119
120
|
}) => {
|
|
120
|
-
const [
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
}, [
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
|
|
121
|
+
const [b, f] = p(0), d = E(null);
|
|
122
|
+
return h(() => {
|
|
123
|
+
t && c !== "canvas" && a === "initial" && s("loading");
|
|
124
|
+
}, [t, a, c, s]), h(() => {
|
|
125
|
+
c !== "canvas" && N(r);
|
|
126
|
+
}, [c, r]), h(() => {
|
|
127
|
+
const y = R(r);
|
|
128
|
+
if (!y || !n) {
|
|
129
|
+
u(void 0);
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
|
-
o ||
|
|
132
|
-
}, [
|
|
132
|
+
o || u(P(y));
|
|
133
|
+
}, [u, n, r, o]), c === "canvas" || a === "initial" ? null : /* @__PURE__ */ m(
|
|
133
134
|
"iframe",
|
|
134
135
|
{
|
|
136
|
+
ref: d,
|
|
135
137
|
title: e,
|
|
136
138
|
src: r,
|
|
137
139
|
loading: l,
|
|
@@ -141,66 +143,69 @@ const T = (e) => {
|
|
|
141
143
|
position: "absolute",
|
|
142
144
|
width: "100%",
|
|
143
145
|
height: "100%",
|
|
144
|
-
opacity:
|
|
146
|
+
opacity: b,
|
|
145
147
|
transition: "opacity 1s",
|
|
146
148
|
border: "none"
|
|
147
149
|
},
|
|
148
150
|
onLoad: () => {
|
|
149
|
-
|
|
151
|
+
s("ready"), f(1), !i && !t && d.current && S(d.current);
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
);
|
|
153
|
-
},
|
|
155
|
+
}, D = C(
|
|
154
156
|
({
|
|
155
157
|
url: e,
|
|
156
|
-
loading:
|
|
158
|
+
loading: a = "lazy",
|
|
157
159
|
autoplay: l,
|
|
158
160
|
showPreview: r,
|
|
159
161
|
children: o,
|
|
160
|
-
privacyEnhancedMode:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
privacyEnhancedMode: t,
|
|
163
|
+
inline: i = !1,
|
|
164
|
+
...c
|
|
165
|
+
}, n) => {
|
|
166
|
+
const [s, u] = p("initial"), [b, f] = p(), { renderer: d } = I(O), y = t ?? !0 ? T : j, g = A(
|
|
164
167
|
{
|
|
165
|
-
...
|
|
168
|
+
...c,
|
|
169
|
+
inline: i,
|
|
166
170
|
url: e,
|
|
167
171
|
autoplay: !0
|
|
168
172
|
},
|
|
169
|
-
|
|
173
|
+
y
|
|
170
174
|
);
|
|
171
|
-
return /* @__PURE__ */
|
|
172
|
-
|
|
175
|
+
return /* @__PURE__ */ m(
|
|
176
|
+
x.Provider,
|
|
173
177
|
{
|
|
174
178
|
value: {
|
|
175
|
-
status:
|
|
176
|
-
previewImageUrl:
|
|
179
|
+
status: s,
|
|
180
|
+
previewImageUrl: b,
|
|
177
181
|
onInitPlayer() {
|
|
178
|
-
d !== "canvas" &&
|
|
182
|
+
d !== "canvas" && u("loading");
|
|
179
183
|
}
|
|
180
184
|
},
|
|
181
|
-
children: /* @__PURE__ */
|
|
185
|
+
children: /* @__PURE__ */ m("div", { ...c, ref: n, children: g ? /* @__PURE__ */ _(L, { children: [
|
|
182
186
|
o,
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
187
|
+
/* @__PURE__ */ m(
|
|
188
|
+
V,
|
|
185
189
|
{
|
|
186
|
-
title:
|
|
190
|
+
title: c.title,
|
|
187
191
|
autoplay: l,
|
|
188
|
-
videoUrl:
|
|
189
|
-
previewImageUrl:
|
|
190
|
-
loading:
|
|
192
|
+
videoUrl: g,
|
|
193
|
+
previewImageUrl: b,
|
|
194
|
+
loading: a,
|
|
195
|
+
inline: i,
|
|
191
196
|
showPreview: r,
|
|
192
197
|
renderer: d,
|
|
193
|
-
status:
|
|
194
|
-
onStatusChange:
|
|
195
|
-
onPreviewImageUrlChange:
|
|
198
|
+
status: s,
|
|
199
|
+
onStatusChange: u,
|
|
200
|
+
onPreviewImageUrlChange: f
|
|
196
201
|
}
|
|
197
202
|
)
|
|
198
|
-
] }) : /* @__PURE__ */
|
|
203
|
+
] }) : /* @__PURE__ */ m(U, {}) })
|
|
199
204
|
}
|
|
200
205
|
);
|
|
201
206
|
}
|
|
202
207
|
);
|
|
203
|
-
|
|
208
|
+
D.displayName = "YouTube";
|
|
204
209
|
export {
|
|
205
|
-
|
|
210
|
+
D as YouTube
|
|
206
211
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.207.0",
|
|
4
4
|
"description": "Webstudio default library for react",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -49,21 +49,22 @@
|
|
|
49
49
|
"colord": "^2.9.3",
|
|
50
50
|
"micromark": "^4.0.1",
|
|
51
51
|
"micromark-extension-gfm-table": "^2.1.0",
|
|
52
|
-
"@webstudio-is/icons": "0.
|
|
53
|
-
"@webstudio-is/
|
|
54
|
-
"@webstudio-is/
|
|
55
|
-
"@webstudio-is/
|
|
52
|
+
"@webstudio-is/icons": "0.207.0",
|
|
53
|
+
"@webstudio-is/react-sdk": "0.207.0",
|
|
54
|
+
"@webstudio-is/sdk": "0.207.0",
|
|
55
|
+
"@webstudio-is/image": "0.207.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@testing-library/
|
|
58
|
+
"@testing-library/dom": "^10.4.0",
|
|
59
|
+
"@testing-library/react": "^16.2.0",
|
|
59
60
|
"@types/react": "^18.2.70",
|
|
60
61
|
"@types/react-dom": "^18.2.25",
|
|
61
62
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
62
63
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
63
|
-
"vitest": "^3.0.
|
|
64
|
+
"vitest": "^3.0.8",
|
|
64
65
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
65
66
|
"@webstudio-is/sdk-cli": "0.94.0",
|
|
66
|
-
"@webstudio-is/template": "0.
|
|
67
|
+
"@webstudio-is/template": "0.207.0",
|
|
67
68
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
68
69
|
},
|
|
69
70
|
"scripts": {
|