### Docusaurus Site Setup Commands
Source: https://docs.tscircuit.com/ai.txt
These commands are essential for setting up and running the Docusaurus-based documentation website locally. `bun i` installs all project dependencies, and `bun run start` launches a local development server, allowing real-time preview of changes.
```bash
bun i
bun run start
```
--------------------------------
### Standard Project Setup and Execution with Bun
Source: https://blog.tscircuit.com/i/149495167/help-us-build-the-largest-library-of-schematic-symbols
This snippet demonstrates the common workflow for setting up, testing, and running tscircuit projects. It leverages the Bun runtime for dependency installation, test execution, and application startup, a pattern consistently used across most tscircuit repositories.
```Shell
bun install
bun test
bun start
```
--------------------------------
### tscircuit CLI Commands Reference
Source: https://docs.tscircuit.com/ai.txt
Comprehensive guide to the tscircuit command-line interface, including installation, project initialization, development server management, and project publishing to the registry.
```APIDOC
npm install -g @tscircuit/cli
- Installs the tscircuit CLI globally.
- Parameters:
- -g: Installs the package globally, making the `tsci` command available system-wide.
- Usage: Required once to set up the CLI.
tsci init
- Initializes a new tscircuit project in the current directory.
- Creates necessary project files and directories.
- Usage: Run in an empty directory to start a new tscircuit project.
tsci dev
- Starts the tscircuit development server.
- Automatically rebuilds and previews circuits in real-time as code changes.
- Access: Typically available at `https://localhost:3020`.
- Usage: Run within a tscircuit project directory to begin development.
tsci push
- Pushes the current tscircuit project to the tscircuit registry.
- Makes the project accessible and viewable in your online tscircuit account.
- Usage: Run within a tscircuit project directory to publish your design.
```
--------------------------------
### tscircuit Library Development Commands
Source: https://github.com/tscircuit/tscircuit-autorouter
This snippet provides the essential shell commands for setting up and working on the tscircuit library. It covers installing project dependencies using 'bun install', launching the interactive development environment with 'bun run start', executing tests via 'bun test', and building the final library using 'bun run build'.
```Shell
# Install dependencies
bun install
# Start the interactive development environment
bun run start
# Run tests
bun test
# Build the library
bun run build
```
--------------------------------
### Docusaurus Local Development Setup
Source: https://context7_llms
Commands to set up and run a local development server for a Docusaurus-based website, including installing dependencies and starting the server.
```shell
bun i
```
```shell
bun run start
```
--------------------------------
### Install dsn-converter Library
Source: https://github.com/tscircuit/dsn-converter
These commands demonstrate how to install the `dsn-converter` library using either the Bun package manager or npm. Choose the command appropriate for your project's package management setup.
```Shell
bun add dsn-converter
```
```Shell
npm install dsn-converter
```
--------------------------------
### Install @tscircuit/capacity-autorouter
Source: https://github.com/tscircuit/tscircuit-autorouter
Instructions for installing the @tscircuit/capacity-autorouter library using the Bun package manager.
```Shell
bun add @tscircuit/capacity-autorouter
```
--------------------------------
### Bun.js Testing with bun:test
Source: https://bun.sh/
Illustrates basic testing in Bun.js using the built-in `bun:test` module. It includes a `beforeAll` hook for setup, a `describe` block for grouping tests, `test` cases, `expect` assertions, and a snapshot test example.
```TypeScript
import { describe, expect, test, beforeAll } from "bun:test";
beforeAll(() => {
// setup tests
});
describe("math", () => {
test("addition", () => {
expect(2 + 2).toBe(4);
expect(7 + 13).toMatchSnapshot();
});
});
```
--------------------------------
### Install tscircuit API SDK
Source: https://context7_llms
Instructions for installing the `@tscircuit/api` package, which provides a convenient client for interacting with the Datasheet API.
```bash
npm install @tscircuit/api
```
--------------------------------
### Install Bun using PowerShell
Source: https://bun.sh/
This command uses PowerShell to download and execute the Bun installation script from bun.sh. It's a common method for installing Bun on Windows systems, leveraging `Invoke-RestMethod` (irm) to fetch the script and `Invoke-Expression` (iex) to run it.
```powershell
powershell -c "irm bun.sh/install.ps1 | iex"
```
--------------------------------
### Install Bun Runtime
Source: https://bun.sh/
Instructions for installing the Bun JavaScript runtime on Unix-like systems using curl and on Windows using PowerShell. These commands download and execute the official Bun installation script.
```Shell
curl -fsSL https://bun.sh/install | bash
```
```PowerShell
powershell -c "irm bun.sh/install.ps1 | iex"
```
--------------------------------
### Install tscircuit CLI Globally
Source: https://docs.tscircuit.com/ai.txt
These commands demonstrate how to globally install the tscircuit command-line interface (CLI) using either npm or Bun. Installing the CLI provides access to the `tsci` command, which is essential for creating, developing, and exporting tscircuit projects.
```bash
npm install -g @tscircuit/cli
```
```bash
bun install -g @tscircuit/cli
```
--------------------------------
### Install tscircuit API SDK
Source: https://docs.tscircuit.com/ai.txt
This command installs the `@tscircuit/api` package, which provides a convenient client for interacting with the tscircuit Datasheet API, using npm.
```bash
npm install @tscircuit/api
```
--------------------------------
### Install circuit-json-to-pnp-csv library
Source: https://github.com/tscircuit/circuit-json-to-pnp-csv
Commands to install the 'circuit-json-to-pnp-csv' library, which converts Circuit JSON into a Pick'n'Place CSV, using either the npm or bun package managers.
```Shell
npm install circuit-json-to-pnp-csv
```
```Shell
bun add circuit-json-to-pnp-csv
```
--------------------------------
### Install circuit-json-to-pnp-csv with Bun
Source: https://github.com/tscircuit/circuit-json-to-pnp-csv
Installs the `circuit-json-to-pnp-csv` library using the Bun package manager. This provides an alternative, potentially faster, method for adding the library to your project's dependencies.
```Shell
bun add circuit-json-to-pnp-csv
```
--------------------------------
### Install circuit-json-to-gerber CLI Globally
Source: https://github.com/tscircuit/circuit-json-to-gerber
Instructions for installing the `circuit-json-to-gerber` package globally using npm, enabling its command-line interface (CLI) usage.
```Shell
npm install -g circuit-json-to-gerber
```
--------------------------------
### Initial Setup for Local Package Development
Source: https://github.com/tscircuit/handbook/blob/main/guides/using-yalc
This script details the initial steps to set up a local package for development. It involves navigating to the package directory, building it with `bun`, publishing it locally with `yalc --watch` for continuous updates, and then linking it to your project.
```Shell
# In your package directory
cd my-package
bun run build # Build the initial version
yalc publish --watch # Start watching for changes
# In your project directory
cd ../my-project
yalc add my-package # Link to local version
```
--------------------------------
### Start Development Server with Bun
Source: https://github.com/tscircuit/led-matrix-server
This command initiates the development server for the web application using Bun. Once started, the web interface will be accessible locally, typically for development and testing purposes.
```Bun
bun run start
```
--------------------------------
### Install Bun on Linux and macOS using curl
Source: https://bun.sh/
This Bash command provides a convenient way to install Bun, a fast JavaScript runtime, on Linux and macOS systems. It uses 'curl' to download the installation script and pipes it directly to 'bash' for execution. This method ensures a quick and straightforward setup of Bun on compatible environments.
```Bash
curl -fsSL https://bun.sh/install | bash
```
--------------------------------
### Run LED Matrix Server with Bun
Source: https://github.com/tscircuit/led-matrix-server
This command starts the LED matrix server using Bun, a fast JavaScript runtime. The web interface will then be accessible via a local URL.
```Shell
bun run start
```
--------------------------------
### Create and Initialize a New tscircuit Project
Source: https://docs.tscircuit.com/ai.txt
This sequence of bash commands guides the user through creating a new directory for their project, navigating into it, and then initializing a new tscircuit project. The `tsci init` command bootstraps the project with a basic structure, including the main circuit definition file (`index.tsx`) and necessary configuration files.
```bash
mkdir my-keyboard
cd my-keyboard
tsci init
```
--------------------------------
### Using tscircuit Breakout Element for Guided Routing
Source: https://docs.tscircuit.com/ai.txt
This example illustrates the usage of the `breakout` component in tscircuit. It acts as a container for components, guiding the autorouter on where connections should exit the group. It includes nested components like `resistor`, `capacitor`, `trace`, and `breakoutpoint`.
```tsx
export default () => (
)
```
--------------------------------
### Install Project Dependencies with Bun
Source: https://github.com/tscircuit/led-matrix-server
This command uses the Bun package manager to install all required dependencies for the project. It's a crucial step to set up the development environment before running the web application.
```Bun
bun install
```
--------------------------------
### tscircuit CLI Usage Examples
Source: https://github.com/tscircuit/cli
Demonstrates how to use the tscircuit command-line interface for common tasks. This includes starting a local development server that watches for file changes and cloning packages from the tscircuit registry.
```bash
# Start a local server that watches for changes in
# this file or it's dependencies and updates the
# browser preview
tsci dev ./path/to/file.tsx
```
```bash
# Clone a package from the registry
tsci clone author/packageName
```
--------------------------------
### Initialize New tscircuit Project
Source: https://docs.tscircuit.com/ai.txt
Steps to create a new directory and initialize a fresh tscircuit project within it using the `tsci init` command. This bootstraps the necessary project structure, preparing it for development.
```bash
mkdir my-project
cd my-project
tsci init
```
--------------------------------
### Bun Project Management Commands
Source: https://blog.tscircuit.com/i/149495167/help-us-build-the-largest-library-of-schematic-symbols
Common Bun commands used for managing JavaScript/TypeScript projects. These commands facilitate dependency installation, test execution, and starting the main project script, streamlining the development workflow.
```Shell
bun install
bun test
bun start
```
--------------------------------
### Manage Local Package Development with Yalc and Bun
Source: https://github.com/tscircuit/handbook/blob/main/guides/using-yalc
This snippet outlines a complete workflow for developing and testing local packages using `yalc` and `bun`. It covers initial setup, publishing a package to a local registry, adding it to a dependent project, updating during development, and cleaning up before committing to restore original dependencies.
```shell
# Initial setup
bun install -g yalc # Install yalc globally
# In your package directory (e.g. @tscircuit/builder):
bun run build # Build TypeScript first!
yalc publish # Publish to local registry
# In dependent project (e.g. @tscircuit/editor):
yalc add @tscircuit/builder # Use local version
# Development cycle:
bun run build # After changes, rebuild
yalc push # Update all dependent projects
# Before committing:
yalc remove --all # Remove local links
bun install # Restore npm versions
```
--------------------------------
### Development Commands for tscircuit-autorouter
Source: https://github.com/tscircuit/unravel-autorouter
This snippet provides the essential shell commands required to set up and manage the tscircuit-autorouter library during development. It covers installing project dependencies, starting the interactive development environment, executing tests, and building the final library.
```Shell
# Install dependencies
bun install
# Start the interactive development environment
bun run start
# Run tests
bun test
# Build the library
bun run build
```
--------------------------------
### Install project dependencies using Bun
Source: https://github.com/tscircuit/led-matrix-server
This shell command uses the Bun package manager to install all required dependencies for the project. Bun is a fast JavaScript runtime and package manager.
```Shell
bun install
```
--------------------------------
### Define Silkscreen Line in tscircuit
Source: https://docs.tscircuit.com/ai.txt
Shows how to draw a straight line on the silkscreen layer using the `` element in tscircuit. This example specifies the start and end coordinates (x1, y1, x2, y2) and the stroke width of the line.
```javascript
export default () => (
)
```
--------------------------------
### tscircuit Trace Element Properties
Source: https://docs.tscircuit.com/ai.txt
This section details the available properties for the `` element in tscircuit, including their descriptions and examples. These properties allow for defining the start and end points of a trace, as well as optional length and width constraints.
```APIDOC
Properties:
from: string
Description: Starting point of the trace using a port selector.
Example: ".R1 > .pin1"
to: string
Description: Ending point of the trace using a port selector.
Example: ".C1 > .pin1"
maxLength: string (optional)
Description: Maximum length the trace can be.
Example: "10mm"
minLength: string (optional)
Description: Minimum length the trace must be.
Example: "5mm"
width: string (optional)
Description: Width of the trace.
Example: "0.2mm"
differentialPairKey: string (optional, beta)
Description: Groups traces for differential pair routing, ensuring matched lengths. Note: This property is in beta and not available on all autorouters yet.
```
--------------------------------
### Bun.js Build Configuration
Source: https://bun.sh/
Demonstrates how to configure and run a build process using Bun.js. This example specifies entry points, an output directory, enables minification, and includes a placeholder for plugins.
```TypeScript
await Bun.build({
entrypoints: ["./index.tsx"],
outdir: "./build",
minify: true,
plugins: [ /* ... */ ]
})
```
--------------------------------
### Bun Development Workflow Commands
Source: https://github.com/tscircuit/unravel-autorouter
These commands outline the standard development workflow for the tscircuit autorouter project using Bun. They cover installing project dependencies, starting the interactive development environment, running automated tests, and building the library for distribution.
```Shell
# Install dependencies
bun install
# Start the interactive development environment
bun run start
# Run tests
bun test
# Build the library
bun run build
```
--------------------------------
### Start Server to Access Bug Report with Bun
Source: https://github.com/tscircuit/unravel-autorouter
After downloading a bug report, this command starts the local server, allowing you to access and inspect the debugging fixture file created in the `examples/bug-reports` directory. This is crucial for finding and debugging the reported issue.
```Shell
bun run start
```
--------------------------------
### Create a Bun HTTP Server with SQL Database Access
Source: https://bun.sh/
This snippet demonstrates how to set up a basic HTTP server using Bun.js, serving a welcome message and an API endpoint that fetches user data from a database using Bun's SQL template literal.
```TypeScript
import { sql, serve } from "bun";
const server = serve({
port: 3000,
routes: {
"/": () => new Response("Welcome to Bun!"),
"/api/users": async (req) => {
const users = await sql`SELECT * FROM users LIMIT 10`;
return Response.json({ users });
}
}
});
console.log(`Listening on localhost:${server.port}`);
```
--------------------------------
### Bun Development Commands for Autorouter Library
Source: https://github.com/tscircuit/tscircuit-autorouter
These shell commands are used for developing the autorouter library using Bun. They cover essential development tasks such as installing project dependencies, starting the interactive development environment, running automated tests, and building the final library.
```Shell
bun install
bun run start
bun test
bun run build
```
--------------------------------
### Example JSON Response for Database/Registry Status
Source: https://github.com/npm/registry/blob/main/docs/REGISTRY-API
This JSON snippet represents a typical response from an API endpoint providing status information for a database or registry. It includes details such as the database name, document counts, update sequence, disk usage, and instance start time.
```JSON
{
"db_name": "registry",
"doc_count": 399172,
"doc_del_count": 354,
"update_seq": 3351374,
"purge_seq": 0,
"compact_running": false,
"disk_size": 2118398075,
"data_size": 1600835750,
"instance_start_time": "1475135224217333",
"disk_format_version": 6,
"committed_update_seq": 3351374
}
```
--------------------------------
### Initialize New tscircuit Project
Source: https://context7_llms
Demonstrates how to create a new directory and initialize a fresh tscircuit project within it using the `tsci init` command.
```bash
mkdir my-project
cd my-project
tsci init
```
--------------------------------
### Node.js Worker Threads Example
Source: https://nodejs.org/
This snippet demonstrates how to use Node.js worker threads to offload CPU-intensive tasks from the main thread. It shows the setup for both the main thread (spawning a worker and sending data) and the worker thread (receiving data and posting results back).
```JavaScript
// threads.mjs
import { Worker, isMainThread, workerData, parentPort } from 'node:worker_threads';
if (isMainThread) {
const data = 'some data';
const worker = new Worker(import.meta.url, {
workerData: data
});
worker.on('message', (msg) => {
console.log('Main thread received:', msg);
});
worker.on('error', (err) => {
console.error('Worker error:', err);
});
worker.on('exit', (code) => {
if (code !== 0) {
console.error(`Worker stopped with exit code ${code}`);
}
});
} else {
// This is the worker thread
console.log('Worker thread received:', workerData);
parentPort.postMessage('Hello from worker!');
}
```
--------------------------------
### Create a Basic Bun Web Server
Source: https://bun.sh/
Example TypeScript code demonstrating how to create a simple HTTP server using Bun. The server listens on port 3000 and responds with 'Welcome to Bun!' for all incoming requests.
```TypeScript
const server = Bun.serve({
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
}
});
console.log(`Listening on localhost:${server.port}`);
```
--------------------------------
### Using the Breakout Element in tscircuit
Source: https://context7_llms
This example illustrates the use of the `breakout` component to group elements and guide the autorouter. It contains a resistor, capacitor, and a trace, along with a `breakoutpoint` to define an exit location for connections from within the group, enabling precise routing control.
```JavaScript
export default () => (
)
```
--------------------------------
### Create a Basic Node.js HTTP Server
Source: https://nodejs.org/
This Node.js example demonstrates how to create a simple HTTP server using the built-in `node:http` module. The server listens on port 3000 and responds with 'Hello World!' to all incoming requests, providing a fundamental setup for web applications.
```JavaScript
// server.mjs
import { createServer } from 'node:http';
const server = createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World!\n');
});
// starts a simple http server locally on port 3000
server.listen(3000, '127.0.0.1', () => {
console.log('Listening on 127.0.0.1:3000');
});
// run with `node server.mjs`
```
--------------------------------
### Start tscircuit Development Server
Source: https://docs.tscircuit.com/ai.txt
This command starts the local development server for a tscircuit project, allowing users to view and interact with their circuit designs in a web browser.
```text
tsci dev
```
--------------------------------
### Configure tscircuit Board with Custom Autorouter Settings
Source: https://context7_llms
This example shows how to define a tscircuit board with custom dimensions and advanced autorouter configurations. It specifies a server URL, server mode, and input format for the autorouter, and includes multiple components and a trace to demonstrate a more complex board setup.
```JavaScript
export default () => (
)
```
--------------------------------
### MicroPython Wi-Fi Connection and API Data Fetching
Source: https://github.com/tscircuit/led-matrix-server
This Python snippet handles Wi-Fi connection setup and fetches LED matrix data from a specified API endpoint. It uses the `network` module for Wi-Fi and `urequests` for HTTP requests. The `get_matrix` function makes an HTTP GET request to retrieve the matrix data as JSON.
```Python
import network
import time
from credentials import SSID, PASSWORD
import urequests
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, PASSWORD)
while not wlan.isconnected():
print('Waiting for connection...')
time.sleep(1)
print('Connected to Wi-Fi')
def get_matrix():
response = urequests.get("http://-beside-witch.trycloudflare.com/api/matrix/get") #change this URL to your ngrok/cloudflared url!
matrix = response.json()
response.close()
return matrix
```
--------------------------------
### Creating a 4-Key Keyboard PCB with KeyMatrix and Pico
Source: https://docs.tscircuit.com/ai.txt
This comprehensive example demonstrates building a simple 2x2 keyboard PCB. It combines the 'KeyMatrix' component with a 'PICO' microcontroller, defining the key layout and mapping the matrix's row and column nets to specific Pico pins to create a functional macropad design.
```tsx
import { PICO } from "@tsci/seveibar.PICO";
import { type KLELayout, KeyMatrix } from "@tsci/seveibar.keyboard-utils";
// Define a simple 2x2 layout
const simpleLayout: KLELayout = [
["1", "2"],
["3", "4"],
]
// Map rows and columns to Pico pins (using net names for clarity)
const rowPins = ["net.ROW0", "net.ROW1"];
const colPins = ["net.COL0", "net.COL1"];
export default () => (
{/* Place the Pico */}
{/* Place the KeyMatrix */}
)
```
--------------------------------
### Defining Footprints with Strings vs. Manual Elements in tscircuit
Source: https://context7_llms
This example demonstrates two ways to define a resistor's footprint in tscircuit: using a simple footprinter string ('0402') for quick setup, and manually defining a custom footprint with and elements for precise control over pad and silkscreen geometries. This highlights the flexibility in component definition.
```JSX
export default () => (
} pcbX={3} resistance="1k" />
)
```
--------------------------------
### Initialize tscircuit Project
Source: https://docs.tscircuit.com/ai.txt
This command initializes a new tscircuit project in the current directory, setting up the necessary files and configuration. The `-y` flag automatically confirms any prompts.
```text
tsci init -y
```
--------------------------------
### Bun CLI: Installing Dependencies
Source: https://bun.sh/
Illustrates the basic command for installing project dependencies using Bun as a package manager. It highlights Bun's significant speed advantage over npm, pnpm, and Yarn, while maintaining compatibility with existing `node_modules` and `package.json` structures.
```shell
$ bun install
```
--------------------------------
### Install easyeda-converter CLI
Source: https://github.com/tscircuit/easyeda-converter
This command installs the easyeda-converter command-line interface globally, allowing you to use it from any directory in your terminal.
```shell
npm install -g easyeda
```
--------------------------------
### tscircuit CLI Project Initialization and Authentication
Source: https://docs.tscircuit.com/ai.txt
This snippet provides commands for initializing a new tscircuit project and retrieving an authentication token. The `tsci init` command bootstraps a new project with necessary files like `index.tsx` and `package.json`, and can be run interactively or with default acceptance. The `tsci auth print-token` command outputs the CLI token required for API authentication.
```bash
tsci auth print-token
mkdir my-circuit
cd my-circuit
tsci init
```
--------------------------------
### Install tscircuit 3D Viewer
Source: https://github.com/tscircuit/3d-viewer
Installs the `@tscircuit/3d-viewer` package using npm, making it available for use in your project.
```npm
npm install @tscircuit/3d-viewer
```
--------------------------------
### Install PCB Viewer Library
Source: https://github.com/tscircuit/pcb-viewer
Installs the `@tscircuit/pcb-viewer` package using npm, making it available for use in JavaScript/TypeScript projects.
```shell
npm install @tscircuit/pcb-viewer
```
--------------------------------
### Install circuit-to-svg Library
Source: https://github.com/tscircuit/circuit-to-svg
Instructions for installing the `circuit-to-svg` library using popular Node.js package managers like npm and Bun. This step is required before using the library's functionalities.
```shell
bun add circuit-to-svg
```
```shell
npm install circuit-to-svg
```