diff --git a/worker/TldrawDurableObject.ts b/worker/TldrawDurableObject.ts index 7d499a0..74073d6 100644 --- a/worker/TldrawDurableObject.ts +++ b/worker/TldrawDurableObject.ts @@ -3,14 +3,15 @@ import { AutoRouter, IRequest, error } from "itty-router" import throttle from "lodash.throttle" import { Environment } from "./types" -import { ChatBoxShape } from "@/shapes/ChatBoxShapeUtil" -import { VideoChatShape } from "@/shapes/VideoChatShapeUtil" -import { EmbedShape } from "@/shapes/EmbedShapeUtil" -import { MarkdownShape } from "@/shapes/MarkdownShapeUtil" -import { MycrozineTemplateShape } from "@/shapes/MycrozineTemplateShapeUtil" -import { SlideShape } from "@/shapes/SlideShapeUtil" -import { PromptShape } from "@/shapes/PromptShapeUtil" -import { SharedPianoShape } from "@/shapes/SharedPianoShapeUtil" +// Import worker-compatible shape utilities (without React components) +import { ChatBoxShape } from "./shapes/ChatBoxShapeUtil" +import { VideoChatShape } from "./shapes/VideoChatShapeUtil" +import { EmbedShape } from "./shapes/EmbedShapeUtil" +import { MarkdownShape } from "./shapes/MarkdownShapeUtil" +import { MycrozineTemplateShape } from "./shapes/MycrozineTemplateShapeUtil" +import { SlideShape } from "./shapes/SlideShapeUtil" +import { PromptShape } from "./shapes/PromptShapeUtil" +import { SharedPianoShape } from "./shapes/SharedPianoShapeUtil" // Lazy load TLDraw dependencies to avoid startup timeouts let customSchema: any = null diff --git a/worker/shapes/ChatBoxShapeUtil.ts b/worker/shapes/ChatBoxShapeUtil.ts new file mode 100644 index 0000000..179c3ec --- /dev/null +++ b/worker/shapes/ChatBoxShapeUtil.ts @@ -0,0 +1,32 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type IChatBoxShape = TLBaseShape< + "ChatBox", + { + w: number + h: number + roomId: string + userName: string + } +> + +export class ChatBoxShape extends BaseBoxShapeUtil { + static override type = "ChatBox" + + getDefaultProps(): IChatBoxShape["props"] { + return { + roomId: "default-room", + w: 100, + h: 100, + userName: "", + } + } + + indicator(_shape: IChatBoxShape) { + return null // Simplified for worker + } + + component(_shape: IChatBoxShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/EmbedShapeUtil.ts b/worker/shapes/EmbedShapeUtil.ts new file mode 100644 index 0000000..ea99569 --- /dev/null +++ b/worker/shapes/EmbedShapeUtil.ts @@ -0,0 +1,36 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type IEmbedShape = TLBaseShape< + "Embed", + { + w: number + h: number + url: string + title: string + description: string + image: string + } +> + +export class EmbedShape extends BaseBoxShapeUtil { + static override type = "Embed" + + getDefaultProps(): IEmbedShape["props"] { + return { + w: 300, + h: 200, + url: "", + title: "", + description: "", + image: "", + } + } + + indicator(shape: IEmbedShape) { + return null // Simplified for worker + } + + component(shape: IEmbedShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/MarkdownShapeUtil.ts b/worker/shapes/MarkdownShapeUtil.ts new file mode 100644 index 0000000..4130485 --- /dev/null +++ b/worker/shapes/MarkdownShapeUtil.ts @@ -0,0 +1,31 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" +// Worker-compatible version + +export type IMarkdownShape = TLBaseShape< + "Markdown", + { + w: number + h: number + text: string + } +> + +export class MarkdownShape extends BaseBoxShapeUtil { + static override type = "Markdown" + + getDefaultProps(): IMarkdownShape["props"] { + return { + w: 300, + h: 200, + text: "# Markdown\n\nYour content here...", + } + } + + indicator(_shape: IMarkdownShape) { + return null // Simplified for worker + } + + component(_shape: IMarkdownShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/MycrozineTemplateShapeUtil.ts b/worker/shapes/MycrozineTemplateShapeUtil.ts new file mode 100644 index 0000000..a745c17 --- /dev/null +++ b/worker/shapes/MycrozineTemplateShapeUtil.ts @@ -0,0 +1,30 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type IMycrozineTemplateShape = TLBaseShape< + "MycrozineTemplate", + { + w: number + h: number + templateType: string + } +> + +export class MycrozineTemplateShape extends BaseBoxShapeUtil { + static override type = "MycrozineTemplate" + + getDefaultProps(): IMycrozineTemplateShape["props"] { + return { + w: 400, + h: 300, + templateType: "default", + } + } + + indicator(_shape: IMycrozineTemplateShape) { + return null // Simplified for worker + } + + component(_shape: IMycrozineTemplateShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/PromptShapeUtil.ts b/worker/shapes/PromptShapeUtil.ts new file mode 100644 index 0000000..ba2fe9c --- /dev/null +++ b/worker/shapes/PromptShapeUtil.ts @@ -0,0 +1,32 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type IPromptShape = TLBaseShape< + "Prompt", + { + w: number + h: number + prompt: string + response: string + } +> + +export class PromptShape extends BaseBoxShapeUtil { + static override type = "Prompt" + + getDefaultProps(): IPromptShape["props"] { + return { + w: 300, + h: 200, + prompt: "", + response: "", + } + } + + indicator(_shape: IPromptShape) { + return null // Simplified for worker + } + + component(_shape: IPromptShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/SharedPianoShapeUtil.ts b/worker/shapes/SharedPianoShapeUtil.ts new file mode 100644 index 0000000..1f6ee2b --- /dev/null +++ b/worker/shapes/SharedPianoShapeUtil.ts @@ -0,0 +1,30 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type ISharedPianoShape = TLBaseShape< + "SharedPiano", + { + w: number + h: number + isPlaying: boolean + } +> + +export class SharedPianoShape extends BaseBoxShapeUtil { + static override type = "SharedPiano" + + getDefaultProps(): ISharedPianoShape["props"] { + return { + w: 400, + h: 200, + isPlaying: false, + } + } + + indicator(_shape: ISharedPianoShape) { + return null // Simplified for worker + } + + component(_shape: ISharedPianoShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/SlideShapeUtil.ts b/worker/shapes/SlideShapeUtil.ts new file mode 100644 index 0000000..4cf3823 --- /dev/null +++ b/worker/shapes/SlideShapeUtil.ts @@ -0,0 +1,32 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type ISlideShape = TLBaseShape< + "Slide", + { + w: number + h: number + title: string + content: string + } +> + +export class SlideShape extends BaseBoxShapeUtil { + static override type = "Slide" + + getDefaultProps(): ISlideShape["props"] { + return { + w: 400, + h: 300, + title: "Slide Title", + content: "Slide content...", + } + } + + indicator(_shape: ISlideShape) { + return null // Simplified for worker + } + + component(_shape: ISlideShape) { + return null // No React components in worker + } +} diff --git a/worker/shapes/VideoChatShapeUtil.ts b/worker/shapes/VideoChatShapeUtil.ts new file mode 100644 index 0000000..e1fa5db --- /dev/null +++ b/worker/shapes/VideoChatShapeUtil.ts @@ -0,0 +1,52 @@ +import { BaseBoxShapeUtil, TLBaseShape } from "tldraw" + +export type IVideoChatShape = TLBaseShape< + "VideoChat", + { + w: number + h: number + roomUrl: string | null + allowCamera: boolean + allowMicrophone: boolean + enableRecording: boolean + recordingId: string | null + enableTranscription: boolean + isTranscribing: boolean + transcriptionHistory: Array<{ + sender: string + message: string + id: string + }> + meetingToken: string | null + isOwner: boolean + } +> + +export class VideoChatShape extends BaseBoxShapeUtil { + static override type = "VideoChat" + + indicator(_shape: IVideoChatShape) { + return null + } + + getDefaultProps(): IVideoChatShape["props"] { + return { + roomUrl: null, + w: 800, + h: 600, + allowCamera: false, + allowMicrophone: false, + enableRecording: true, + recordingId: null, + enableTranscription: true, + isTranscribing: false, + transcriptionHistory: [], + meetingToken: null, + isOwner: false + } + } + + component(_shape: IVideoChatShape) { + return null // No React components in worker + } +} diff --git a/worker/worker.ts b/worker/worker.ts index 077e60a..396c65f 100644 --- a/worker/worker.ts +++ b/worker/worker.ts @@ -19,7 +19,7 @@ async function getUnfurlHandler() { // Define security headers const securityHeaders = { "Content-Security-Policy": - "default-src 'self'; connect-src 'self' wss: https:; img-src 'self' data: blob: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';", + "default-src 'self'; connect-src 'self' wss: https:; img-src 'self' data: blob: https: https://cdn.tldraw.com; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "DENY", "X-XSS-Protection": "1; mode=block",