@streamplace/components 0.7.0 → 0.7.2
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/components/chat/chat-box.js +46 -43
- package/dist/components/chat/chat-message.js +36 -33
- package/dist/components/chat/chat.js +31 -27
- package/dist/components/chat/mention-suggestions.js +16 -13
- package/dist/components/chat/mod-view.js +20 -17
- package/dist/components/mobile-player/fullscreen.js +21 -17
- package/dist/components/mobile-player/fullscreen.native.js +39 -35
- package/dist/components/mobile-player/player.js +38 -32
- package/dist/components/mobile-player/props.js +2 -1
- package/dist/components/mobile-player/shared.js +16 -13
- package/dist/components/mobile-player/ui/countdown.js +23 -19
- package/dist/components/mobile-player/ui/index.js +9 -5
- package/dist/components/mobile-player/ui/input.js +16 -12
- package/dist/components/mobile-player/ui/metrics.js +20 -16
- package/dist/components/mobile-player/ui/streamer-context-menu.js +6 -3
- package/dist/components/mobile-player/ui/viewer-context-menu.js +19 -16
- package/dist/components/mobile-player/ui/viewers.js +23 -0
- package/dist/components/mobile-player/use-webrtc.js +29 -24
- package/dist/components/mobile-player/video.js +109 -99
- package/dist/components/mobile-player/video.native.js +108 -84
- package/dist/components/mobile-player/webrtc-diagnostics.js +9 -5
- package/dist/components/mobile-player/webrtc-primitives.js +8 -6
- package/dist/components/mobile-player/webrtc-primitives.native.js +8 -1
- package/dist/components/ui/button.js +26 -23
- package/dist/components/ui/dialog.js +43 -40
- package/dist/components/ui/dropdown.js +121 -116
- package/dist/components/ui/icons.js +8 -5
- package/dist/components/ui/index.js +27 -19
- package/dist/components/ui/input.js +31 -28
- package/dist/components/ui/loader.js +9 -6
- package/dist/components/ui/primitives/button.js +33 -29
- package/dist/components/ui/primitives/input.js +44 -40
- package/dist/components/ui/primitives/modal.js +45 -41
- package/dist/components/ui/primitives/text.js +35 -29
- package/dist/components/ui/resizeable.js +54 -43
- package/dist/components/ui/text.js +50 -48
- package/dist/components/ui/textarea.js +13 -11
- package/dist/components/ui/toast.js +26 -23
- package/dist/components/ui/view.js +41 -39
- package/dist/hooks/index.js +12 -8
- package/dist/hooks/useAvatars.js +11 -8
- package/dist/hooks/useCameraToggle.js +7 -4
- package/dist/hooks/useKeyboard.js +13 -10
- package/dist/hooks/useKeyboardSlide.js +8 -5
- package/dist/hooks/useLivestreamInfo.js +17 -14
- package/dist/hooks/useOuterAndInnerDimensions.js +9 -6
- package/dist/hooks/usePlayerDimensions.js +9 -6
- package/dist/hooks/useSegmentDimensions.js +17 -0
- package/dist/hooks/useSegmentTiming.js +13 -10
- package/dist/index.js +24 -15
- package/dist/lib/facet.js +5 -1
- package/dist/lib/theme/atoms.js +153 -148
- package/dist/lib/theme/atoms.types.js +2 -1
- package/dist/lib/theme/index.js +31 -5
- package/dist/lib/theme/theme.js +91 -83
- package/dist/lib/theme/tokens.js +15 -12
- package/dist/lib/utils.js +22 -11
- package/dist/livestream-provider/index.js +19 -14
- package/dist/livestream-provider/websocket.js +14 -10
- package/dist/livestream-store/chat.js +26 -19
- package/dist/livestream-store/context.js +5 -2
- package/dist/livestream-store/index.js +7 -4
- package/dist/livestream-store/livestream-state.js +2 -1
- package/dist/livestream-store/livestream-store.js +31 -18
- package/dist/livestream-store/stream-key.js +22 -18
- package/dist/livestream-store/websocket-consumer.js +18 -14
- package/dist/player-store/context.js +5 -2
- package/dist/player-store/index.js +8 -5
- package/dist/player-store/player-provider.js +20 -15
- package/dist/player-store/player-state.js +9 -6
- package/dist/player-store/player-store.js +32 -21
- package/dist/player-store/single-player-provider.js +35 -23
- package/dist/streamplace-provider/context.js +5 -2
- package/dist/streamplace-provider/index.js +14 -10
- package/dist/streamplace-provider/poller.js +20 -17
- package/dist/streamplace-store/block.js +6 -3
- package/dist/streamplace-store/index.js +6 -3
- package/dist/streamplace-store/stream.js +14 -10
- package/dist/streamplace-store/streamplace-store.js +23 -13
- package/dist/streamplace-store/user.js +19 -14
- package/dist/streamplace-store/xrpc.js +10 -7
- package/node-compile-cache/v22.15.0-x64-92db9086-0/37be0eec +0 -0
- package/node-compile-cache/v22.15.0-x64-92db9086-0/56540125 +0 -0
- package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/67b1eb60 +0 -0
- package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/7c275f90 +0 -0
- package/package.json +6 -7
- package/src/components/mobile-player/ui/index.ts +1 -0
- package/src/components/mobile-player/ui/viewer-context-menu.tsx +5 -4
- package/src/components/mobile-player/ui/viewers.tsx +32 -0
- package/src/components/mobile-player/video.native.tsx +50 -5
- package/src/components/ui/resizeable.tsx +15 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useSegmentDimensions.tsx +18 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/56540125 +0 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRenditions = exports.useSegment = exports.useLivestream = exports.useViewers = exports.useProfile = exports.useChat = exports.useHandleWebsocketMessages = exports.makeLivestreamStore = void 0;
|
|
4
|
+
exports.getStoreFromContext = getStoreFromContext;
|
|
5
|
+
exports.useLivestreamStore = useLivestreamStore;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const zustand_1 = require("zustand");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const websocket_consumer_1 = require("./websocket-consumer");
|
|
10
|
+
const makeLivestreamStore = () => {
|
|
11
|
+
return (0, zustand_1.createStore)()((set) => ({
|
|
7
12
|
profile: null,
|
|
8
13
|
chatIndex: {},
|
|
9
14
|
chat: [],
|
|
@@ -17,26 +22,34 @@ export const makeLivestreamStore = () => {
|
|
|
17
22
|
authors: {},
|
|
18
23
|
}));
|
|
19
24
|
};
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
exports.makeLivestreamStore = makeLivestreamStore;
|
|
26
|
+
function getStoreFromContext() {
|
|
27
|
+
const context = (0, react_1.useContext)(context_1.LivestreamContext);
|
|
22
28
|
if (!context) {
|
|
23
29
|
throw new Error("useLivestreamStore must be used within a LivestreamProvider");
|
|
24
30
|
}
|
|
25
31
|
return context.store;
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
function useLivestreamStore(selector) {
|
|
28
34
|
const store = getStoreFromContext();
|
|
29
|
-
return useStore(store, selector);
|
|
35
|
+
return (0, zustand_1.useStore)(store, selector);
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
const useHandleWebsocketMessages = () => {
|
|
32
38
|
const store = getStoreFromContext();
|
|
33
39
|
return (messages) => {
|
|
34
|
-
store.setState((state) => handleWebSocketMessages(state, messages));
|
|
40
|
+
store.setState((state) => (0, websocket_consumer_1.handleWebSocketMessages)(state, messages));
|
|
35
41
|
};
|
|
36
42
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
exports.useHandleWebsocketMessages = useHandleWebsocketMessages;
|
|
44
|
+
const useChat = () => useLivestreamStore((x) => x.chat);
|
|
45
|
+
exports.useChat = useChat;
|
|
46
|
+
const useProfile = () => useLivestreamStore((x) => x.profile);
|
|
47
|
+
exports.useProfile = useProfile;
|
|
48
|
+
const useViewers = () => useLivestreamStore((x) => x.viewers);
|
|
49
|
+
exports.useViewers = useViewers;
|
|
50
|
+
const useLivestream = () => useLivestreamStore((x) => x.livestream);
|
|
51
|
+
exports.useLivestream = useLivestream;
|
|
52
|
+
const useSegment = () => useLivestreamStore((x) => x.segment);
|
|
53
|
+
exports.useSegment = useSegment;
|
|
54
|
+
const useRenditions = () => useLivestreamStore((x) => x.renditions);
|
|
55
|
+
exports.useRenditions = useRenditions;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStreamKey = void 0;
|
|
4
|
+
const crypto_1 = require("@atproto/crypto");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const accounts_1 = require("viem/accounts");
|
|
8
|
+
const xrpc_1 = require("../streamplace-store/xrpc");
|
|
9
|
+
const livestream_store_1 = require("./livestream-store");
|
|
7
10
|
function getBrowserName(userAgent) {
|
|
8
11
|
// The order matters here, and this may report false positives for unlisted browsers.
|
|
9
12
|
if (userAgent.includes("Firefox")) {
|
|
@@ -36,13 +39,13 @@ function getBrowserName(userAgent) {
|
|
|
36
39
|
}
|
|
37
40
|
return "unknown";
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
const pdsAgent = usePDSAgent();
|
|
41
|
-
const streamKey = useLivestreamStore((state) => state.streamKey);
|
|
42
|
-
const setStreamKey = useLivestreamStore((state) => state.setStreamKey);
|
|
43
|
-
const [key, setKey] = useState(streamKey ? JSON.parse(streamKey) : null);
|
|
44
|
-
const [error, setError] = useState(null);
|
|
45
|
-
useEffect(() => {
|
|
42
|
+
const useStreamKey = () => {
|
|
43
|
+
const pdsAgent = (0, xrpc_1.usePDSAgent)();
|
|
44
|
+
const streamKey = (0, livestream_store_1.useLivestreamStore)((state) => state.streamKey);
|
|
45
|
+
const setStreamKey = (0, livestream_store_1.useLivestreamStore)((state) => state.setStreamKey);
|
|
46
|
+
const [key, setKey] = (0, react_1.useState)(streamKey ? JSON.parse(streamKey) : null);
|
|
47
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
46
49
|
if (key)
|
|
47
50
|
return; // already have key
|
|
48
51
|
const generateKey = async () => {
|
|
@@ -55,22 +58,22 @@ export const useStreamKey = () => {
|
|
|
55
58
|
setError("PDS Agent did is not available (not logged in?)");
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
|
-
const keypair = await Secp256k1Keypair.create({ exportable: true });
|
|
61
|
+
const keypair = await crypto_1.Secp256k1Keypair.create({ exportable: true });
|
|
59
62
|
const exportedKey = await keypair.export();
|
|
60
63
|
const didBytes = new TextEncoder().encode(did);
|
|
61
64
|
const combinedKey = new Uint8Array([...exportedKey, ...didBytes]);
|
|
62
|
-
const multibaseKey = bytesToMultibase(combinedKey, "base58btc");
|
|
65
|
+
const multibaseKey = (0, crypto_1.bytesToMultibase)(combinedKey, "base58btc");
|
|
63
66
|
const hexKey = Array.from(exportedKey)
|
|
64
67
|
.map((b) => b.toString(16).padStart(2, "0"))
|
|
65
68
|
.join("");
|
|
66
|
-
const account = privateKeyToAccount(`0x${hexKey}`);
|
|
69
|
+
const account = (0, accounts_1.privateKeyToAccount)(`0x${hexKey}`);
|
|
67
70
|
const newKey = {
|
|
68
71
|
privateKey: multibaseKey,
|
|
69
72
|
did: keypair.did(),
|
|
70
73
|
address: account.address.toLowerCase(),
|
|
71
74
|
};
|
|
72
|
-
let platform = Platform.OS;
|
|
73
|
-
if (Platform.OS === "web" &&
|
|
75
|
+
let platform = react_native_1.Platform.OS;
|
|
76
|
+
if (react_native_1.Platform.OS === "web" &&
|
|
74
77
|
typeof window !== "undefined" &&
|
|
75
78
|
window.navigator) {
|
|
76
79
|
if (window.navigator.userAgent.includes("streamplace-desktop")) {
|
|
@@ -113,3 +116,4 @@ export const useStreamKey = () => {
|
|
|
113
116
|
}, [key, setStreamKey]);
|
|
114
117
|
return { streamKey: key, error };
|
|
115
118
|
};
|
|
119
|
+
exports.useStreamKey = useStreamKey;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleWebSocketMessages = void 0;
|
|
4
|
+
const api_1 = require("@atproto/api");
|
|
5
|
+
const streamplace_1 = require("streamplace");
|
|
6
|
+
const chat_1 = require("./chat");
|
|
7
|
+
const handleWebSocketMessages = (state, messages) => {
|
|
5
8
|
for (const message of messages) {
|
|
6
|
-
if (PlaceStreamLivestream.isLivestreamView(message)) {
|
|
9
|
+
if (streamplace_1.PlaceStreamLivestream.isLivestreamView(message)) {
|
|
7
10
|
state = {
|
|
8
11
|
...state,
|
|
9
12
|
livestream: message,
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
|
-
else if (PlaceStreamLivestream.isViewerCount(message)) {
|
|
15
|
+
else if (streamplace_1.PlaceStreamLivestream.isViewerCount(message)) {
|
|
13
16
|
state = {
|
|
14
17
|
...state,
|
|
15
18
|
viewers: message.count,
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
|
-
else if (PlaceStreamChatDefs.isMessageView(message)) {
|
|
21
|
+
else if (streamplace_1.PlaceStreamChatDefs.isMessageView(message)) {
|
|
19
22
|
// Explicitly map MessageView to MessageViewHydrated
|
|
20
23
|
const hydrated = {
|
|
21
24
|
uri: message.uri,
|
|
@@ -26,30 +29,31 @@ export const handleWebSocketMessages = (state, messages) => {
|
|
|
26
29
|
chatProfile: message.chatProfile,
|
|
27
30
|
replyTo: message.replyTo,
|
|
28
31
|
};
|
|
29
|
-
state = reduceChat(state, [hydrated], []);
|
|
32
|
+
state = (0, chat_1.reduceChat)(state, [hydrated], []);
|
|
30
33
|
}
|
|
31
|
-
else if (PlaceStreamSegment.isRecord(message)) {
|
|
34
|
+
else if (streamplace_1.PlaceStreamSegment.isRecord(message)) {
|
|
32
35
|
state = {
|
|
33
36
|
...state,
|
|
34
37
|
segment: message,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
|
-
else if (PlaceStreamDefs.isBlockView(message)) {
|
|
40
|
+
else if (streamplace_1.PlaceStreamDefs.isBlockView(message)) {
|
|
38
41
|
const block = message;
|
|
39
|
-
state = reduceChat(state, [], [block]);
|
|
42
|
+
state = (0, chat_1.reduceChat)(state, [], [block]);
|
|
40
43
|
}
|
|
41
|
-
else if (PlaceStreamDefs.isRenditions(message)) {
|
|
44
|
+
else if (streamplace_1.PlaceStreamDefs.isRenditions(message)) {
|
|
42
45
|
state = {
|
|
43
46
|
...state,
|
|
44
47
|
renditions: message.renditions,
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
|
-
else if (AppBskyActorDefs.isProfileViewBasic(message)) {
|
|
50
|
+
else if (api_1.AppBskyActorDefs.isProfileViewBasic(message)) {
|
|
48
51
|
state = {
|
|
49
52
|
...state,
|
|
50
53
|
profile: message,
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
|
-
return reduceChat(state, [], []);
|
|
57
|
+
return (0, chat_1.reduceChat)(state, [], []);
|
|
55
58
|
};
|
|
59
|
+
exports.handleWebSocketMessages = handleWebSocketMessages;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlayerContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.PlayerContext = (0, react_1.createContext)(null);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
1
4
|
// barrel file :)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
tslib_1.__exportStar(require("./context"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./player-provider"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./player-state"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./player-store"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./single-player-provider"), exports);
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlayerProvider = void 0;
|
|
4
|
+
exports.withPlayerProvider = withPlayerProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
const player_store_1 = require("./player-store");
|
|
9
|
+
const PlayerProvider = ({ children, initialPlayers = [], defaultId = Math.random().toString(36).slice(8), }) => {
|
|
10
|
+
const [players, setPlayers] = (0, react_1.useState)(() => {
|
|
7
11
|
// Initialize with any initial player IDs provided
|
|
8
12
|
const initialPlayerStores = {};
|
|
9
13
|
for (const playerId of initialPlayers) {
|
|
10
|
-
initialPlayerStores[playerId] = makePlayerStore(playerId);
|
|
14
|
+
initialPlayerStores[playerId] = (0, player_store_1.makePlayerStore)(playerId);
|
|
11
15
|
}
|
|
12
16
|
// Always create at least one player by default
|
|
13
17
|
if (initialPlayers.length === 0) {
|
|
14
|
-
initialPlayerStores[defaultId] = makePlayerStore(defaultId);
|
|
18
|
+
initialPlayerStores[defaultId] = (0, player_store_1.makePlayerStore)(defaultId);
|
|
15
19
|
}
|
|
16
20
|
return initialPlayerStores;
|
|
17
21
|
});
|
|
18
|
-
const createPlayer = useCallback((id) => {
|
|
22
|
+
const createPlayer = (0, react_1.useCallback)((id) => {
|
|
19
23
|
const playerId = id || Math.random().toString(36).slice(8);
|
|
20
|
-
const playerStore = makePlayerStore(playerId);
|
|
24
|
+
const playerStore = (0, player_store_1.makePlayerStore)(playerId);
|
|
21
25
|
setPlayers((prev) => ({
|
|
22
26
|
...prev,
|
|
23
27
|
[playerId]: playerStore,
|
|
24
28
|
}));
|
|
25
29
|
return playerId;
|
|
26
30
|
}, []);
|
|
27
|
-
const removePlayer = useCallback((id) => {
|
|
31
|
+
const removePlayer = (0, react_1.useCallback)((id) => {
|
|
28
32
|
setPlayers((prev) => {
|
|
29
33
|
// Don't remove the last player
|
|
30
34
|
if (Object.keys(prev).length <= 1) {
|
|
@@ -36,17 +40,18 @@ export const PlayerProvider = ({ children, initialPlayers = [], defaultId = Math
|
|
|
36
40
|
return newPlayers;
|
|
37
41
|
});
|
|
38
42
|
}, []);
|
|
39
|
-
const contextValue = useMemo(() => ({
|
|
43
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
40
44
|
players,
|
|
41
45
|
createPlayer,
|
|
42
46
|
removePlayer,
|
|
43
47
|
}), [players, createPlayer, removePlayer]);
|
|
44
|
-
return (
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(context_1.PlayerContext.Provider, { value: contextValue, children: children }));
|
|
45
49
|
};
|
|
50
|
+
exports.PlayerProvider = PlayerProvider;
|
|
46
51
|
// HOC to wrap components that need player context
|
|
47
|
-
|
|
52
|
+
function withPlayerProvider(Component) {
|
|
48
53
|
return function WithPlayerProvider(props) {
|
|
49
54
|
const { initialPlayers, ...componentProps } = props;
|
|
50
|
-
return (
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(exports.PlayerProvider, { initialPlayers: initialPlayers, children: (0, jsx_runtime_1.jsx)(Component, { ...componentProps }) }));
|
|
51
56
|
};
|
|
52
57
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IngestMediaSource = exports.PlayerStatus = exports.PlayerProtocol = void 0;
|
|
4
|
+
var PlayerProtocol;
|
|
2
5
|
(function (PlayerProtocol) {
|
|
3
6
|
PlayerProtocol["WEBRTC"] = "webrtc";
|
|
4
7
|
PlayerProtocol["HLS"] = "hls";
|
|
5
8
|
PlayerProtocol["PROGRESSIVE_MP4"] = "progressive-mp4";
|
|
6
9
|
PlayerProtocol["PROGRESSIVE_WEBM"] = "progressive-webm";
|
|
7
|
-
})(PlayerProtocol || (PlayerProtocol = {}));
|
|
8
|
-
|
|
10
|
+
})(PlayerProtocol || (exports.PlayerProtocol = PlayerProtocol = {}));
|
|
11
|
+
var PlayerStatus;
|
|
9
12
|
(function (PlayerStatus) {
|
|
10
13
|
PlayerStatus["START"] = "start";
|
|
11
14
|
PlayerStatus["PLAYING"] = "playing";
|
|
@@ -14,9 +17,9 @@ export var PlayerStatus;
|
|
|
14
17
|
PlayerStatus["WAITING"] = "waiting";
|
|
15
18
|
PlayerStatus["PAUSE"] = "pause";
|
|
16
19
|
PlayerStatus["MUTE"] = "mute";
|
|
17
|
-
})(PlayerStatus || (PlayerStatus = {}));
|
|
18
|
-
|
|
20
|
+
})(PlayerStatus || (exports.PlayerStatus = PlayerStatus = {}));
|
|
21
|
+
var IngestMediaSource;
|
|
19
22
|
(function (IngestMediaSource) {
|
|
20
23
|
IngestMediaSource["USER"] = "user";
|
|
21
24
|
IngestMediaSource["DISPLAY"] = "display";
|
|
22
|
-
})(IngestMediaSource || (IngestMediaSource = {}));
|
|
25
|
+
})(IngestMediaSource || (exports.IngestMediaSource = IngestMediaSource = {}));
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.intoPlayerProtocol = exports.usePlayerProtocol = exports.makePlayerStore = void 0;
|
|
4
|
+
exports.usePlayerContext = usePlayerContext;
|
|
5
|
+
exports.getPlayerStoreById = getPlayerStoreById;
|
|
6
|
+
exports.getFirstPlayerID = getFirstPlayerID;
|
|
7
|
+
exports.getPlayerStoreFromContext = getPlayerStoreFromContext;
|
|
8
|
+
exports.usePlayerStore = usePlayerStore;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const zustand_1 = require("zustand");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const player_state_1 = require("./player-state");
|
|
13
|
+
const makePlayerStore = (id) => {
|
|
14
|
+
return (0, zustand_1.createStore)()((set) => ({
|
|
7
15
|
id: id || Math.random().toString(36).slice(8),
|
|
8
16
|
selectedRendition: "source",
|
|
9
17
|
setSelectedRendition: (rendition) => set((state) => ({ ...state, selectedRendition: rendition })),
|
|
10
|
-
protocol: PlayerProtocol.WEBRTC,
|
|
18
|
+
protocol: player_state_1.PlayerProtocol.WEBRTC,
|
|
11
19
|
setProtocol: (protocol) => set((state) => ({ ...state, protocol: protocol })),
|
|
12
20
|
src: "",
|
|
13
21
|
setSrc: (src) => set(() => ({ src })),
|
|
@@ -29,7 +37,7 @@ export const makePlayerStore = (id) => {
|
|
|
29
37
|
setVolume: (volume) => set(() => ({ volume, muteWasForced: false })),
|
|
30
38
|
fullscreen: false,
|
|
31
39
|
setFullscreen: (isFullscreen) => set(() => ({ fullscreen: isFullscreen })),
|
|
32
|
-
status: PlayerStatus.START,
|
|
40
|
+
status: player_state_1.PlayerStatus.START,
|
|
33
41
|
setStatus: (status) => set(() => ({ status })),
|
|
34
42
|
playTime: 0,
|
|
35
43
|
setPlayTime: (playTime) => set(() => ({ playTime })),
|
|
@@ -100,15 +108,16 @@ export const makePlayerStore = (id) => {
|
|
|
100
108
|
setModMessage: (modMessage) => set(() => ({ modMessage })),
|
|
101
109
|
}));
|
|
102
110
|
};
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
exports.makePlayerStore = makePlayerStore;
|
|
112
|
+
function usePlayerContext() {
|
|
113
|
+
const context = (0, react_1.useContext)(context_1.PlayerContext);
|
|
105
114
|
if (!context) {
|
|
106
115
|
throw new Error("usePlayerContext must be used within a PlayerProvider");
|
|
107
116
|
}
|
|
108
117
|
return context;
|
|
109
118
|
}
|
|
110
119
|
// Get a specific player store by ID
|
|
111
|
-
|
|
120
|
+
function getPlayerStoreById(id) {
|
|
112
121
|
const { players } = usePlayerContext();
|
|
113
122
|
const playerStore = players[id];
|
|
114
123
|
if (!playerStore) {
|
|
@@ -117,7 +126,7 @@ export function getPlayerStoreById(id) {
|
|
|
117
126
|
return playerStore;
|
|
118
127
|
}
|
|
119
128
|
// Will get the first player ID in the context
|
|
120
|
-
|
|
129
|
+
function getFirstPlayerID() {
|
|
121
130
|
const { players } = usePlayerContext();
|
|
122
131
|
const playerIds = Object.keys(players);
|
|
123
132
|
if (playerIds.length === 0) {
|
|
@@ -125,7 +134,7 @@ export function getFirstPlayerID() {
|
|
|
125
134
|
}
|
|
126
135
|
return playerIds[0];
|
|
127
136
|
}
|
|
128
|
-
|
|
137
|
+
function getPlayerStoreFromContext() {
|
|
129
138
|
console.warn("getPlayerStoreFromContext is deprecated. Use getPlayerStoreById instead.");
|
|
130
139
|
const { players } = usePlayerContext();
|
|
131
140
|
const playerIds = Object.keys(players);
|
|
@@ -136,24 +145,26 @@ export function getPlayerStoreFromContext() {
|
|
|
136
145
|
}
|
|
137
146
|
// Use a specific player store by ID
|
|
138
147
|
// If no ID is provided, it will use the first player in the context
|
|
139
|
-
|
|
148
|
+
function usePlayerStore(selector, playerId) {
|
|
140
149
|
if (!playerId) {
|
|
141
150
|
playerId = Object.keys(usePlayerContext().players)[0];
|
|
142
151
|
}
|
|
143
152
|
const store = getPlayerStoreById(playerId);
|
|
144
|
-
return useStore(store, selector);
|
|
153
|
+
return (0, zustand_1.useStore)(store, selector);
|
|
145
154
|
}
|
|
146
155
|
/* Convenience selectors/hooks */
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
const usePlayerProtocol = (playerId) => usePlayerStore((x) => [x.protocol, x.setProtocol], playerId);
|
|
157
|
+
exports.usePlayerProtocol = usePlayerProtocol;
|
|
158
|
+
const intoPlayerProtocol = (protocol) => {
|
|
149
159
|
switch (protocol) {
|
|
150
160
|
case "hls":
|
|
151
|
-
return PlayerProtocol.HLS;
|
|
161
|
+
return player_state_1.PlayerProtocol.HLS;
|
|
152
162
|
case "progressive-mp4":
|
|
153
|
-
return PlayerProtocol.PROGRESSIVE_MP4;
|
|
163
|
+
return player_state_1.PlayerProtocol.PROGRESSIVE_MP4;
|
|
154
164
|
case "progressive-webm":
|
|
155
|
-
return PlayerProtocol.PROGRESSIVE_WEBM;
|
|
165
|
+
return player_state_1.PlayerProtocol.PROGRESSIVE_WEBM;
|
|
156
166
|
default:
|
|
157
|
-
return PlayerProtocol.WEBRTC;
|
|
167
|
+
return player_state_1.PlayerProtocol.WEBRTC;
|
|
158
168
|
}
|
|
159
169
|
};
|
|
170
|
+
exports.intoPlayerProtocol = intoPlayerProtocol;
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SinglePlayerProvider = void 0;
|
|
4
|
+
exports.useSinglePlayerContext = useSinglePlayerContext;
|
|
5
|
+
exports.useCurrentPlayerId = useCurrentPlayerId;
|
|
6
|
+
exports.useCurrentPlayerStore = useCurrentPlayerStore;
|
|
7
|
+
exports.useCurrentPlayerProtocol = useCurrentPlayerProtocol;
|
|
8
|
+
exports.useCurrentPlayerRendition = useCurrentPlayerRendition;
|
|
9
|
+
exports.useCurrentPlayerIngest = useCurrentPlayerIngest;
|
|
10
|
+
exports.withSinglePlayer = withSinglePlayer;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
14
|
+
const zustand_1 = require("zustand");
|
|
15
|
+
const player_store_1 = require("../player-store");
|
|
16
|
+
const player_state_1 = require("./player-state");
|
|
17
|
+
const SinglePlayerContext = (0, react_1.createContext)(null);
|
|
7
18
|
/**
|
|
8
19
|
* Provider component for a single player that creates a scoped context
|
|
9
20
|
* This allows components to access a specific player's state without passing IDs around
|
|
10
21
|
*/
|
|
11
|
-
|
|
12
|
-
const { players, createPlayer } = usePlayerContext();
|
|
22
|
+
const SinglePlayerProvider = ({ children, playerId: providedPlayerId, protocol = player_state_1.PlayerProtocol.WEBRTC, rendition = "auto", }) => {
|
|
23
|
+
const { players, createPlayer } = (0, player_store_1.usePlayerContext)();
|
|
13
24
|
// Create or get a player ID
|
|
14
|
-
const playerId = useMemo(() => {
|
|
25
|
+
const playerId = (0, react_1.useMemo)(() => {
|
|
15
26
|
// If a player ID is provided and exists, use it
|
|
16
27
|
if (providedPlayerId && players[providedPlayerId]) {
|
|
17
28
|
return providedPlayerId;
|
|
@@ -24,11 +35,11 @@ export const SinglePlayerProvider = ({ children, playerId: providedPlayerId, pro
|
|
|
24
35
|
return createPlayer();
|
|
25
36
|
}, [providedPlayerId, players, createPlayer]);
|
|
26
37
|
// Get the player store
|
|
27
|
-
const playerStore = useMemo(() => {
|
|
38
|
+
const playerStore = (0, react_1.useMemo)(() => {
|
|
28
39
|
return players[playerId];
|
|
29
40
|
}, [players, playerId]);
|
|
30
41
|
// Set initial protocol and rendition if provided
|
|
31
|
-
|
|
42
|
+
react_1.default.useEffect(() => {
|
|
32
43
|
if (protocol) {
|
|
33
44
|
playerStore.setState((state) => ({
|
|
34
45
|
...state,
|
|
@@ -43,17 +54,18 @@ export const SinglePlayerProvider = ({ children, playerId: providedPlayerId, pro
|
|
|
43
54
|
}
|
|
44
55
|
}, [playerStore, protocol, rendition]);
|
|
45
56
|
// Create context value
|
|
46
|
-
const contextValue = useMemo(() => ({
|
|
57
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
47
58
|
playerId,
|
|
48
59
|
playerStore,
|
|
49
60
|
}), [playerId, playerStore]);
|
|
50
|
-
return (
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(SinglePlayerContext.Provider, { value: contextValue, children: children }));
|
|
51
62
|
};
|
|
63
|
+
exports.SinglePlayerProvider = SinglePlayerProvider;
|
|
52
64
|
/**
|
|
53
65
|
* Hook to access the current single player context
|
|
54
66
|
*/
|
|
55
|
-
|
|
56
|
-
const context = useContext(SinglePlayerContext);
|
|
67
|
+
function useSinglePlayerContext() {
|
|
68
|
+
const context = (0, react_1.useContext)(SinglePlayerContext);
|
|
57
69
|
if (!context) {
|
|
58
70
|
throw new Error("useSinglePlayerContext must be used within a SinglePlayerProvider");
|
|
59
71
|
}
|
|
@@ -62,33 +74,33 @@ export function useSinglePlayerContext() {
|
|
|
62
74
|
/**
|
|
63
75
|
* Hook to access the current player ID from the single player context
|
|
64
76
|
*/
|
|
65
|
-
|
|
77
|
+
function useCurrentPlayerId() {
|
|
66
78
|
const { playerId } = useSinglePlayerContext();
|
|
67
79
|
return playerId;
|
|
68
80
|
}
|
|
69
81
|
/**
|
|
70
82
|
* Hook to access state from the current player without needing to specify the ID
|
|
71
83
|
*/
|
|
72
|
-
|
|
84
|
+
function useCurrentPlayerStore(selector) {
|
|
73
85
|
const { playerStore } = useSinglePlayerContext();
|
|
74
|
-
return useStore(playerStore, selector);
|
|
86
|
+
return (0, zustand_1.useStore)(playerStore, selector);
|
|
75
87
|
}
|
|
76
88
|
/**
|
|
77
89
|
* Hook to get the protocol of the current player
|
|
78
90
|
*/
|
|
79
|
-
|
|
91
|
+
function useCurrentPlayerProtocol() {
|
|
80
92
|
return useCurrentPlayerStore((state) => [state.protocol, state.setProtocol]);
|
|
81
93
|
}
|
|
82
94
|
/**
|
|
83
95
|
* Hook to get the selected rendition of the current player
|
|
84
96
|
*/
|
|
85
|
-
|
|
97
|
+
function useCurrentPlayerRendition() {
|
|
86
98
|
return useCurrentPlayerStore((state) => [state.selectedRendition, state.setSelectedRendition]);
|
|
87
99
|
}
|
|
88
100
|
/**
|
|
89
101
|
* Hook to get the ingest state of the current player
|
|
90
102
|
*/
|
|
91
|
-
|
|
103
|
+
function useCurrentPlayerIngest() {
|
|
92
104
|
return useCurrentPlayerStore((state) => ({
|
|
93
105
|
starting: state.ingestStarting,
|
|
94
106
|
setStarting: state.setIngestStarting,
|
|
@@ -101,9 +113,9 @@ export function useCurrentPlayerIngest() {
|
|
|
101
113
|
/**
|
|
102
114
|
* HOC to wrap components with a SinglePlayerProvider
|
|
103
115
|
*/
|
|
104
|
-
|
|
116
|
+
function withSinglePlayer(Component) {
|
|
105
117
|
return function WithSinglePlayer(props) {
|
|
106
118
|
const { playerId, protocol, rendition, ...componentProps } = props;
|
|
107
|
-
return (
|
|
119
|
+
return ((0, jsx_runtime_1.jsx)(exports.SinglePlayerProvider, { playerId: playerId, protocol: protocol, rendition: rendition, children: (0, jsx_runtime_1.jsx)(Component, { ...componentProps }) }));
|
|
108
120
|
};
|
|
109
121
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamplaceContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.StreamplaceContext = (0, react_1.createContext)(null);
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamplaceProvider = StreamplaceProvider;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const streamplace_store_1 = require("../streamplace-store/streamplace-store");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const poller_1 = tslib_1.__importDefault(require("./poller"));
|
|
10
|
+
function StreamplaceProvider({ children, url, oauthSession, }) {
|
|
7
11
|
// todo: handle url changes?
|
|
8
|
-
const store = useRef(makeStreamplaceStore({ url })).current;
|
|
9
|
-
useEffect(() => {
|
|
12
|
+
const store = (0, react_1.useRef)((0, streamplace_store_1.makeStreamplaceStore)({ url })).current;
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
10
14
|
store.setState({ url });
|
|
11
15
|
}, [url]);
|
|
12
|
-
useEffect(() => {
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
13
17
|
store.setState({ oauthSession });
|
|
14
18
|
}, [oauthSession]);
|
|
15
|
-
return (
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(context_1.StreamplaceContext.Provider, { value: { store: store }, children: (0, jsx_runtime_1.jsx)(poller_1.default, { children: children }) }));
|
|
16
20
|
}
|