chore(deps): upgrade to Trystero@0.18.0

This commit is contained in:
Jeremy Kahn 2024-03-14 21:35:51 -05:00
parent 5d4619965c
commit d81e930da6
7 changed files with 3055 additions and 874 deletions

3891
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@
"sdp": "^3.2.0",
"secure-file-transfer": "^0.0.7",
"streamsaver": "^2.0.6",
"trystero": "^0.15.0",
"trystero": "^0.18.0",
"typeface-public-sans": "^1.1.13",
"typeface-roboto": "^1.1.13",
"typescript": "^5.4.2",

View File

@ -60,10 +60,10 @@ export function Room({
} = useRoom(
{
appId,
trackerUrls,
relayUrls: trackerUrls,
rtcConfig,
password,
trackerRedundancy: 4,
relayRedundancy: 4,
},
{
roomId,

View File

@ -1,6 +1,6 @@
import { useContext, useEffect, useMemo, useState } from 'react'
import { BaseRoomConfig } from 'trystero'
import { TorrentRoomConfig } from 'trystero/torrent'
import { RelayConfig } from 'trystero/torrent'
import { v4 as uuid } from 'uuid'
import { useDebounce } from '@react-hook/debounce'
@ -45,14 +45,14 @@ interface UseRoomConfig {
timeService?: typeof time
}
interface UserMetadata {
interface UserMetadata extends Record<string, any> {
userId: string
customUsername: string
publicKeyString: string
}
export function useRoom(
{ password, ...roomConfig }: BaseRoomConfig & TorrentRoomConfig,
{ password, ...roomConfig }: BaseRoomConfig & RelayConfig,
{
roomId,
userId,

View File

@ -1,4 +1,4 @@
import { getTrackers } from 'trystero/torrent'
import { getRelaySockets } from 'trystero/torrent'
import { rtcConfig } from 'config/rtcConfig'
import { parseCandidate } from 'sdp'
@ -104,17 +104,15 @@ export class ConnectionTest extends EventTarget {
}
testTrackerConnection() {
const trackers = getTrackers()
const relaySockets = Object.values(getRelaySockets())
const trackerSockets = Object.values(trackers)
if (trackerSockets.length === 0) {
if (relaySockets.length === 0) {
// Trystero has not yet initialized tracker sockets
this.trackerConnection = TrackerConnection.SEARCHING
return this.trackerConnection
}
const readyStates = trackerSockets.map(({ readyState }) => readyState)
const readyStates = relaySockets.map(({ readyState }) => readyState)
const haveAllTrackerConnectionsFailed = readyStates.every(
readyState => readyState === WebSocket.CLOSED

View File

@ -1,5 +1,5 @@
import { joinRoom, Room, BaseRoomConfig } from 'trystero'
import { TorrentRoomConfig } from 'trystero/torrent'
import { joinRoom, Room, BaseRoomConfig, DataPayload } from 'trystero'
import { RelayConfig } from 'trystero/torrent'
import { sleep } from 'lib/sleep'
@ -27,7 +27,7 @@ const streamQueueAddDelay = 1000
export class PeerRoom {
private room: Room
private roomConfig: TorrentRoomConfig & BaseRoomConfig
private roomConfig: RelayConfig & BaseRoomConfig
private peerJoinHandlers: Map<
PeerHookType,
@ -60,7 +60,7 @@ export class PeerRoom {
this.isProcessingPendingStreams = false
}
constructor(config: TorrentRoomConfig & BaseRoomConfig, roomId: string) {
constructor(config: RelayConfig & BaseRoomConfig, roomId: string) {
this.roomConfig = config
this.room = joinRoom(this.roomConfig, roomId)
@ -167,7 +167,7 @@ export class PeerRoom {
return peerConnections
}
makeAction = <T>(namespace: string) => {
makeAction = <T extends DataPayload>(namespace: string) => {
return this.room.makeAction<T>(namespace)
}

View File

@ -1,4 +1,4 @@
export interface UnsentMessage {
export interface UnsentMessage extends Record<string, any> {
id: string
text: string
timeSent: number
@ -73,11 +73,11 @@ export const isInlineMedia = (
return 'magnetURI' in message
}
export interface FileOfferMetadata {
export interface FileOfferMetadata extends Record<string, any> {
magnetURI: string
isAllInlineMedia: boolean
}
export interface TypingStatus {
export interface TypingStatus extends Record<string, any> {
isTyping: boolean
}