From 453a19076882b86933c1a83acba55616f6d7751c Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Tue, 11 Nov 2025 22:38:24 -0800 Subject: [PATCH] update cloudflare errors --- src/automerge/useAutomergeStoreV2.ts | 1 + src/components/FathomMeetingsPanel.tsx | 2 ++ src/components/StandardizedToolWrapper.tsx | 23 ++++++++++++++++-- src/hooks/usePinnedToView.ts | 24 +++++++++---------- src/lib/blockchain/index.ts | 6 ++--- src/routes/Board.tsx | 28 +++++++++++++++++++--- src/shapes/ChatBoxShapeUtil.tsx | 2 ++ src/shapes/FathomNoteShapeUtil.tsx | 1 + src/shapes/VideoChatShapeUtil.tsx | 4 ++-- src/tools/ObsNoteTool.ts | 1 + src/ui/components.tsx | 18 ++++++++++++-- worker/worker.ts | 4 ++-- 12 files changed, 87 insertions(+), 27 deletions(-) diff --git a/src/automerge/useAutomergeStoreV2.ts b/src/automerge/useAutomergeStoreV2.ts index 6d12d82..77d578d 100644 --- a/src/automerge/useAutomergeStoreV2.ts +++ b/src/automerge/useAutomergeStoreV2.ts @@ -3,6 +3,7 @@ import { TLStoreWithStatus, createTLStore, TLStoreSnapshot, + RecordsDiff, } from "@tldraw/tldraw" import { createTLSchema, defaultBindingSchemas, defaultShapeSchemas } from "@tldraw/tlschema" import { useEffect, useState } from "react" diff --git a/src/components/FathomMeetingsPanel.tsx b/src/components/FathomMeetingsPanel.tsx index d53de1e..804a73a 100644 --- a/src/components/FathomMeetingsPanel.tsx +++ b/src/components/FathomMeetingsPanel.tsx @@ -33,6 +33,8 @@ interface FathomMeeting { email: string team?: string } + call_id?: string | number + id?: string | number } interface FathomMeetingsPanelProps { diff --git a/src/components/StandardizedToolWrapper.tsx b/src/components/StandardizedToolWrapper.tsx index c6ac974..362be05 100644 --- a/src/components/StandardizedToolWrapper.tsx +++ b/src/components/StandardizedToolWrapper.tsx @@ -69,8 +69,27 @@ export const StandardizedToolWrapper: React.FC = ( useEffect(() => { if (editor && shapeId && isSelected) { try { - // Use sendToFront to bring the shape to the top of the z-order - editor.sendToFront([shapeId]) + // Bring the shape to the front by updating its index + // Note: sendToFront doesn't exist in this version of tldraw + const allShapes = editor.getCurrentPageShapes() + let highestIndex = 'a0' + for (const s of allShapes) { + if (s.index && typeof s.index === 'string' && s.index > highestIndex) { + highestIndex = s.index + } + } + const shape = editor.getShape(shapeId) + if (shape) { + const match = highestIndex.match(/^([a-z])(\d+)$/) + if (match) { + const letter = match[1] + const num = parseInt(match[2], 10) + const newIndex = num < 100 ? `${letter}${num + 1}` : `${String.fromCharCode(letter.charCodeAt(0) + 1)}1` + if (/^[a-z]\d+$/.test(newIndex)) { + editor.updateShape({ id: shapeId, type: shape.type, index: newIndex as any }) + } + } + } } catch (error) { // Silently fail if shape doesn't exist or operation fails // This prevents console spam if shape is deleted during selection diff --git a/src/hooks/usePinnedToView.ts b/src/hooks/usePinnedToView.ts index dd6f519..22b223f 100644 --- a/src/hooks/usePinnedToView.ts +++ b/src/hooks/usePinnedToView.ts @@ -1,5 +1,5 @@ import { useEffect, useRef } from 'react' -import { Editor } from 'tldraw' +import { Editor, TLShapeId } from 'tldraw' /** * Hook to manage shapes pinned to the viewport. @@ -23,7 +23,7 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin return } - const shape = editor.getShape(shapeId) + const shape = editor.getShape(shapeId as TLShapeId) if (!shape) return // If just became pinned (transition from false to true), capture the current screen position @@ -63,12 +63,10 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin } } - // Bring the shape to the front using editor's sendToFront method - // This is safer than manually setting index values + // Bring the shape to the front by manually setting index + // Note: sendToFront doesn't exist in this version of tldraw, so we use manual index setting try { - editor.sendToFront([shapeId]) - } catch (frontError) { - // Fallback: try to set a safe index value + // Try to set a safe index value // Use conservative values that are known to work (a1, a2, b1, etc.) let newIndex: string = 'a2' // Safe default @@ -100,7 +98,7 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin // Validate before using if (/^[a-z]\d+$/.test(newIndex)) { editor.updateShape({ - id: shapeId, + id: shapeId as TLShapeId, type: shape.type, index: newIndex as any, }) @@ -121,7 +119,7 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin // Animate back to original coordinates and size with a calm drift if (originalCoordinatesRef.current && originalSizeRef.current && originalZoomRef.current !== null) { - const currentShape = editor.getShape(shapeId) + const currentShape = editor.getShape(shapeId as TLShapeId) if (currentShape) { const startX = currentShape.x const startY = currentShape.y @@ -173,7 +171,7 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin try { editor.updateShape({ - id: shapeId, + id: shapeId as TLShapeId, type: currentShape.type, x: currentX, y: currentY, @@ -266,7 +264,7 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin return } - const currentShape = editor.getShape(shapeId) + const currentShape = editor.getShape(shapeId as TLShapeId) if (!currentShape) { animationFrameRef.current = requestAnimationFrame(updatePinnedPosition) return @@ -381,11 +379,11 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin // Only respond to changes that affect this specific shape const changedShapes = event?.changedShapes || event?.shapes || [] - const shapeChanged = changedShapes.some((s: any) => s?.id === shapeId) + const shapeChanged = changedShapes.some((s: any) => s?.id === (shapeId as TLShapeId)) if (!shapeChanged) return - const currentShape = editor.getShape(shapeId) + const currentShape = editor.getShape(shapeId as TLShapeId) if (!currentShape) return // Update the pinned screen position to the shape's current screen position diff --git a/src/lib/blockchain/index.ts b/src/lib/blockchain/index.ts index df9f7ec..961f5a6 100644 --- a/src/lib/blockchain/index.ts +++ b/src/lib/blockchain/index.ts @@ -1,5 +1,5 @@ // Blockchain integration exports - -export * from './ethereum'; -export * from './walletIntegration'; +// Note: These modules may not exist yet - commented out to prevent build errors +// export * from './ethereum'; +// export * from './walletIntegration'; diff --git a/src/routes/Board.tsx b/src/routes/Board.tsx index 55aaebd..f0fea4b 100644 --- a/src/routes/Board.tsx +++ b/src/routes/Board.tsx @@ -235,8 +235,30 @@ export function Board() { if (selectionChanged && selectedShapeIds.length > 0) { try { - // Bring all selected shapes to the front - editor.sendToFront(selectedShapeIds) + // Bring all selected shapes to the front by updating their index + // Note: sendToFront doesn't exist in this version of tldraw + const allShapes = editor.getCurrentPageShapes() + let highestIndex = 'a0' + for (const s of allShapes) { + if (s.index && typeof s.index === 'string' && s.index > highestIndex) { + highestIndex = s.index + } + } + // Update each selected shape's index + for (const id of selectedShapeIds) { + const shape = editor.getShape(id) + if (shape) { + const match = highestIndex.match(/^([a-z])(\d+)$/) + if (match) { + const letter = match[1] + const num = parseInt(match[2], 10) + const newIndex = num < 100 ? `${letter}${num + 1}` : `${String.fromCharCode(letter.charCodeAt(0) + 1)}1` + if (/^[a-z]\d+$/.test(newIndex)) { + editor.updateShape({ id, type: shape.type, index: newIndex as any }) + } + } + } + } lastSelectedIds = [...selectedShapeIds] } catch (error) { // Silently fail if shapes don't exist or operation fails @@ -253,7 +275,7 @@ export function Board() { return () => { if (typeof unsubscribe === 'function') { - unsubscribe() + ;(unsubscribe as () => void)() } } }, [editor]) diff --git a/src/shapes/ChatBoxShapeUtil.tsx b/src/shapes/ChatBoxShapeUtil.tsx index 09ccbae..ae87638 100644 --- a/src/shapes/ChatBoxShapeUtil.tsx +++ b/src/shapes/ChatBoxShapeUtil.tsx @@ -95,6 +95,8 @@ export class ChatBoxShape extends BaseBoxShapeUtil { w={shape.props.w} h={shape.props.h - 40} // Subtract header height userName="" + pinnedToView={shape.props.pinnedToView} + tags={shape.props.tags} /> diff --git a/src/shapes/FathomNoteShapeUtil.tsx b/src/shapes/FathomNoteShapeUtil.tsx index 17e8bca..d4a22b3 100644 --- a/src/shapes/FathomNoteShapeUtil.tsx +++ b/src/shapes/FathomNoteShapeUtil.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react' import { BaseBoxShapeUtil, TLBaseShape, createShapeId, IndexKey, TLParentId, HTMLContainer } from '@tldraw/tldraw' +import type { JSX } from 'react' import { StandardizedToolWrapper } from '../components/StandardizedToolWrapper' import { usePinnedToView } from '../hooks/usePinnedToView' diff --git a/src/shapes/VideoChatShapeUtil.tsx b/src/shapes/VideoChatShapeUtil.tsx index 6c2e8b9..a7345d7 100644 --- a/src/shapes/VideoChatShapeUtil.tsx +++ b/src/shapes/VideoChatShapeUtil.tsx @@ -210,7 +210,7 @@ export class VideoChatShape extends BaseBoxShapeUtil { let isNewRoom: boolean = false; if (!response.ok) { - const error = await response.json() + const error = await response.json() as any console.error('🔧 Daily.co API error:', error); // Check if the room already exists @@ -228,7 +228,7 @@ export class VideoChatShape extends BaseBoxShapeUtil { }); if (getRoomResponse.ok) { - const roomData = await getRoomResponse.json(); + const roomData = await getRoomResponse.json() as any; url = roomData.url; console.log('🔧 Retrieved existing room URL:', url); } else { diff --git a/src/tools/ObsNoteTool.ts b/src/tools/ObsNoteTool.ts index 6c41a46..197e550 100644 --- a/src/tools/ObsNoteTool.ts +++ b/src/tools/ObsNoteTool.ts @@ -1,5 +1,6 @@ import { StateNode } from "tldraw" import { ObsNoteShape } from "@/shapes/ObsNoteShapeUtil" +import { findNonOverlappingPosition } from "@/utils/shapeCollisionUtils" export class ObsNoteTool extends StateNode { static override id = "obs_note" diff --git a/src/ui/components.tsx b/src/ui/components.tsx index 765c9f9..04c9cf1 100644 --- a/src/ui/components.tsx +++ b/src/ui/components.tsx @@ -53,12 +53,26 @@ export const components: TLComponents = { {/* Custom Tools */} {customTools.map(tool => ( - + ))} {/* Custom Actions */} {customActions.map(action => ( - + ))} {/* Default content (includes standard TLDraw shortcuts) */} diff --git a/worker/worker.ts b/worker/worker.ts index b15f74b..86bf6bd 100644 --- a/worker/worker.ts +++ b/worker/worker.ts @@ -550,7 +550,7 @@ const router = AutoRouter({ // Support both Authorization: Bearer and X-Api-Key headers for backward compatibility let apiKey = req.headers.get('X-Api-Key') if (!apiKey) { - apiKey = req.headers.get('Authorization')?.split('Bearer ')[1] + apiKey = req.headers.get('Authorization')?.split('Bearer ')[1] || null } console.log('API key present:', !!apiKey) @@ -648,7 +648,7 @@ const router = AutoRouter({ // Support both Authorization: Bearer and X-Api-Key headers let apiKey = req.headers.get('X-Api-Key') if (!apiKey) { - apiKey = req.headers.get('Authorization')?.split('Bearer ')[1] + apiKey = req.headers.get('Authorization')?.split('Bearer ')[1] || null } const { meetingId } = req.params