See https://codesandbox.io/s/mobx-undo-redo-v2-ofty1 for example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const TAU = Math.PI / 2 | |
| const PI2 = Math.PI * 2 | |
| interface VecLike {x: number, y: number } | |
| /** | |
| * Get info about an arc formed by three points. | |
| * | |
| * @param a The start of the arc | |
| * @param b A point on the arc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NextApiRequest, NextApiResponse } from 'next' | |
| import chromium from 'chrome-aws-lambda' | |
| import Cors from 'cors' | |
| import { TDExport, TDExportTypes, TldrawApp } from '@tldraw/tldraw' | |
| // NOTE: You might have to downgrade puppeteer etc in order to fit under the endpoint size limit of 50mb. | |
| const cors = Cors({ | |
| methods: ['POST'], | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Find the control points for a quadratic segment from point a to point c passing through point b. | |
| * @param a The segments's first point | |
| * @param b The point to curve through | |
| * @param c The segment's end point | |
| */ | |
| export function getQuadraticControlPoints( | |
| a: { x: number; y: number }, | |
| b: { x: number; y: number }, | |
| c: { x: number; y: number } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Find the control points for a cubic segment from point a to point c passing through point b. | |
| * @param a The curve's start point | |
| * @param b The point to curve through | |
| * @param c The curve's end point | |
| */ | |
| export function findCubicControlPoints( | |
| a: { x: number; y: number }, | |
| b: { x: number; y: number }, | |
| c: { x: number; y: number } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var DBOpenRequest = window.indexedDB.open("keyval-store", 1); | |
| DBOpenRequest.onsuccess = function(event) { | |
| db = DBOpenRequest.result; | |
| var transaction = db.transaction(["keyval"], "readwrite"); | |
| var objectStore = transaction.objectStore("keyval"); | |
| var objectStoreRequest = objectStore.get("home"); | |
| objectStoreRequest.onsuccess = function(event) { | |
| console.log(JSON.stringify(objectStoreRequest.result)) | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Player { | |
| /** | |
| * @param {Warrior} warrior | |
| */ | |
| playTurn(warrior) { | |
| warrior.walk() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pages/api/auth/[...nextauth.ts] | |
| // Follow docs in nextauth | |
| import { isSignedInUserSponsoringMe } from 'utils/github' | |
| import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next' | |
| import NextAuth from 'next-auth' | |
| import GithubProvider from 'next-auth/providers/github' | |
| export default function Auth( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Model<T> = { | |
| [E in keyof T]: unknown; | |
| } | |
| export type DefaultModel = { | |
| [k: string]: unknown; | |
| }; | |
| class View<E extends Model<E> = Model<unknown>> { | |
| model: E; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable */ | |
| const fs = require('fs') | |
| const path = require('path') | |
| const esbuild = require('esbuild') | |
| const { gzip } = require('zlib') | |
| const { log } = console | |
| const cwd = process.cwd() | |
| const pkg = require(path.join(cwd, 'package.json')) |