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 serializableTypes = new Set(['string', 'number', 'boolean', 'undefined']) | |
| /** | |
| * Get whether a value is serializable. | |
| * | |
| * @example | |
| * | |
| * ```ts | |
| * const A = isSerializable(1) // true |
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 { Node, mergeAttributes } from "@tiptap/core"; | |
| import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react"; | |
| import { Tldraw } from "@tldraw/tldraw"; // use @tldraw/tldraw@canary | |
| import "@tldraw/tldraw/tldraw.css"; | |
| function Component() { | |
| return ( | |
| <NodeViewWrapper className="react-component"> | |
| <div style={{ width: "100%", height: 500 }}> | |
| <Tldraw /> |
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 async function writeV1ContentsToIdb() { | |
| // openDB is a wrapper around indexedDB.open that adds a version migration hook, but we've had to drop it as a dependency. Here it is quicky re-implemented: | |
| function openDB(name: string, version: number) { | |
| const request = indexedDB.open(name, version) | |
| return new Promise<IDBDatabase>((resolve, reject) => { | |
| request.onerror = () => reject(request.error) | |
| request.onsuccess = () => resolve(request.result) | |
| request.onupgradeneeded = () => { | |
| const db = request.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
| { | |
| "action.convert-to-bookmark": "Convert to Bookmark", | |
| "action.convert-to-embed": "Convert to Embed", | |
| "action.open-embed-link": "Open link", | |
| "action.align-bottom": "Align bottom", | |
| "action.align-center-horizontal": "Align horizontally", | |
| "action.align-center-vertical": "Align vertically", | |
| "action.align-center-horizontal.short": "Align H", | |
| "action.align-center-vertical.short": "Align V", | |
| "action.align-left": "Align left", |
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 EmbedDefinition = { | |
| type: string | |
| title: string | |
| hostnames: string[] | |
| minWidth?: number | |
| minHeight?: number | |
| width: number | |
| height: number | |
| doesResize: boolean | |
| isAspectRatioLocked?: boolean |
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
| Lux Capital (lead) | |
| Amplify Partners | |
| Sabrina Hahn | |
| Guillermo Rauch, founder Vercel | |
| Liu Jiang | |
| NP-Hard Ventures | |
| Badrul Farooqi | |
| Soleio Cuervo | |
| Tom Preston-Werner, co-founder Github | |
| Adam Wiggins, founder Ink and Switch, Muse |
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
| // segments are all of the segments in all of the shapes in the scene | |
| // point is light point | |
| // viewport is top left, top right, bottom right, bottom left | |
| function getVisibilityPolygon(segments: Segment[], point: Point, viewport: Point[]) { | |
| const brokenSegments: Segment[] = [] | |
| const viewportMinCorner = viewport[0] | |
| const viewportMaxCorner = viewport[2] |
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
| animateCamera = ( | |
| x: number, | |
| y: number, | |
| z: number, | |
| opts = {} as { duration: number; ease: (t: number) => number } | |
| ) => { | |
| const { duration = 1000 } = opts | |
| const { center } = this.viewport | |
| const currCenter = new Vec2d(center.x, center.y, this.camera.z) | |
| const nextCenter = new Vec2d(x, y, z) |
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 intersectSets<T>(sets: Set<T>[]) { | |
| if (sets.length === 0) return new Set<T>() | |
| const first = sets[0] | |
| const rest = sets.slice(1) | |
| const result = new Set<T>() | |
| for (const val of first) { | |
| if (rest.every((set) => set.has(val))) { | |
| result.add(val) | |
| } |
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 class Cache<T extends object, K> { | |
| items = new WeakMap<T, K>() | |
| get<P extends T>(item: P, cb: (item: P) => K) { | |
| if (!this.items.has(item)) { | |
| this.items.set(item, cb(item)) | |
| } | |
| return this.items.get(item)! | |
| } |