update to fix vercel and cloudflare errors

This commit is contained in:
Jeff Emmett 2025-11-10 11:30:33 -08:00
parent 38d1f28e35
commit 119146e094
17 changed files with 66 additions and 34 deletions

View File

@ -130,6 +130,8 @@ The Fathom transcript shape includes:

View File

@ -81,6 +81,8 @@ You can also manually edit the environment by:

View File

@ -157,7 +157,7 @@ export class CloudflareNetworkAdapter extends NetworkAdapter {
private workerUrl: string
private websocket: WebSocket | null = null
private roomId: string | null = null
private peerId: PeerId | null = null
public peerId: PeerId | undefined = undefined
private readyPromise: Promise<void>
private readyResolve: (() => void) | null = null
private keepAliveInterval: NodeJS.Timeout | null = null
@ -225,22 +225,24 @@ export class CloudflareNetworkAdapter extends NetworkAdapter {
console.log('🔌 CloudflareAdapter: Received binary message (Automerge protocol)')
// Handle binary Automerge sync messages - convert ArrayBuffer to Uint8Array
// Automerge Repo expects binary sync messages as Uint8Array
this.emit('message', {
const message: Message = {
type: 'sync',
data: new Uint8Array(event.data),
senderId: this.peerId || 'unknown' as PeerId,
targetId: this.peerId || 'unknown' as PeerId
} as Message)
senderId: this.peerId || ('unknown' as PeerId),
targetId: this.peerId || ('unknown' as PeerId)
}
this.emit('message', message)
} else if (event.data instanceof Blob) {
// Handle Blob messages (convert to Uint8Array)
event.data.arrayBuffer().then((buffer) => {
console.log('🔌 CloudflareAdapter: Received Blob message, converted to Uint8Array')
this.emit('message', {
const message: Message = {
type: 'sync',
data: new Uint8Array(buffer),
senderId: this.peerId || 'unknown' as PeerId,
targetId: this.peerId || 'unknown' as PeerId
} as Message)
senderId: this.peerId || ('unknown' as PeerId),
targetId: this.peerId || ('unknown' as PeerId)
}
this.emit('message', message)
})
} else {
// Handle text messages (our custom protocol for backward compatibility)
@ -266,15 +268,15 @@ export class CloudflareNetworkAdapter extends NetworkAdapter {
storeKeys: message.data.store ? Object.keys(message.data.store).length : 0
})
// For backward compatibility, handle JSON sync data
this.emit('message', {
const syncMessage: Message = {
type: 'sync',
senderId: message.senderId,
targetId: message.targetId,
documentId: message.documentId,
senderId: message.senderId || this.peerId || ('unknown' as PeerId),
targetId: message.targetId || this.peerId || ('unknown' as PeerId),
data: message.data
})
} else {
this.emit('message', message)
}
this.emit('message', syncMessage)
} else if (message.senderId && message.targetId) {
this.emit('message', message as Message)
}
}
} catch (error) {

View File

@ -140,18 +140,8 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
// Get the store with status
const storeWithStatus = useMemo((): TLStoreWithStatus => {
if (!store) {
if (isLoading) {
return {
status: 'loading' as const,
connectionStatus: 'offline' as const,
store: undefined
}
} else {
return {
status: 'not-synced' as const,
connectionStatus: 'offline' as const,
store: undefined
}
status: 'loading' as const
}
}
@ -163,10 +153,25 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
}, [store, isLoading])
// Get presence data (only when handle is ready)
const userMetadata: { userId: string; name: string; color: string } = (() => {
if (user && 'userId' in user) {
return {
userId: (user as { userId: string; name: string; color?: string }).userId,
name: (user as { userId: string; name: string; color?: string }).name,
color: (user as { userId: string; name: string; color?: string }).color || '#000000'
}
}
return {
userId: user?.id || 'anonymous',
name: user?.name || 'Anonymous',
color: '#000000'
}
})()
const presence = useAutomergePresence({
handle: handle || null,
store: store || null,
userMetadata: user && 'userId' in user ? user : { userId: user?.id || 'anonymous', name: user?.name || 'Anonymous', color: '#000000' }
userMetadata
})
return {

View File

@ -258,6 +258,8 @@ export const LocationDashboard: React.FC = () => {

View File

@ -229,6 +229,8 @@ export const LocationMap: React.FC<LocationMapProps> = ({

View File

@ -171,6 +171,8 @@ export const LocationViewer: React.FC<LocationViewerProps> = ({ shareToken }) =>

View File

@ -138,6 +138,8 @@ export const ShareSettingsComponent: React.FC<ShareSettingsProps> = ({ onSetting

View File

@ -413,6 +413,8 @@

View File

@ -83,7 +83,7 @@ export const useWebSpeechTranscription = ({
const speakerChangeThreshold = 0.3 // Threshold for detecting speaker changes
// Function to add line breaks after pauses and improve punctuation
const processTranscript = useCallback((text: string, isFinal: boolean = false, _confidence?: number) => {
const processTranscript = useCallback((text: string, isFinal: boolean = false) => {
if (!text.trim()) return text
let processedText = text.trim()
@ -216,7 +216,7 @@ export const useWebSpeechTranscription = ({
speakerPrefix = '\n[Speaker Change]\n'
}
const processedFinal = processTranscript(finalTranscript, true, confidence)
const processedFinal = processTranscript(finalTranscript, true)
const newText = speakerPrefix + processedFinal
finalTranscriptRef.current += newText
setTranscript(finalTranscriptRef.current)

View File

@ -191,8 +191,9 @@ export class HoloSphereService {
}).catch((err) => {
console.error(`❌ Error in subscribe promise for ${lens}:`, err)
})
} else {
unsubscribe = (subscribeResult as any)?.unsubscribe || undefined
} else if (subscribeResult && typeof subscribeResult === 'object' && subscribeResult !== null) {
const result = subscribeResult as { unsubscribe?: () => void }
unsubscribe = result?.unsubscribe || undefined
console.log(`✅ Subscribe called successfully for ${lens}`)
}
} catch (subError) {

View File

@ -43,6 +43,8 @@ export interface GeolocationPosition {

View File

@ -25,6 +25,8 @@ export const LocationDashboardRoute: React.FC = () => {

View File

@ -25,6 +25,8 @@ export const LocationShareCreate: React.FC = () => {

View File

@ -39,6 +39,8 @@ export const LocationShareView: React.FC = () => {

View File

@ -37,7 +37,7 @@ export function resolveOverlaps(editor: Editor, shapeId: string): void {
]
const shape = editor.getShape(shapeId as TLShapeId)
if (!shape || !customShapeTypes.includes(shape.type)) return
if (!shape || !customShapeTypes.includes(shape.type as string)) return
const shapeBounds = getShapeBounds(editor, shape)
if (!shapeBounds) return

View File

@ -60,6 +60,8 @@ echo " npm run dev"