From 3df4b5530b7f30b45ed9743bfe8562c5eb7dd37e Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 10 Nov 2025 11:30:33 -0800 Subject: [PATCH] update to fix vercel and cloudflare errors --- FATHOM_INTEGRATION.md | 2 ++ WORKER_ENV_GUIDE.md | 2 ++ src/automerge/CloudflareAdapter.ts | 34 ++++++++++--------- src/automerge/useAutomergeSyncRepo.ts | 31 ++++++++++------- src/components/location/LocationDashboard.tsx | 2 ++ src/components/location/LocationMap.tsx | 2 ++ src/components/location/LocationViewer.tsx | 2 ++ src/components/location/ShareSettings.tsx | 2 ++ src/css/location.css | 2 ++ src/hooks/useWebSpeechTranscription.ts | 4 +-- src/lib/HoloSphereService.ts | 5 +-- src/lib/location/types.ts | 2 ++ src/routes/LocationDashboardRoute.tsx | 2 ++ src/routes/LocationShareCreate.tsx | 2 ++ src/routes/LocationShareView.tsx | 2 ++ src/utils/shapeCollisionUtils.ts | 2 +- switch-worker-env.sh | 2 ++ 17 files changed, 66 insertions(+), 34 deletions(-) diff --git a/FATHOM_INTEGRATION.md b/FATHOM_INTEGRATION.md index 0f64180..ecb162a 100644 --- a/FATHOM_INTEGRATION.md +++ b/FATHOM_INTEGRATION.md @@ -130,6 +130,8 @@ The Fathom transcript shape includes: + + diff --git a/WORKER_ENV_GUIDE.md b/WORKER_ENV_GUIDE.md index a260567..9a80005 100644 --- a/WORKER_ENV_GUIDE.md +++ b/WORKER_ENV_GUIDE.md @@ -81,6 +81,8 @@ You can also manually edit the environment by: + + diff --git a/src/automerge/CloudflareAdapter.ts b/src/automerge/CloudflareAdapter.ts index 1ae4fd8..c50a5bd 100644 --- a/src/automerge/CloudflareAdapter.ts +++ b/src/automerge/CloudflareAdapter.ts @@ -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 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) { diff --git a/src/automerge/useAutomergeSyncRepo.ts b/src/automerge/useAutomergeSyncRepo.ts index 803ad30..2625928 100644 --- a/src/automerge/useAutomergeSyncRepo.ts +++ b/src/automerge/useAutomergeSyncRepo.ts @@ -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 - } + return { + 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 { diff --git a/src/components/location/LocationDashboard.tsx b/src/components/location/LocationDashboard.tsx index 36e986f..dbdf973 100644 --- a/src/components/location/LocationDashboard.tsx +++ b/src/components/location/LocationDashboard.tsx @@ -258,6 +258,8 @@ export const LocationDashboard: React.FC = () => { + + diff --git a/src/components/location/LocationMap.tsx b/src/components/location/LocationMap.tsx index 85f0d54..8ee8a8e 100644 --- a/src/components/location/LocationMap.tsx +++ b/src/components/location/LocationMap.tsx @@ -229,6 +229,8 @@ export const LocationMap: React.FC = ({ + + diff --git a/src/components/location/LocationViewer.tsx b/src/components/location/LocationViewer.tsx index 0e1df4a..1d4c08b 100644 --- a/src/components/location/LocationViewer.tsx +++ b/src/components/location/LocationViewer.tsx @@ -171,6 +171,8 @@ export const LocationViewer: React.FC = ({ shareToken }) => + + diff --git a/src/components/location/ShareSettings.tsx b/src/components/location/ShareSettings.tsx index 4a65cd3..3e46393 100644 --- a/src/components/location/ShareSettings.tsx +++ b/src/components/location/ShareSettings.tsx @@ -138,6 +138,8 @@ export const ShareSettingsComponent: React.FC = ({ onSetting + + diff --git a/src/css/location.css b/src/css/location.css index 42b8d16..9eb28a2 100644 --- a/src/css/location.css +++ b/src/css/location.css @@ -413,6 +413,8 @@ + + diff --git a/src/hooks/useWebSpeechTranscription.ts b/src/hooks/useWebSpeechTranscription.ts index 0762f7b..b11ee30 100644 --- a/src/hooks/useWebSpeechTranscription.ts +++ b/src/hooks/useWebSpeechTranscription.ts @@ -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) diff --git a/src/lib/HoloSphereService.ts b/src/lib/HoloSphereService.ts index afa2218..dbf38a7 100644 --- a/src/lib/HoloSphereService.ts +++ b/src/lib/HoloSphereService.ts @@ -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) { diff --git a/src/lib/location/types.ts b/src/lib/location/types.ts index 8e48547..0e1c795 100644 --- a/src/lib/location/types.ts +++ b/src/lib/location/types.ts @@ -43,6 +43,8 @@ export interface GeolocationPosition { + + diff --git a/src/routes/LocationDashboardRoute.tsx b/src/routes/LocationDashboardRoute.tsx index b3a0fd6..94bea2c 100644 --- a/src/routes/LocationDashboardRoute.tsx +++ b/src/routes/LocationDashboardRoute.tsx @@ -25,6 +25,8 @@ export const LocationDashboardRoute: React.FC = () => { + + diff --git a/src/routes/LocationShareCreate.tsx b/src/routes/LocationShareCreate.tsx index ca1100e..6a11664 100644 --- a/src/routes/LocationShareCreate.tsx +++ b/src/routes/LocationShareCreate.tsx @@ -25,6 +25,8 @@ export const LocationShareCreate: React.FC = () => { + + diff --git a/src/routes/LocationShareView.tsx b/src/routes/LocationShareView.tsx index 1548f1e..77ce651 100644 --- a/src/routes/LocationShareView.tsx +++ b/src/routes/LocationShareView.tsx @@ -39,6 +39,8 @@ export const LocationShareView: React.FC = () => { + + diff --git a/src/utils/shapeCollisionUtils.ts b/src/utils/shapeCollisionUtils.ts index 4962603..e42a880 100644 --- a/src/utils/shapeCollisionUtils.ts +++ b/src/utils/shapeCollisionUtils.ts @@ -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 diff --git a/switch-worker-env.sh b/switch-worker-env.sh index 93af8e6..8483732 100644 --- a/switch-worker-env.sh +++ b/switch-worker-env.sh @@ -60,6 +60,8 @@ echo " npm run dev" + +