diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index a96ff102a..000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Check for type errors", - "type": "typescript", - "tsconfig": "tsconfig.json", - "option": "watch", - "problemMatcher": ["$tsc-watch"], - "group": "build" - } - ] -} diff --git a/apps/www/components/Editor.tsx b/apps/www/components/Editor.tsx index cd6ec81e3..c54887113 100644 --- a/apps/www/components/Editor.tsx +++ b/apps/www/components/Editor.tsx @@ -1,7 +1,7 @@ -import { Tldraw, TldrawApp, useFileSystem } from '@tldraw/tldraw' -import * as gtag from '-utils/gtag' import React from 'react' -import { useAccountHandlers } from '-hooks/useAccountHandlers' +import * as gtag from 'utils/gtag' +import { Tldraw, TldrawApp, useFileSystem } from '@tldraw/tldraw' +import { useAccountHandlers } from 'hooks/useAccountHandlers' declare const window: Window & { app: TldrawApp } @@ -19,9 +19,9 @@ export default function Editor({ id = 'home', isUser = false, isSponsor = false // Send events to gtag as actions. const handlePersist = React.useCallback((_app: TldrawApp, reason?: string) => { gtag.event({ - action: reason, + action: reason ?? '', category: 'editor', - label: reason || 'persist', + label: reason ?? 'persist', value: 0, }) }, []) diff --git a/apps/www/components/MultiplayerEditor.tsx b/apps/www/components/MultiplayerEditor.tsx index c59f73d8f..bce6d387b 100644 --- a/apps/www/components/MultiplayerEditor.tsx +++ b/apps/www/components/MultiplayerEditor.tsx @@ -3,9 +3,9 @@ import * as React from 'react' import { Tldraw, TldrawApp, useFileSystem } from '@tldraw/tldraw' import { createClient } from '@liveblocks/client' import { LiveblocksProvider, RoomProvider } from '@liveblocks/react' -import { useAccountHandlers } from '-hooks/useAccountHandlers' -import { styled } from '-styles' -import { useMultiplayerState } from '-hooks/useMultiplayerState' +import { useAccountHandlers } from 'hooks/useAccountHandlers' +import { styled } from 'styles' +import { useMultiplayerState } from 'hooks/useMultiplayerState' const client = createClient({ publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_API_KEY || '', diff --git a/apps/www/hooks/useMultiplayerState.ts b/apps/www/hooks/useMultiplayerState.ts index 6e0849e9e..bb97ebbc9 100644 --- a/apps/www/hooks/useMultiplayerState.ts +++ b/apps/www/hooks/useMultiplayerState.ts @@ -129,10 +129,17 @@ export function useMultiplayerState(roomId: string) { page: { shapes, bindings }, }, }, - } = doc.toObject() + } = doc.toObject() as { document: TDDocument } - Object.values(shapes).forEach((shape) => lShapes.set(shape.id, shape)) - Object.values(bindings).forEach((binding) => lBindings.set(binding.id, binding)) + for (const key in shapes) { + const shape = shapes[key] + lShapes.set(shape.id, shape) + } + + for (const key in bindings) { + const binding = bindings[key] + lBindings.set(binding.id, binding) + } } } @@ -175,21 +182,23 @@ export function useMultiplayerState(roomId: string) { if (!(lShapes && lBindings)) return - Object.entries(shapes).forEach(([id, shape]) => { + for (const id in shapes) { + const shape = shapes[id] if (!shape) { lShapes.delete(id) } else { lShapes.set(shape.id, shape) } - }) + } - Object.entries(bindings).forEach(([id, binding]) => { + for (const id in bindings) { + const binding = bindings[id] if (!binding) { lBindings.delete(id) } else { lBindings.set(binding.id, binding) } - }) + } rExpectingUpdate.current = true }) diff --git a/apps/www/package.json b/apps/www/package.json index 1aade9c66..e62c5b7ad 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -25,6 +25,7 @@ "@sentry/react": "^6.13.2", "@sentry/tracing": "^6.13.2", "@stitches/react": "^1.2.5", + "@tldraw/core": "^1.1.4", "@tldraw/tldraw": "^1.1.4", "@types/next-auth": "^3.15.0", "next": "^12.0.1", @@ -42,7 +43,7 @@ "cors": "^2.8.5", "eslint": "7.32.0", "eslint-config-next": "11.1.2", - "typescript": "^4.4.2" + "typescript": "^4.5.2" }, "gitHead": "838fabdbff1a66d4d7ee8aa5c5d117bc55acbff2" } diff --git a/apps/www/pages/_app.tsx b/apps/www/pages/_app.tsx index 1ba10f5a8..a84700ac6 100644 --- a/apps/www/pages/_app.tsx +++ b/apps/www/pages/_app.tsx @@ -1,7 +1,9 @@ import '../styles/globals.css' -import { init } from '-utils/sentry' import Head from 'next/head' -import useGtag from '-utils/useGtag' +import useGtag from 'utils/useGtag' +import { init } from 'utils/sentry' +import type { AppProps } from 'next/app' +import type React from 'react' init() @@ -10,7 +12,7 @@ const APP_DESCRIPTION = 'A tiny little drawing app.' const APP_URL = 'https://tldraw.com' const IMAGE = 'https://tldraw.com/social-image.png' -function MyApp({ Component, pageProps }) { +function MyApp({ Component, pageProps }: AppProps) { useGtag() return ( diff --git a/apps/www/pages/_document.tsx b/apps/www/pages/_document.tsx index f1b73b987..dbfaba7d8 100644 --- a/apps/www/pages/_document.tsx +++ b/apps/www/pages/_document.tsx @@ -1,29 +1,19 @@ import NextDocument, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' -import { getCssText } from '../styles' -import { GA_TRACKING_ID } from '../utils/gtag' +import { getCssText } from 'styles' +import { GA_TRACKING_ID } from 'utils/gtag' class MyDocument extends NextDocument { - static async getInitialProps(ctx: DocumentContext): Promise<{ - styles: JSX.Element - html: string - head?: JSX.Element[] - }> { - try { - const initialProps = await NextDocument.getInitialProps(ctx) + static async getInitialProps(ctx: DocumentContext) { + const initialProps = await NextDocument.getInitialProps(ctx) - return { - ...initialProps, - styles: ( - <> - {initialProps.styles} -