@tscircuit/cli 0.0.168 → 0.0.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,15 @@
1
+ import "@tscircuit/core"
1
2
  import { layout } from "@tscircuit/layout"
2
3
  import manual_edits from "../src/manual-edits"
3
4
 
4
- export const BasicBug = () => (
5
+ export const BasicChip = () => (
5
6
  <board pcbCenterX={0} pcbCenterY={0} width="20mm" height="20mm">
6
7
  <group
7
8
  layout={layout()
8
9
  .autoLayoutSchematic()
9
10
  .manualPcbPlacement(manual_edits.pcb_placements)}
10
11
  >
11
- <bug
12
+ <chip
12
13
  name="U2"
13
14
  schPortArrangement={{
14
15
  leftSize: 4,
@@ -23,7 +24,7 @@ export const BasicBug = () => (
23
24
  }}
24
25
  />
25
26
  <resistor name="R1" resistance="10kohm" footprint="0805" />
26
- <trace from=".U2 > .1" to=".R1 > .left" />
27
+ <trace from=".U2 > .1" to=".R1 > port.1" />
27
28
  </group>
28
29
  </board>
29
30
  )
@@ -288,7 +288,7 @@ export const HeaderMenu = () => {
288
288
  </MenubarItem>
289
289
  <MenubarItem disabled>
290
290
  @tscircuit/react-fiber v
291
- {cliPackageJson.devDependencies["@tscircuit/react-fiber"].replace(
291
+ {cliPackageJson.dependencies["@tscircuit/react-fiber"].replace(
292
292
  /\^/g,
293
293
  "",
294
294
  )}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.168",
3
+ "version": "0.0.170",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",
@@ -35,6 +35,9 @@
35
35
  "dependencies": {
36
36
  "@edge-runtime/primitives": "^4.1.0",
37
37
  "@hono/node-server": "^1.8.2",
38
+ "@tscircuit/builder": "*",
39
+ "@tscircuit/core": "0.0.14",
40
+ "@tscircuit/react-fiber": "*",
38
41
  "archiver": "^7.0.1",
39
42
  "axios": "^1.6.7",
40
43
  "chokidar": "^3.6.0",
@@ -66,8 +69,7 @@
66
69
  "ts-morph": "^22.0.0",
67
70
  "tsup": "^8.0.2",
68
71
  "winterspec": "0.0.86",
69
- "zod": "^3.22.4",
70
- "@tscircuit/builder": "*"
72
+ "zod": "^3.22.4"
71
73
  },
72
74
  "peerDependencies": {
73
75
  "@tscircuit/builder": "*",
@@ -96,9 +98,8 @@
96
98
  "@tscircuit/layout": "^0.0.25",
97
99
  "@tscircuit/manual-edit-events": "^0.0.4",
98
100
  "@tscircuit/pcb-viewer": "^1.4.4",
99
- "@tscircuit/react-fiber": "*",
100
101
  "@tscircuit/schematic-viewer": "^1.2.14",
101
- "@tscircuit/soup-util": "^0.0.18",
102
+ "@tscircuit/soup-util": "^0.0.20",
102
103
  "@tscircuit/table-viewer": "0.0.8",
103
104
  "@types/archiver": "^6.0.2",
104
105
  "@types/bun": "^1.0.8",
package/tsconfig.json CHANGED
@@ -13,8 +13,17 @@
13
13
  "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
14
14
  "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
15
15
 
16
+ "paths": {
17
+ "cli/*": ["cli/*"],
18
+ "frontend/*": ["frontend/*"],
19
+ "api/*": ["api/*"],
20
+ "scripts/*": ["scripts/*"],
21
+ },
22
+
16
23
  "strict": true /* Enable all strict type-checking options. */,
17
24
  "skipLibCheck": true,
18
- "verbatimModuleSyntax": false
25
+ "verbatimModuleSyntax": false,
19
26
  },
27
+ "include": ["src/**/*", "cli/**/*", "frontend/**/*", "api/**/*", "scripts/**/*", "example-project/**/*"],
28
+ "exclude": ["node_modules"]
20
29
  }
@@ -1,115 +0,0 @@
1
- import { AppContext } from "./util/app-context"
2
- import { z } from "zod"
3
- import $ from "dax-sh"
4
- import * as Path from "path"
5
- import { unlink } from "node:fs/promises"
6
- import kleur from "kleur"
7
- import { writeFileSync } from "fs"
8
- import { readFile } from "fs/promises"
9
- import Debug from "debug"
10
-
11
- const debug = Debug("tscircuit:soupify")
12
-
13
- export const soupify = async (
14
- {
15
- filePath,
16
- exportName,
17
- }: {
18
- filePath: string
19
- exportName?: string
20
- },
21
- ctx: Pick<AppContext, "runtime" | "params">,
22
- ) => {
23
- debug(`reading ${filePath}`)
24
- const targetFileContent = await readFile(filePath, "utf-8")
25
-
26
- if (!exportName) {
27
- if (targetFileContent.includes("export default")) {
28
- exportName = "default"
29
- } else {
30
- // Look for "export const <name>" or "export function <name>"
31
- const exportRegex = /export\s+(?:const|function)\s+(\w+)/g
32
- const match = exportRegex.exec(targetFileContent)
33
- if (match) {
34
- exportName = match[1]
35
- }
36
- }
37
- }
38
-
39
- if (!exportName) {
40
- throw new Error(
41
- `Couldn't derive an export name and didn't find default export in "${filePath}"`,
42
- )
43
- }
44
-
45
- const tmpFilePath = Path.join(
46
- Path.dirname(filePath),
47
- Path.basename(filePath).replace(/\.[^\.]+$/, "") + ".__tmp_entrypoint.tsx",
48
- )
49
-
50
- debug(`writing to ${tmpFilePath}`)
51
- writeFileSync(
52
- tmpFilePath,
53
- `
54
- import React from "react"
55
- import { createRoot } from "@tscircuit/react-fiber"
56
- import { createProjectBuilder } from "@tscircuit/builder"
57
-
58
- import * as EXPORTS from "./${Path.basename(filePath)}"
59
-
60
- const Component = EXPORTS["${exportName}"]
61
-
62
- if (!Component) {
63
- console.log(JSON.stringify({
64
- COMPILE_ERROR: 'Failed to find "${exportName}" export in "${filePath}"'
65
- }))
66
- process.exit(0)
67
- }
68
-
69
- const projectBuilder = createProjectBuilder()
70
- const elements = await createRoot().render(<Component />, projectBuilder)
71
-
72
- console.log(JSON.stringify(elements))
73
-
74
- `.trim(),
75
- )
76
-
77
- debug(`using runtime ${ctx.runtime}`)
78
- const processCmdPart1 =
79
- ctx.runtime === "node" ? $`npx tsx ${tmpFilePath}` : $`bun ${tmpFilePath}`
80
-
81
- debug(`starting process....`)
82
- const processResult = await processCmdPart1
83
- .stdout(debug.enabled ? "inheritPiped" : "piped")
84
- .stderr(debug.enabled ? "inheritPiped" : "piped")
85
- .noThrow()
86
-
87
- // TODO we should send it to a temporarty file rather than rely on stdout
88
- // which can easily be polluted
89
- const rawSoup = processResult.stdout.replace(/^[^\[]*/, "")
90
- const errText = processResult.stderr
91
-
92
- if (ctx.params.cleanup !== false) {
93
- debug(`deleting ${tmpFilePath}`)
94
- await unlink(tmpFilePath)
95
- }
96
-
97
- try {
98
- debug(`parsing result of soupify...`)
99
- const soup = JSON.parse(rawSoup)
100
-
101
- if (soup.COMPILE_ERROR) {
102
- // console.log(kleur.red(`Failed to compile ${filePath}`))
103
- console.log(kleur.red(soup.COMPILE_ERROR))
104
- throw new Error(soup.COMPILE_ERROR)
105
- }
106
-
107
- return soup
108
- } catch (e: any) {
109
- // console.log(kleur.red(`Failed to parse result of soupify: ${e.toString()}`))
110
- const t = Date.now()
111
- console.log(`Dumping raw output to .tscircuit/err-${t}.log`)
112
- writeFileSync(`.tscircuit/err-${t}.log`, rawSoup + "\n\n" + errText)
113
- throw new Error(errText)
114
- }
115
- }