circuit-json-to-spice 0.0.1

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.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/biome.json +49 -0
  4. package/bun.lockb +0 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +3 -0
  7. package/docs/CIRCUIT_JSON_PCB_OVERVIEW.md +340 -0
  8. package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +151 -0
  9. package/docs/SPICE_SUMMARY.txt +248 -0
  10. package/lib/index.ts +1 -0
  11. package/lib/spice-classes/SpiceComponent.ts +0 -0
  12. package/lib/spice-classes/SpiceModel.ts +0 -0
  13. package/lib/spice-classes/SpiceNetlist.ts +9 -0
  14. package/lib/spice-classes/SpiceNode.ts +1 -0
  15. package/lib/spice-classes/SpiceSubcircuit.ts +0 -0
  16. package/lib/spice-commands/BJTCommand.ts +34 -0
  17. package/lib/spice-commands/BaseSpiceCommand.ts +6 -0
  18. package/lib/spice-commands/CapacitorCommand.ts +41 -0
  19. package/lib/spice-commands/CurrentSourceCommand.ts +35 -0
  20. package/lib/spice-commands/DiodeCommand.ts +27 -0
  21. package/lib/spice-commands/InductorCommand.ts +33 -0
  22. package/lib/spice-commands/InductorCouplingCommand.ts +21 -0
  23. package/lib/spice-commands/JFETCommand.ts +28 -0
  24. package/lib/spice-commands/MOSFETCommand.ts +67 -0
  25. package/lib/spice-commands/ResistorCommand.ts +28 -0
  26. package/lib/spice-commands/SubcircuitCallCommand.ts +21 -0
  27. package/lib/spice-commands/TransmissionLineCommand.ts +46 -0
  28. package/lib/spice-commands/VoltageControlledSwitchCommand.ts +31 -0
  29. package/lib/spice-commands/VoltageSourceCommand.ts +35 -0
  30. package/lib/spice-commands/index.ts +14 -0
  31. package/lib/spice-utils/convertSpiceNetlistToString.ts +3 -0
  32. package/package.json +18 -0
  33. package/tsconfig.json +27 -0
@@ -0,0 +1,35 @@
1
+ import type { BaseSpiceCommand } from "./BaseSpiceCommand"
2
+
3
+ export interface VoltageSourceCommandProps {
4
+ name: string
5
+ positiveNode: string
6
+ negativeNode: string
7
+ value?: string
8
+ acMagnitude?: string
9
+ acPhase?: string
10
+ }
11
+
12
+ export class VoltageSourceCommand implements BaseSpiceCommand {
13
+ commandName = "voltage_source" as const
14
+ props: VoltageSourceCommandProps
15
+
16
+ constructor(props: VoltageSourceCommandProps) {
17
+ this.props = props
18
+ }
19
+
20
+ toSpiceString(): string {
21
+ const { name, positiveNode, negativeNode, value, acMagnitude, acPhase } =
22
+ this.props
23
+ let spiceString = `V${name} ${positiveNode} ${negativeNode}`
24
+ if (value) {
25
+ spiceString += ` ${value}`
26
+ }
27
+ if (acMagnitude) {
28
+ spiceString += ` AC ${acMagnitude}`
29
+ if (acPhase) {
30
+ spiceString += ` ${acPhase}`
31
+ }
32
+ }
33
+ return spiceString
34
+ }
35
+ }
@@ -0,0 +1,14 @@
1
+ export * from "./BJTCommand"
2
+ export * from "./BaseSpiceCommand"
3
+ export * from "./CapacitorCommand"
4
+ export * from "./CurrentSourceCommand"
5
+ export * from "./DiodeCommand"
6
+ export * from "./InductorCommand"
7
+ export * from "./InductorCouplingCommand"
8
+ export * from "./JFETCommand"
9
+ export * from "./MOSFETCommand"
10
+ export * from "./ResistorCommand"
11
+ export * from "./SubcircuitCallCommand"
12
+ export * from "./TransmissionLineCommand"
13
+ export * from "./VoltageControlledSwitchCommand"
14
+ export * from "./VoltageSourceCommand"
@@ -0,0 +1,3 @@
1
+ import type { SpiceNetlist } from "../spice-classes/SpiceNetlist"
2
+
3
+ export const convertSpiceNetlistToString = (netlist: SpiceNetlist) => {}
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "circuit-json-to-spice",
3
+ "main": "dist/index.js",
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "tsup-node ./lib/index.ts --dts --format esm --sourcemap inline -d dist"
8
+ },
9
+ "devDependencies": {
10
+ "@biomejs/biome": "^1.9.4",
11
+ "@types/bun": "latest",
12
+ "circuit-json": "^0.0.111",
13
+ "tsup": "^8.4.0"
14
+ },
15
+ "peerDependencies": {
16
+ "typescript": "^5.0.0"
17
+ }
18
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }