-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into optimize-build
- Loading branch information
Showing
123 changed files
with
2,922 additions
and
497 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @seveibar @tscircuit/core | ||
* @seveibar @imrishabh18 @tscircuit/core |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Created using @tscircuit/plop (npm install -g @tscircuit/plop) | ||
name: Publish to npm | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'fake-snippets-api/**' | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install -g pver | ||
- run: bun install --frozen-lockfile | ||
- run: bun run build:fake-api | ||
- run: pver release | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
name: Playwright Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,7 @@ package-lock.json | |
test-results | ||
|
||
.yalc | ||
yalc.lock | ||
yalc.lock | ||
|
||
public/assets | ||
public/sitemap.xml |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import axios from "redaxios" | ||
import fs from "fs" | ||
import path from "path" | ||
import { DbClient } from "./db-client" | ||
|
||
const extractTsciDependencies = ( | ||
code: string, | ||
): Array<{ owner: string; name: string }> => { | ||
const regex = /@tsci\/([^.]+)\.([^"'\s]+)/g | ||
const matches = Array.from(code.matchAll(regex)) | ||
return matches.map((match) => ({ | ||
owner: match[1], | ||
name: match[2], | ||
})) | ||
} | ||
|
||
const registryApi = axios.create({ | ||
baseURL: "https://registry-api.tscircuit.com", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
}) | ||
|
||
const fetchSnippetFromRegistry = async (owner: string, name: string) => { | ||
const response = await registryApi.get( | ||
`/snippets/get?owner_name=${owner}&unscoped_name=${name}`, | ||
) | ||
return response.data.snippet | ||
} | ||
|
||
const loadSnippetWithDependencies = async ( | ||
db: DbClient, | ||
owner: string, | ||
name: string, | ||
loadedSnippets = new Set<string>(), | ||
) => { | ||
const snippetKey = `${owner}/${name}` | ||
if (loadedSnippets.has(snippetKey)) { | ||
return | ||
} | ||
|
||
try { | ||
const snippet = await fetchSnippetFromRegistry(owner, name) | ||
|
||
if (db.getSnippetByAuthorAndName(owner, name)) return | ||
|
||
db.addSnippet(snippet) | ||
loadedSnippets.add(snippetKey) | ||
|
||
const dependencies = extractTsciDependencies(snippet.code) | ||
for (const dep of dependencies) { | ||
loadSnippetWithDependencies(db, dep.owner, dep.name, loadedSnippets) | ||
} | ||
} catch (e) { | ||
console.error(`✗ Failed to load ${snippetKey}:`, e) | ||
} | ||
} | ||
|
||
export const loadAutoloadSnippets = async (db: DbClient) => { | ||
try { | ||
const autoloadPath = path.join( | ||
path.dirname(__dirname), | ||
"db", | ||
"autoload-snippets.json", | ||
) | ||
if (fs.existsSync(autoloadPath)) { | ||
const autoloadContent = JSON.parse(fs.readFileSync(autoloadPath, "utf8")) | ||
console.log("Loading development snippets from registry...") | ||
|
||
const loadedSnippets = new Set<string>() | ||
for (const snippetRef of autoloadContent.snippets) { | ||
loadSnippetWithDependencies( | ||
db, | ||
snippetRef.owner, | ||
snippetRef.name, | ||
loadedSnippets, | ||
) | ||
} | ||
} | ||
} catch (e) { | ||
console.error("Failed to load autoload-snippets.json:", e) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"snippets": [ | ||
{ | ||
"owner": "Abse2001", | ||
"name": "Arduino-Nano-Servo-Breakout" | ||
}, | ||
{ | ||
"owner": "ShiboSoftwareDev", | ||
"name": "Wifi-Camera-Module" | ||
}, | ||
{ | ||
"owner": "imrishabh18", | ||
"name": "Arduino-nano" | ||
}, | ||
{ | ||
"owner": "seveibar", | ||
"name": "usb-c-flashlight" | ||
}, | ||
{ | ||
"owner": "AnasSarkiz", | ||
"name": "grid-of-LEDs-with-an-ESP32" | ||
} | ||
] | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="robots" content="index, follow, NOODP" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16"> | ||
<title>tscircuit - Code Electronics with React</title> | ||
<meta name="description" content="tscircuit is an open-source electronics design tool that lets you create circuits using React components. Design schematics, generate PCB layouts, export and manufacture PCBs online!" /> | ||
<meta name="keywords" content="electronic design, PCB design, schematic capture, React components, circuit design, electronics CAD, open source EDA" /> | ||
<meta property="og:title" content="tscircuit - Design Electronics with React Components" /> | ||
<meta property="og:description" content="Create electronic circuits using React components. Design schematics, generate PCB layouts, and manufacture custom PCBs with this free open-source tool." /> | ||
<meta property="og:type" content="website" /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta name="twitter:title" content="tscircuit - Design Electronics with React Components" /> | ||
<meta name="twitter:description" content="Create electronic circuits using React components. Free open-source electronics design tool." /> | ||
<link rel="canonical" href="https://tscircuit.com" /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/pages/landing.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.