@dialtribe/react-sdk 0.1.0-alpha.11 → 0.1.0-alpha.14
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/README.md +11 -11
- package/dist/{broadcast-player-DnnXgWin.d.mts → dialtribe-player-CNriUtNi.d.mts} +87 -87
- package/dist/{broadcast-player-DnnXgWin.d.ts → dialtribe-player-CNriUtNi.d.ts} +87 -87
- package/dist/dialtribe-player.d.mts +3 -0
- package/dist/dialtribe-player.d.ts +3 -0
- package/dist/{broadcast-player.js → dialtribe-player.js} +105 -108
- package/dist/dialtribe-player.js.map +1 -0
- package/dist/{broadcast-player.mjs → dialtribe-player.mjs} +100 -103
- package/dist/dialtribe-player.mjs.map +1 -0
- package/dist/{broadcast-streamer.d.ts → dialtribe-streamer.d.mts} +203 -32
- package/dist/{broadcast-streamer.d.mts → dialtribe-streamer.d.ts} +203 -32
- package/dist/{broadcast-streamer.js → dialtribe-streamer.js} +386 -257
- package/dist/dialtribe-streamer.js.map +1 -0
- package/dist/{broadcast-streamer.mjs → dialtribe-streamer.mjs} +276 -150
- package/dist/dialtribe-streamer.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +382 -253
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +273 -147
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -9
- package/dist/broadcast-player.d.mts +0 -3
- package/dist/broadcast-player.d.ts +0 -3
- package/dist/broadcast-player.js.map +0 -1
- package/dist/broadcast-player.mjs.map +0 -1
- package/dist/broadcast-streamer.js.map +0 -1
- package/dist/broadcast-streamer.mjs.map +0 -1
|
@@ -2,9 +2,9 @@ import { createContext, useState, useCallback, useEffect, useContext, useRef, Co
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import ReactPlayer from 'react-player';
|
|
4
4
|
|
|
5
|
-
// src/context/
|
|
6
|
-
var
|
|
7
|
-
function
|
|
5
|
+
// src/context/DialtribeProvider.tsx
|
|
6
|
+
var DialtribeContext = createContext(null);
|
|
7
|
+
function DialtribeProvider({
|
|
8
8
|
sessionToken: initialToken,
|
|
9
9
|
onTokenRefresh,
|
|
10
10
|
onTokenExpired,
|
|
@@ -40,19 +40,19 @@ function DialTribeProvider({
|
|
|
40
40
|
markExpired,
|
|
41
41
|
apiBaseUrl
|
|
42
42
|
};
|
|
43
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
+
return /* @__PURE__ */ jsx(DialtribeContext.Provider, { value, children });
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const context = useContext(
|
|
45
|
+
function useDialtribe() {
|
|
46
|
+
const context = useContext(DialtribeContext);
|
|
47
47
|
if (!context) {
|
|
48
48
|
throw new Error(
|
|
49
|
-
'
|
|
49
|
+
'useDialtribe must be used within a DialtribeProvider. Wrap your app with <DialtribeProvider sessionToken="sess_xxx">...</DialtribeProvider>'
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
return context;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// src/client/
|
|
55
|
+
// src/client/DialtribeClient.ts
|
|
56
56
|
function getDefaultApiBaseUrl() {
|
|
57
57
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_DIALTRIBE_API_URL) {
|
|
58
58
|
return process.env.NEXT_PUBLIC_DIALTRIBE_API_URL;
|
|
@@ -72,13 +72,13 @@ function getEndpoints(baseUrl = DIALTRIBE_API_BASE) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
var ENDPOINTS = getEndpoints();
|
|
75
|
-
var
|
|
75
|
+
var DialtribeClient = class {
|
|
76
76
|
constructor(config) {
|
|
77
77
|
this.config = config;
|
|
78
78
|
this.endpoints = config.apiBaseUrl ? getEndpoints(config.apiBaseUrl) : ENDPOINTS;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Make an authenticated request to
|
|
81
|
+
* Make an authenticated request to Dialtribe API
|
|
82
82
|
*
|
|
83
83
|
* Automatically:
|
|
84
84
|
* - Adds Authorization header with session token
|
|
@@ -743,7 +743,7 @@ function getErrorMessage(error) {
|
|
|
743
743
|
}
|
|
744
744
|
return "Unable to play media. Please try refreshing the page or contact support if the problem persists.";
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function DialtribePlayer({
|
|
747
747
|
broadcast,
|
|
748
748
|
appId,
|
|
749
749
|
contentId,
|
|
@@ -754,18 +754,18 @@ function BroadcastPlayer({
|
|
|
754
754
|
className = "",
|
|
755
755
|
enableKeyboardShortcuts = false
|
|
756
756
|
}) {
|
|
757
|
-
const { sessionToken, setSessionToken, markExpired, apiBaseUrl } =
|
|
757
|
+
const { sessionToken, setSessionToken, markExpired, apiBaseUrl } = useDialtribe();
|
|
758
758
|
const clientRef = useRef(null);
|
|
759
759
|
if (!clientRef.current && sessionToken) {
|
|
760
|
-
clientRef.current = new
|
|
760
|
+
clientRef.current = new DialtribeClient({
|
|
761
761
|
sessionToken,
|
|
762
762
|
apiBaseUrl,
|
|
763
763
|
onTokenRefresh: (newToken, expiresAt) => {
|
|
764
|
-
debug.log(`[
|
|
764
|
+
debug.log(`[DialtribeClient] Token refreshed, expires at ${expiresAt}`);
|
|
765
765
|
setSessionToken(newToken, expiresAt);
|
|
766
766
|
},
|
|
767
767
|
onTokenExpired: () => {
|
|
768
|
-
debug.error("[
|
|
768
|
+
debug.error("[DialtribeClient] Token expired");
|
|
769
769
|
markExpired();
|
|
770
770
|
}
|
|
771
771
|
});
|
|
@@ -1210,7 +1210,7 @@ function BroadcastPlayer({
|
|
|
1210
1210
|
setAudioElement(internalPlayer);
|
|
1211
1211
|
}
|
|
1212
1212
|
} catch (error) {
|
|
1213
|
-
debug.error("[
|
|
1213
|
+
debug.error("[DialtribePlayer] Error getting internal player:", error);
|
|
1214
1214
|
}
|
|
1215
1215
|
};
|
|
1216
1216
|
useEffect(() => {
|
|
@@ -1418,7 +1418,7 @@ function BroadcastPlayer({
|
|
|
1418
1418
|
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ jsx(LoadingSpinner, { variant: "white", text: "Loading..." }) });
|
|
1419
1419
|
}
|
|
1420
1420
|
const hasTranscript = broadcast.transcriptStatus === 2 && transcriptData && (transcriptData.segments && transcriptData.segments.some((s) => s.words && s.words.length > 0) || transcriptData.words && transcriptData.words.length > 0);
|
|
1421
|
-
|
|
1421
|
+
const playerContent = /* @__PURE__ */ jsxs("div", { className: `bg-black rounded-lg shadow-2xl w-full max-h-full flex flex-col overflow-hidden ${className}`, children: [
|
|
1422
1422
|
/* @__PURE__ */ jsxs("div", { className: "bg-zinc-900/50 backdrop-blur-sm border-b border-zinc-800 px-3 sm:px-4 md:px-6 py-2 sm:py-3 md:py-4 flex justify-between items-center rounded-t-lg shrink-0", children: [
|
|
1423
1423
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1424
1424
|
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-white", children: broadcast.streamKeyRecord?.foreignName || "Broadcast" }),
|
|
@@ -1950,90 +1950,9 @@ function BroadcastPlayer({
|
|
|
1950
1950
|
}
|
|
1951
1951
|
` })
|
|
1952
1952
|
] });
|
|
1953
|
+
return playerContent;
|
|
1953
1954
|
}
|
|
1954
|
-
|
|
1955
|
-
broadcast,
|
|
1956
|
-
isOpen,
|
|
1957
|
-
onClose,
|
|
1958
|
-
appId,
|
|
1959
|
-
contentId,
|
|
1960
|
-
foreignId,
|
|
1961
|
-
foreignTier,
|
|
1962
|
-
renderClipCreator,
|
|
1963
|
-
className,
|
|
1964
|
-
enableKeyboardShortcuts = false
|
|
1965
|
-
}) {
|
|
1966
|
-
const closeButtonRef = useRef(null);
|
|
1967
|
-
const previousActiveElement = useRef(null);
|
|
1968
|
-
useEffect(() => {
|
|
1969
|
-
if (!isOpen) return;
|
|
1970
|
-
previousActiveElement.current = document.activeElement;
|
|
1971
|
-
setTimeout(() => {
|
|
1972
|
-
closeButtonRef.current?.focus();
|
|
1973
|
-
}, 100);
|
|
1974
|
-
return () => {
|
|
1975
|
-
if (previousActiveElement.current) {
|
|
1976
|
-
previousActiveElement.current.focus();
|
|
1977
|
-
}
|
|
1978
|
-
};
|
|
1979
|
-
}, [isOpen]);
|
|
1980
|
-
useEffect(() => {
|
|
1981
|
-
if (!isOpen) return;
|
|
1982
|
-
const handleKeyDown = (e) => {
|
|
1983
|
-
if (e.key === "Escape") {
|
|
1984
|
-
onClose();
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
1988
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
1989
|
-
}, [isOpen, onClose]);
|
|
1990
|
-
if (!isOpen) return null;
|
|
1991
|
-
const handleBackdropClick = (e) => {
|
|
1992
|
-
if (e.target === e.currentTarget) {
|
|
1993
|
-
onClose();
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
|
-
return /* @__PURE__ */ jsx(
|
|
1997
|
-
"div",
|
|
1998
|
-
{
|
|
1999
|
-
className: "fixed inset-0 bg-black/70 backdrop-blur-xl flex items-center justify-center z-50 p-2 sm:p-4",
|
|
2000
|
-
onClick: handleBackdropClick,
|
|
2001
|
-
role: "dialog",
|
|
2002
|
-
"aria-modal": "true",
|
|
2003
|
-
"aria-label": "Broadcast player",
|
|
2004
|
-
children: /* @__PURE__ */ jsxs("div", { className: "relative w-full max-w-7xl max-h-[95vh] sm:max-h-[90vh] overflow-hidden", children: [
|
|
2005
|
-
/* @__PURE__ */ jsx(
|
|
2006
|
-
"button",
|
|
2007
|
-
{
|
|
2008
|
-
ref: closeButtonRef,
|
|
2009
|
-
onClick: onClose,
|
|
2010
|
-
className: "absolute top-2 right-2 sm:top-4 sm:right-4 z-10 text-gray-400 hover:text-white text-2xl leading-none transition-colors w-8 h-8 flex items-center justify-center bg-black/50 rounded-full",
|
|
2011
|
-
title: "Close (ESC)",
|
|
2012
|
-
"aria-label": "Close player",
|
|
2013
|
-
children: "\xD7"
|
|
2014
|
-
}
|
|
2015
|
-
),
|
|
2016
|
-
/* @__PURE__ */ jsx(
|
|
2017
|
-
BroadcastPlayer,
|
|
2018
|
-
{
|
|
2019
|
-
broadcast,
|
|
2020
|
-
appId,
|
|
2021
|
-
contentId,
|
|
2022
|
-
foreignId,
|
|
2023
|
-
foreignTier,
|
|
2024
|
-
renderClipCreator,
|
|
2025
|
-
className,
|
|
2026
|
-
enableKeyboardShortcuts,
|
|
2027
|
-
onError: (error) => {
|
|
2028
|
-
debug.error("[BroadcastPlayerModal] Player error:", error);
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
)
|
|
2032
|
-
] })
|
|
2033
|
-
}
|
|
2034
|
-
);
|
|
2035
|
-
}
|
|
2036
|
-
var BroadcastPlayerErrorBoundary = class extends Component {
|
|
1955
|
+
var DialtribePlayerErrorBoundary = class extends Component {
|
|
2037
1956
|
constructor(props) {
|
|
2038
1957
|
super(props);
|
|
2039
1958
|
this.handleReset = () => {
|
|
@@ -2159,7 +2078,85 @@ var BroadcastPlayerErrorBoundary = class extends Component {
|
|
|
2159
2078
|
return this.props.children;
|
|
2160
2079
|
}
|
|
2161
2080
|
};
|
|
2081
|
+
var overlayStyles = {
|
|
2082
|
+
modal: {
|
|
2083
|
+
backdrop: "bg-black/70 backdrop-blur-xl p-2 sm:p-4",
|
|
2084
|
+
container: "max-w-7xl max-h-[95vh] sm:max-h-[90vh]"
|
|
2085
|
+
},
|
|
2086
|
+
fullscreen: {
|
|
2087
|
+
backdrop: "bg-black",
|
|
2088
|
+
container: "h-full"
|
|
2089
|
+
}
|
|
2090
|
+
};
|
|
2091
|
+
function DialtribeOverlay({
|
|
2092
|
+
isOpen,
|
|
2093
|
+
onClose,
|
|
2094
|
+
mode = "modal",
|
|
2095
|
+
children,
|
|
2096
|
+
ariaLabel = "Dialog",
|
|
2097
|
+
showCloseButton = true,
|
|
2098
|
+
closeOnBackdropClick = true,
|
|
2099
|
+
closeOnEsc = true
|
|
2100
|
+
}) {
|
|
2101
|
+
const closeButtonRef = useRef(null);
|
|
2102
|
+
const previousActiveElement = useRef(null);
|
|
2103
|
+
useEffect(() => {
|
|
2104
|
+
if (!isOpen) return;
|
|
2105
|
+
previousActiveElement.current = document.activeElement;
|
|
2106
|
+
setTimeout(() => {
|
|
2107
|
+
closeButtonRef.current?.focus();
|
|
2108
|
+
}, 100);
|
|
2109
|
+
return () => {
|
|
2110
|
+
if (previousActiveElement.current) {
|
|
2111
|
+
previousActiveElement.current.focus();
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
}, [isOpen]);
|
|
2115
|
+
useEffect(() => {
|
|
2116
|
+
if (!isOpen || !closeOnEsc) return;
|
|
2117
|
+
const handleKeyDown = (e) => {
|
|
2118
|
+
if (e.key === "Escape") {
|
|
2119
|
+
onClose();
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
2123
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2124
|
+
}, [isOpen, onClose, closeOnEsc]);
|
|
2125
|
+
if (!isOpen) {
|
|
2126
|
+
return null;
|
|
2127
|
+
}
|
|
2128
|
+
const handleBackdropClick = (e) => {
|
|
2129
|
+
if (closeOnBackdropClick && e.target === e.currentTarget) {
|
|
2130
|
+
onClose();
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
const styles = overlayStyles[mode];
|
|
2134
|
+
return /* @__PURE__ */ jsx(
|
|
2135
|
+
"div",
|
|
2136
|
+
{
|
|
2137
|
+
className: `fixed inset-0 flex items-center justify-center z-50 ${styles.backdrop}`,
|
|
2138
|
+
onClick: handleBackdropClick,
|
|
2139
|
+
role: "dialog",
|
|
2140
|
+
"aria-modal": "true",
|
|
2141
|
+
"aria-label": ariaLabel,
|
|
2142
|
+
children: /* @__PURE__ */ jsxs("div", { className: `relative w-full overflow-hidden ${styles.container}`, children: [
|
|
2143
|
+
showCloseButton && /* @__PURE__ */ jsx(
|
|
2144
|
+
"button",
|
|
2145
|
+
{
|
|
2146
|
+
ref: closeButtonRef,
|
|
2147
|
+
onClick: onClose,
|
|
2148
|
+
className: "absolute top-2 right-2 sm:top-4 sm:right-4 z-10 text-gray-400 hover:text-white text-2xl leading-none transition-colors w-8 h-8 flex items-center justify-center bg-black/50 rounded-full",
|
|
2149
|
+
title: "Close (ESC)",
|
|
2150
|
+
"aria-label": "Close",
|
|
2151
|
+
children: "\xD7"
|
|
2152
|
+
}
|
|
2153
|
+
),
|
|
2154
|
+
children
|
|
2155
|
+
] })
|
|
2156
|
+
}
|
|
2157
|
+
);
|
|
2158
|
+
}
|
|
2162
2159
|
|
|
2163
|
-
export { AudioWaveform,
|
|
2164
|
-
//# sourceMappingURL=
|
|
2165
|
-
//# sourceMappingURL=
|
|
2160
|
+
export { AudioWaveform, CDN_DOMAIN, DIALTRIBE_API_BASE, DialtribeClient, DialtribeOverlay, DialtribePlayer, DialtribePlayerErrorBoundary, DialtribeProvider, ENDPOINTS, HTTP_STATUS, LoadingSpinner, buildBroadcastCdnUrl, buildBroadcastS3KeyPrefix, formatTime, useDialtribe };
|
|
2161
|
+
//# sourceMappingURL=dialtribe-player.mjs.map
|
|
2162
|
+
//# sourceMappingURL=dialtribe-player.mjs.map
|