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
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')) |
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 { DOUBLE_CLICK } from '~constants' | |
import { TLTestApp } from './TLTestApp' | |
jest.useFakeTimers() | |
describe('When detecting double/triple/quadruple clicks...', () => { | |
it('Detects a click', () => { | |
const app = new TLTestApp() | |
app.onClick = jest.fn() | |
app.onDoubleClick = jest.fn() |
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 { GeomUtils, TLCursor } from '@tldraw/core' | |
import * as React from 'react' | |
function getCursorCss(svg: string, r: number, f = false) { | |
return ( | |
`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 35 35' xmlns='http://www.w3.org/2000/svg'><g fill='none' style='transform-origin:center center' transform='rotate(${r})${ | |
f ? ` scale(-1,-1) translate(0, -32)` : '' | |
}'>` + | |
svg.replaceAll(`"`, `'`) + | |
'</g></svg>") 16 16, pointer' |
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
export function intersectLineLine(AB: number[][], PQ: number[][]): number[] | undefined { | |
const slopeAB = AB[0][0] === AB[1][0] ? NaN : (AB[0][1] - AB[1][1]) / (AB[0][0] - AB[1][0]) | |
const slopePQ = AB[0][0] === PQ[1][0] ? NaN : (PQ[0][1] - PQ[1][1]) / (PQ[0][0] - PQ[1][0]) | |
if (slopeAB === slopePQ) return undefined | |
if (Number.isNaN(slopeAB) && !Number.isNaN(slopePQ)) { | |
return [AB[0][0], (AB[0][0] - PQ[0][0]) * slopePQ + PQ[0][1]] | |
} |
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/sponsors.ts | |
import { NextApiRequest, NextApiResponse } from 'next' | |
const AV_SIZE = 32 | |
const PADDING = 4 | |
const COLS = 16 | |
type SponsorResult = { avatarUrl: string; login: string } |
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/pusher/pusher-auth.ts | |
import { pusher } from "backend/pusher" | |
import { NextApiHandler, NextApiRequest } from "next" | |
interface PushAuthRequest extends NextApiRequest { | |
body: { | |
socket_id: string | |
channel_name: string | |
} |