@openpeepshq/core 0.19.0 → 0.26.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/dist/jams/index.d.ts +1 -0
- package/dist/jams/index.js +1 -0
- package/dist/jams/spotlight.d.ts +12 -0
- package/dist/jams/spotlight.js +52 -0
- package/package.json +3 -3
package/dist/jams/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { createJamToken, createJamEgressToken } from './token';
|
|
|
3
3
|
export { diagnoseLivekit, isLivekitConnected } from './health';
|
|
4
4
|
export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
|
|
5
5
|
export { rtmpStreamOutput } from './rtmp';
|
|
6
|
+
export { setJamSpotlight } from './spotlight';
|
|
6
7
|
export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs';
|
|
7
8
|
export * from './waitingRoom';
|
|
8
9
|
export * from './mutations';
|
package/dist/jams/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { createJamToken, createJamEgressToken } from './token.js';
|
|
|
16
16
|
export { diagnoseLivekit, isLivekitConnected } from './health.js';
|
|
17
17
|
export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit.js';
|
|
18
18
|
export { rtmpStreamOutput } from './rtmp.js';
|
|
19
|
+
export { setJamSpotlight } from './spotlight.js';
|
|
19
20
|
export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs.js';
|
|
20
21
|
export * from './waitingRoom.js';
|
|
21
22
|
export * from './mutations.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PostWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets or clears the room-wide spotlight in LiveKit room metadata.
|
|
4
|
+
*
|
|
5
|
+
* Recording/RTMP web egress joins the room after the spotlight was set, so a
|
|
6
|
+
* one-shot data packet never reaches it. Room metadata is replayed to every
|
|
7
|
+
* (re)joining participant, so the egress's observer view sees the spotlight on
|
|
8
|
+
* load and follows live changes via `RoomMetadataChanged`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const setJamSpotlight: (jamEvent: PostWithMeta, identity: string | null, recurrenceId?: string) => Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jamRoomName } from '@openpeepshq/common/lib';
|
|
2
|
+
import { logger } from '../log/index.js';
|
|
3
|
+
import { roomService } from './livekit.js';
|
|
4
|
+
const log = logger('app:jams:spotlight');
|
|
5
|
+
const isRoomMetadata = (value) => {
|
|
6
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const record = value;
|
|
10
|
+
return (('instanceDomain' in record
|
|
11
|
+
? typeof record.instanceDomain === 'string'
|
|
12
|
+
: true) &&
|
|
13
|
+
('spotlightIdentity' in record
|
|
14
|
+
? typeof record.spotlightIdentity === 'string' ||
|
|
15
|
+
record.spotlightIdentity === null
|
|
16
|
+
: true));
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Sets or clears the room-wide spotlight in LiveKit room metadata.
|
|
20
|
+
*
|
|
21
|
+
* Recording/RTMP web egress joins the room after the spotlight was set, so a
|
|
22
|
+
* one-shot data packet never reaches it. Room metadata is replayed to every
|
|
23
|
+
* (re)joining participant, so the egress's observer view sees the spotlight on
|
|
24
|
+
* load and follows live changes via `RoomMetadataChanged`.
|
|
25
|
+
*/
|
|
26
|
+
export const setJamSpotlight = async (jamEvent, identity, recurrenceId) => {
|
|
27
|
+
const roomName = jamRoomName(jamEvent.id, recurrenceId);
|
|
28
|
+
const rs = await roomService();
|
|
29
|
+
if (rs === undefined) {
|
|
30
|
+
log.warn(`Cannot set spotlight for jam ${jamEvent.id}: LiveKit is not configured`);
|
|
31
|
+
return { success: false };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const rooms = await rs.listRooms([roomName]);
|
|
35
|
+
const room = rooms[0];
|
|
36
|
+
if (!room) {
|
|
37
|
+
log.warn(`Cannot set spotlight for jam ${jamEvent.id}: room ${roomName} is not open`);
|
|
38
|
+
return { success: false };
|
|
39
|
+
}
|
|
40
|
+
const parsed = room.metadata ? JSON.parse(room.metadata) : {};
|
|
41
|
+
if (!isRoomMetadata(parsed)) {
|
|
42
|
+
log.warn(`Cannot set spotlight for jam ${jamEvent.id}: room ${roomName} has malformed metadata`);
|
|
43
|
+
return { success: false };
|
|
44
|
+
}
|
|
45
|
+
await rs.updateRoomMetadata(roomName, JSON.stringify({ ...parsed, spotlightIdentity: identity }));
|
|
46
|
+
return { success: true };
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
log.warn(`Failed to set spotlight for jam ${jamEvent.id}: ${e.message}`);
|
|
50
|
+
return { success: false };
|
|
51
|
+
}
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"dependencies": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"type-fest": "^4.31.0",
|
|
38
38
|
"uuidv7": "^1.0.2",
|
|
39
39
|
"web-push": "^3.6.7",
|
|
40
|
-
"@openpeepshq/common": "0.
|
|
41
|
-
"@openpeepshq/geocoder": "^0.1.2",
|
|
40
|
+
"@openpeepshq/common": "0.28.0",
|
|
42
41
|
"@openpeepshq/fetch-client": "^0.3.0",
|
|
42
|
+
"@openpeepshq/geocoder": "^0.1.2",
|
|
43
43
|
"@openpeepshq/i18n": "^0.29.0"
|
|
44
44
|
},
|
|
45
45
|
"main": "dist/index.js",
|