This file contains 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
/** | |
* Lock all scrollbars by disabling mousewheel and locking scrollbars in position | |
* Optionally provide an element to allow it to scroll when hovered | |
*/ | |
const listenerOptions = supportsPassiveEvents | |
? { capture: true, passive: false } | |
: true | |
let lockedScrolls = [] | |
function lockScroll(node) { |
This file contains 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
/** Get the closest element that scrolls */ | |
function getClosestOverflowElement(node: HTMLElement, includeHidden?: boolean) { | |
if (node) { | |
const { overflow, overflowX, overflowY } = getComputedStyle(node) | |
const canScroll = ( | |
includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/ | |
).test(overflow + overflowX + overflowY) | |
if (node === document.body || canScroll) { | |
return node | |
} else { |
This file contains 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 fs from 'node:fs/promises' | |
import path from 'node:path' | |
/** Fetches the types for a locally installed NPM package. */ | |
export async function getTypeDeclarations(packageName) { | |
const [parentPackage, submodule] = packageName.split('/') | |
const parentPackagePath = path.resolve( | |
process.cwd(), | |
'node_modules', | |
parentPackage, |
This file contains 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 * as React from 'react' | |
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api' | |
import ts from 'typescript' | |
import { setupTypeAcquisition } from '@typescript/ata' | |
import { signal } from '@preact/signals-core' | |
/** Type definitions for the current project. */ | |
export const types = signal<{ code: string; path: string }[]>([]) | |
const ata = setupTypeAcquisition({ |
This file contains 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 { execSync } from 'node:child_process'; | |
import parseGitDiff from 'parse-git-diff'; | |
import { Node, Project, SyntaxKind } from 'ts-morph'; | |
/** | |
* We're going to build a NextJS utility that compares two git branches and | |
* outputs a list of pages that have changed. We'll use TS-Morph to trace | |
* the references of the pages that are not obvious by the file name and directory | |
* structure that NextJS uses to render pages. | |
*/ |
This file contains 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
#!/usr/bin/env node | |
import { | |
ReferencedSymbol, | |
Project, | |
ts, | |
Node, | |
SourceFile, | |
ImportDeclaration, | |
ImportClause, | |
JsxElement, |
This file contains 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 { App } from '@tinyhttp/app' | |
import cors from 'cors' | |
import * as fs from 'fs/promises' | |
import * as prettier from 'prettier' | |
import * as codemod from '@codemod/core' | |
const app = new App() | |
const plugin = () => { | |
return { |
This file contains 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 React, { useState } from 'react'; | |
import { Box, Text } from 'ink'; | |
import TextInput from 'ink-text-input'; | |
import Spinner from 'ink-spinner'; | |
import Table from 'ink-table'; | |
import type { ExportedDeclarations, ImportDeclaration } from 'ts-morph'; | |
import { Project, SourceFile, ts } from 'ts-morph'; | |
import { resolve } from 'node:path'; | |
import { promises } from 'node:fs'; |
This file contains 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 usePointer({ | |
onStart, | |
onMove, | |
onEnd, | |
}: { | |
onStart: () => void | |
onMove: () => void | |
onEnd: () => void | |
}) { | |
const pressed = useSignal(false) |
This file contains 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 * as React from "react" | |
import { useSnapshot } from "valtio" | |
import { TreeStateContext, TreeMapContext, createInitialTreeState } from "./contexts" | |
import { useServerComputedData } from "./server" | |
import { useIndex, useIndexedChildren } from "./use-indexed-children" | |
import { isServer, useIsomorphicLayoutEffect } from "./utils" | |
export function useTreeSnapshot<ComputedData extends any>( | |
computeData?: (treeMap: Map<string, any>) => ComputedData, |