@tscircuit/ngspice-spice-engine 0.0.17 → 0.0.18
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.
- package/dist/index.d.ts +30 -1
- package/dist/index.js +22 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SpiceEngine } from '@tscircuit/props';
|
|
2
|
-
import { ResultType } from '@tscircuit/eecircuit-engine';
|
|
3
2
|
import { SimulationTransientVoltageGraph, SimulationTransientCurrentGraph } from 'circuit-json';
|
|
4
3
|
|
|
5
4
|
interface TranParams {
|
|
@@ -13,6 +12,36 @@ declare const parseTranParams: (spiceString: string) => TranParams | null;
|
|
|
13
12
|
|
|
14
13
|
declare const rewritePspiceCompatibilitySyntax: (spiceString: string) => string;
|
|
15
14
|
|
|
15
|
+
type ComplexNumber = {
|
|
16
|
+
real: number;
|
|
17
|
+
img: number;
|
|
18
|
+
};
|
|
19
|
+
type RealDataType = {
|
|
20
|
+
name: string;
|
|
21
|
+
type: "voltage" | "current" | "time" | "frequency" | "notype";
|
|
22
|
+
values: number[];
|
|
23
|
+
};
|
|
24
|
+
type ComplexDataType = {
|
|
25
|
+
name: string;
|
|
26
|
+
type: RealDataType["type"];
|
|
27
|
+
values: ComplexNumber[];
|
|
28
|
+
};
|
|
29
|
+
type ResultType = {
|
|
30
|
+
header: string;
|
|
31
|
+
numVariables: number;
|
|
32
|
+
variableNames: string[];
|
|
33
|
+
numPoints: number;
|
|
34
|
+
dataType: "real";
|
|
35
|
+
data: RealDataType[];
|
|
36
|
+
} | {
|
|
37
|
+
header: string;
|
|
38
|
+
numVariables: number;
|
|
39
|
+
variableNames: string[];
|
|
40
|
+
numPoints: number;
|
|
41
|
+
dataType: "complex";
|
|
42
|
+
data: ComplexDataType[];
|
|
43
|
+
};
|
|
44
|
+
|
|
16
45
|
interface VoltageProbeMetadata {
|
|
17
46
|
simulation_voltage_probe_id: string;
|
|
18
47
|
name?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
// lib/import-eecircuit-engine.ts
|
|
2
|
+
var EECIRCUIT_ENGINE_URL = "https://jscdn.tscircuit.com/@tscircuit/eecircuit-engine/1.7.4/+esm";
|
|
3
|
+
var modulePromise = null;
|
|
4
|
+
var importEecircuitEngine = async () => {
|
|
5
|
+
if (!modulePromise) {
|
|
6
|
+
modulePromise = fetch(EECIRCUIT_ENGINE_URL).then(async (response) => {
|
|
7
|
+
if (!response.ok) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
`Failed to load @tscircuit/eecircuit-engine from ${EECIRCUIT_ENGINE_URL}: ${response.status} ${response.statusText}`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
const source = await response.text();
|
|
13
|
+
const moduleUrl = URL.createObjectURL(
|
|
14
|
+
new Blob([source], { type: "text/javascript" })
|
|
15
|
+
);
|
|
16
|
+
return import(moduleUrl);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return modulePromise;
|
|
20
|
+
};
|
|
21
|
+
|
|
1
22
|
// lib/parse-tran-params.ts
|
|
2
23
|
var SUFFIX_MULTIPLIERS = {
|
|
3
24
|
t: 1e12,
|
|
@@ -477,7 +498,7 @@ var simulationGraphsToCircuitJson = (graphs, spiceString) => {
|
|
|
477
498
|
|
|
478
499
|
// lib/index.ts
|
|
479
500
|
var ensureSimulation = async () => {
|
|
480
|
-
const { Simulation: SimulationCtor } = await
|
|
501
|
+
const { Simulation: SimulationCtor } = await importEecircuitEngine();
|
|
481
502
|
const instance = new SimulationCtor({ ngBehavior: "psa" });
|
|
482
503
|
await instance.start();
|
|
483
504
|
return instance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/ngspice-spice-engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "A tscircuit-compatible SPICE engine using ngspice.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"typecheck": "tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@tscircuit/eecircuit-engine": "https://jscdn.tscircuit.com/@tscircuit/eecircuit-engine/1.7.4.tgz",
|
|
21
20
|
"@tscircuit/props": "^0.0.551",
|
|
22
21
|
"bun-match-svg": "^0.0.14",
|
|
23
22
|
"circuit-json": "^0.0.437",
|