@openpeepshq/react 0.6.2 → 0.6.3

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.
@@ -40,7 +40,7 @@ export declare const toOidc: (form: ProviderFormState) => {
40
40
  tokenUrl: string;
41
41
  userinfoUrl: string;
42
42
  clientId: string;
43
- kind?: "oidc" | "gitlab" | "gitlab-selfhosted" | "github" | "google" | "entra" | "discord" | "auth0" | "okta" | "keycloak" | "authentik" | "pocketid" | undefined;
43
+ kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
44
44
  instanceUrl?: string | undefined;
45
45
  tenant?: string | undefined;
46
46
  emailsUrl?: string | undefined;
@@ -186,7 +186,7 @@ export declare const useSsoConfig: () => {
186
186
  tokenUrl: string;
187
187
  userinfoUrl: string;
188
188
  clientId: string;
189
- kind?: "oidc" | "gitlab" | "gitlab-selfhosted" | "github" | "google" | "entra" | "discord" | "auth0" | "okta" | "keycloak" | "authentik" | "pocketid" | undefined;
189
+ kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
190
190
  instanceUrl?: string | undefined;
191
191
  tenant?: string | undefined;
192
192
  emailsUrl?: string | undefined;
@@ -269,7 +269,7 @@ export declare const useSsoConfig: () => {
269
269
  tokenUrl: string;
270
270
  userinfoUrl: string;
271
271
  clientId: string;
272
- kind?: "oidc" | "gitlab" | "gitlab-selfhosted" | "github" | "google" | "entra" | "discord" | "auth0" | "okta" | "keycloak" | "authentik" | "pocketid" | undefined;
272
+ kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
273
273
  instanceUrl?: string | undefined;
274
274
  tenant?: string | undefined;
275
275
  emailsUrl?: string | undefined;
@@ -52,7 +52,7 @@ export type { JamEventsContextValue } from './components/jams/JamEventsContext';
52
52
  export { mentionProfilesFromParticipants, parseJamEventPayload, parseParticipantMetadata, sendAttendance, sendJamEvent, sendReaction, toggleHand, } from './components/jams/jamEventActions';
53
53
  export type { JamParticipantMetadata } from './components/jams/jamEventActions';
54
54
  export { useRaisedHands } from './components/jams/useJamHands';
55
- export { calculateRecordingState, calculateRtmpStreamState, useJamRecordingState, useJamRtmpStreamState, } from './components/jams/jamRecordingState';
55
+ export { calculateRecordingState, calculateRtmpStreamState, formatRecordingElapsed, useJamRecordingElapsed, useJamRecordingState, useJamRtmpStreamState, } from './components/jams/jamRecordingState';
56
56
  export { shouldReconnectAfterDisconnect } from './components/jams/disconnectReason';
57
57
  export { JAM_EMOJIS, defaultRoomOptions, emojis, } from './components/jams/constants';
58
58
  export * from './lib/reactionEmojis';
@@ -40,7 +40,7 @@ export { JamProvider, useJamContext, useJamObserver, } from './components/jams/J
40
40
  export { JamEventsProvider, useJamEventsContext, useMaybeJamEventsContext, } from './components/jams/JamEventsContext.js';
41
41
  export { mentionProfilesFromParticipants, parseJamEventPayload, parseParticipantMetadata, sendAttendance, sendJamEvent, sendReaction, toggleHand, } from './components/jams/jamEventActions.js';
42
42
  export { useRaisedHands } from './components/jams/useJamHands.js';
43
- export { calculateRecordingState, calculateRtmpStreamState, useJamRecordingState, useJamRtmpStreamState, } from './components/jams/jamRecordingState.js';
43
+ export { calculateRecordingState, calculateRtmpStreamState, formatRecordingElapsed, useJamRecordingElapsed, useJamRecordingState, useJamRtmpStreamState, } from './components/jams/jamRecordingState.js';
44
44
  export { shouldReconnectAfterDisconnect } from './components/jams/disconnectReason.js';
45
45
  export { JAM_EMOJIS, defaultRoomOptions, emojis, } from './components/jams/constants.js';
46
46
  export * from './lib/reactionEmojis.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "react-i18next": "^15.4.1",
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
- "@openpeepshq/common": "^0.3.2",
55
54
  "@openpeepshq/client": "^0.2.1",
56
55
  "@openpeepshq/greenscreen": "^0.2.1",
56
+ "@openpeepshq/common": "^0.3.2",
57
57
  "@openpeepshq/react-ui": "^0.4.1"
58
58
  },
59
59
  "peerDependencies": {
@@ -85,22 +85,18 @@ const useFooterControls = () => {
85
85
  const RecordButton = ({
86
86
  isRecording,
87
87
  busy,
88
+ label,
88
89
  onToggle,
89
- t,
90
90
  }: {
91
91
  isRecording: boolean;
92
92
  busy: boolean;
93
+ label: string;
93
94
  onToggle: () => void;
94
- t: ReturnType<typeof useT>;
95
95
  }) => (
96
96
  <JamToolbarButton
97
97
  tone="danger"
98
98
  disabled={busy}
99
- title={
100
- isRecording
101
- ? t('jams.recording.stopTitle')
102
- : t('events.recordingInProgress')
103
- }
99
+ title={label}
104
100
  action={onToggle}
105
101
  >
106
102
  {isRecording ? <SquareStop /> : <Disc />}
@@ -224,6 +220,7 @@ const MobileMenu = ({
224
220
  isModerator,
225
221
  recordingEnabled,
226
222
  isRecording,
223
+ recordingLabel,
227
224
  busy,
228
225
  onClose,
229
226
  onOpenChat,
@@ -236,6 +233,7 @@ const MobileMenu = ({
236
233
  isModerator: boolean;
237
234
  recordingEnabled: boolean;
238
235
  isRecording: boolean;
236
+ recordingLabel: string;
239
237
  busy: boolean;
240
238
  onClose: () => void;
241
239
  onOpenChat: () => void;
@@ -302,11 +300,7 @@ const MobileMenu = ({
302
300
  }}
303
301
  >
304
302
  {isRecording ? <CircleStop /> : <Disc />}
305
- <span>
306
- {isRecording
307
- ? t('jams.recording.stopTitle')
308
- : t('events.recordingInProgress')}
309
- </span>
303
+ <span>{recordingLabel}</span>
310
304
  </button>
311
305
  ) : null}
312
306
  </div>
@@ -333,6 +327,7 @@ export const JamFooter = ({
333
327
  t,
334
328
  isModerator,
335
329
  isRecording,
330
+ recordingLabel,
336
331
  recordingEnabled,
337
332
  handRaised,
338
333
  busy,
@@ -377,8 +372,8 @@ export const JamFooter = ({
377
372
  <RecordButton
378
373
  isRecording={isRecording}
379
374
  busy={busy}
375
+ label={recordingLabel}
380
376
  onToggle={() => void toggleRecording()}
381
- t={t}
382
377
  />
383
378
  ) : null}
384
379
 
@@ -444,6 +439,7 @@ export const JamFooter = ({
444
439
  isModerator={isModerator}
445
440
  recordingEnabled={recordingEnabled}
446
441
  isRecording={isRecording}
442
+ recordingLabel={recordingLabel}
447
443
  busy={busy}
448
444
  onClose={() => setMobileMenuOpen(false)}
449
445
  onOpenChat={onToggleChat}
@@ -6,7 +6,10 @@ import {
6
6
  import { ConnectionQuality } from 'livekit-client';
7
7
  import { Circle, X } from 'lucide-react';
8
8
  import { useT } from '../../i18n';
9
- import { useJamRecordingState } from './jamRecordingState';
9
+ import {
10
+ useJamRecordingElapsed,
11
+ useJamRecordingState,
12
+ } from './jamRecordingState';
10
13
 
11
14
  /**
12
15
  * Red "recording" pill shown to every participant while egress is active,
@@ -15,6 +18,7 @@ import { useJamRecordingState } from './jamRecordingState';
15
18
  export function JamRecordingIndicator() {
16
19
  const t = useT();
17
20
  const { isRecording } = useJamRecordingState();
21
+ const elapsed = useJamRecordingElapsed();
18
22
 
19
23
  if (!isRecording) return null;
20
24
 
@@ -22,6 +26,7 @@ export function JamRecordingIndicator() {
22
26
  <div className="bg-error/90 text-error-foreground pointer-events-none fixed left-4 top-4 z-50 flex items-center gap-2 rounded-full px-3 py-1 text-sm font-medium shadow-lg">
23
27
  <Circle className="size-3 animate-pulse fill-current" />
24
28
  {t('events.recordingInProgress', { defaultValue: 'Recording' })}
29
+ {elapsed ? <span className="tabular-nums">{elapsed}</span> : null}
25
30
  </div>
26
31
  );
27
32
  }
@@ -1,4 +1,4 @@
1
- import { useMemo } from 'react';
1
+ import { useEffect, useMemo, useState } from 'react';
2
2
  import type { JamEvent } from '@openpeepshq/common/types';
3
3
  import { getUniqueBy } from '@openpeepshq/common';
4
4
  import { useOpenpeeps } from '../../contexts/openpeeps';
@@ -70,3 +70,37 @@ export const useJamRtmpStreamState = () => {
70
70
  [eventsQuery.data, sessionEvents],
71
71
  );
72
72
  };
73
+
74
+ const pad2 = (value: number) => String(value).padStart(2, '0');
75
+
76
+ /** Elapsed milliseconds as m:ss, or h:mm:ss past one hour (recording pill). */
77
+ export const formatRecordingElapsed = (ms: number) => {
78
+ const totalSeconds = Math.max(0, Math.floor(ms / 1000));
79
+ const hours = Math.floor(totalSeconds / 3600);
80
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
81
+ const seconds = totalSeconds % 60;
82
+ return hours > 0
83
+ ? `${hours}:${pad2(minutes)}:${pad2(seconds)}`
84
+ : `${pad2(minutes)}:${pad2(seconds)}`;
85
+ };
86
+
87
+ /**
88
+ * Elapsed time of the active recording, ticked once per second. Returns
89
+ * `undefined` while nothing is recording (no timer while idle).
90
+ */
91
+ export const useJamRecordingElapsed = () => {
92
+ const { isRecording, recordingStart } = useJamRecordingState();
93
+ const [now, setNow] = useState(() => Date.now());
94
+
95
+ useEffect(() => {
96
+ if (!isRecording) return;
97
+ setNow(Date.now());
98
+ const id = setInterval(() => setNow(Date.now()), 1000);
99
+ return () => clearInterval(id);
100
+ }, [isRecording, recordingStart]);
101
+
102
+ return useMemo(() => {
103
+ if (!isRecording || !recordingStart) return undefined;
104
+ return formatRecordingElapsed(now - new Date(recordingStart).getTime());
105
+ }, [isRecording, recordingStart, now]);
106
+ };
@@ -9,6 +9,9 @@ import { useJamEventsContext } from '../../components/jams/JamEventsContext';
9
9
  import { useJamRecordingState } from '../../components/jams/jamRecordingState';
10
10
  import { toggleHand } from '../../components/jams/jamEventActions';
11
11
  import { useRaisedHands } from '../../components/jams/useJamHands';
12
+ import { logger } from '../../log';
13
+
14
+ const log = logger('jams:recording');
12
15
 
13
16
  export type UseJamFooterControlsArgs = {
14
17
  room: Room;
@@ -65,13 +68,15 @@ export const useJamFooterControls = ({
65
68
  undefined,
66
69
  occurrence ? { occurrence } : undefined,
67
70
  );
68
- onSuccess(t('jams.recording.stopped', { id: recording.id }));
71
+ log.info('recording stopped', recording.id);
72
+ onSuccess(t('jams.recording.stopped'));
69
73
  } else {
70
74
  const recording = await startRecording(
71
75
  undefined,
72
76
  occurrence ? { occurrence } : undefined,
73
77
  );
74
- onSuccess(t('jams.recording.started', { id: recording.id }));
78
+ log.info('recording started', recording.id);
79
+ onSuccess(t('jams.recording.started'));
75
80
  }
76
81
  } catch {
77
82
  onError(
@@ -84,9 +89,16 @@ export const useJamFooterControls = ({
84
89
  }
85
90
  };
86
91
 
92
+ const recordingLabel = busy
93
+ ? t(isRecording ? 'jams.recording.stopping' : 'jams.recording.starting')
94
+ : t(
95
+ isRecording ? 'jams.recording.stopTitle' : 'jams.recording.recordTitle',
96
+ );
97
+
87
98
  return {
88
99
  isModerator,
89
100
  isRecording,
101
+ recordingLabel,
90
102
  recordingEnabled,
91
103
  handRaised,
92
104
  busy,
@@ -141,6 +141,8 @@ export { useRaisedHands } from './components/jams/useJamHands';
141
141
  export {
142
142
  calculateRecordingState,
143
143
  calculateRtmpStreamState,
144
+ formatRecordingElapsed,
145
+ useJamRecordingElapsed,
144
146
  useJamRecordingState,
145
147
  useJamRtmpStreamState,
146
148
  } from './components/jams/jamRecordingState';