schematex 0.1.0
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/LICENSE +661 -0
- package/README.md +379 -0
- package/dist/chunk-2MQWZ2XY.cjs +453 -0
- package/dist/chunk-2MQWZ2XY.cjs.map +1 -0
- package/dist/chunk-2UKC6ZCY.cjs +1803 -0
- package/dist/chunk-2UKC6ZCY.cjs.map +1 -0
- package/dist/chunk-34X3ZJ6E.cjs +783 -0
- package/dist/chunk-34X3ZJ6E.cjs.map +1 -0
- package/dist/chunk-3FTUWAXK.cjs +1220 -0
- package/dist/chunk-3FTUWAXK.cjs.map +1 -0
- package/dist/chunk-3J7TFUOC.js +745 -0
- package/dist/chunk-3J7TFUOC.js.map +1 -0
- package/dist/chunk-47ZC6EMJ.js +1009 -0
- package/dist/chunk-47ZC6EMJ.js.map +1 -0
- package/dist/chunk-4DBRNOPA.cjs +750 -0
- package/dist/chunk-4DBRNOPA.cjs.map +1 -0
- package/dist/chunk-4G7ZIBHN.js +778 -0
- package/dist/chunk-4G7ZIBHN.js.map +1 -0
- package/dist/chunk-5C7DPDHQ.js +1321 -0
- package/dist/chunk-5C7DPDHQ.js.map +1 -0
- package/dist/chunk-ADOXGKAK.js +1251 -0
- package/dist/chunk-ADOXGKAK.js.map +1 -0
- package/dist/chunk-BE5HNDA5.cjs +874 -0
- package/dist/chunk-BE5HNDA5.cjs.map +1 -0
- package/dist/chunk-CZRM7LT7.js +889 -0
- package/dist/chunk-CZRM7LT7.js.map +1 -0
- package/dist/chunk-D4JTSPOL.js +1795 -0
- package/dist/chunk-D4JTSPOL.js.map +1 -0
- package/dist/chunk-DS47NTWZ.cjs +1034 -0
- package/dist/chunk-DS47NTWZ.cjs.map +1 -0
- package/dist/chunk-FDLZEKEB.js +449 -0
- package/dist/chunk-FDLZEKEB.js.map +1 -0
- package/dist/chunk-FGPTCDUT.cjs +1851 -0
- package/dist/chunk-FGPTCDUT.cjs.map +1 -0
- package/dist/chunk-HDKDQAEQ.cjs +86 -0
- package/dist/chunk-HDKDQAEQ.cjs.map +1 -0
- package/dist/chunk-IX554O5K.js +346 -0
- package/dist/chunk-IX554O5K.js.map +1 -0
- package/dist/chunk-KLJEK547.js +71 -0
- package/dist/chunk-KLJEK547.js.map +1 -0
- package/dist/chunk-LMFSHK45.js +1028 -0
- package/dist/chunk-LMFSHK45.js.map +1 -0
- package/dist/chunk-MDICUK6F.cjs +1258 -0
- package/dist/chunk-MDICUK6F.cjs.map +1 -0
- package/dist/chunk-N7KOXOMX.cjs +363 -0
- package/dist/chunk-N7KOXOMX.cjs.map +1 -0
- package/dist/chunk-NYCIK4SU.cjs +775 -0
- package/dist/chunk-NYCIK4SU.cjs.map +1 -0
- package/dist/chunk-PDPHRZZT.js +770 -0
- package/dist/chunk-PDPHRZZT.js.map +1 -0
- package/dist/chunk-ROFLJ74T.js +1212 -0
- package/dist/chunk-ROFLJ74T.js.map +1 -0
- package/dist/chunk-S6BK5DB6.cjs +845 -0
- package/dist/chunk-S6BK5DB6.cjs.map +1 -0
- package/dist/chunk-U4I37IBN.js +874 -0
- package/dist/chunk-U4I37IBN.js.map +1 -0
- package/dist/chunk-U5GGE6PJ.js +839 -0
- package/dist/chunk-U5GGE6PJ.js.map +1 -0
- package/dist/chunk-UHLYS3W5.cjs +1015 -0
- package/dist/chunk-UHLYS3W5.cjs.map +1 -0
- package/dist/chunk-URSKIHSY.cjs +881 -0
- package/dist/chunk-URSKIHSY.cjs.map +1 -0
- package/dist/chunk-V6WO7RK7.cjs +1056 -0
- package/dist/chunk-V6WO7RK7.cjs.map +1 -0
- package/dist/chunk-VFQCTXOX.js +869 -0
- package/dist/chunk-VFQCTXOX.js.map +1 -0
- package/dist/chunk-XQ52ICHU.cjs +895 -0
- package/dist/chunk-XQ52ICHU.cjs.map +1 -0
- package/dist/chunk-XX4BKS7Y.js +1051 -0
- package/dist/chunk-XX4BKS7Y.js.map +1 -0
- package/dist/chunk-XXU36667.js +1844 -0
- package/dist/chunk-XXU36667.js.map +1 -0
- package/dist/chunk-ZX7QKZK2.cjs +1326 -0
- package/dist/chunk-ZX7QKZK2.cjs.map +1 -0
- package/dist/diagrams/blockdiagram/index.cjs +25 -0
- package/dist/diagrams/blockdiagram/index.cjs.map +1 -0
- package/dist/diagrams/blockdiagram/index.d.cts +67 -0
- package/dist/diagrams/blockdiagram/index.d.ts +67 -0
- package/dist/diagrams/blockdiagram/index.js +4 -0
- package/dist/diagrams/blockdiagram/index.js.map +1 -0
- package/dist/diagrams/circuit/index.cjs +34 -0
- package/dist/diagrams/circuit/index.cjs.map +1 -0
- package/dist/diagrams/circuit/index.d.cts +138 -0
- package/dist/diagrams/circuit/index.d.ts +138 -0
- package/dist/diagrams/circuit/index.js +5 -0
- package/dist/diagrams/circuit/index.js.map +1 -0
- package/dist/diagrams/ecomap/index.cjs +30 -0
- package/dist/diagrams/ecomap/index.cjs.map +1 -0
- package/dist/diagrams/ecomap/index.d.cts +15 -0
- package/dist/diagrams/ecomap/index.d.ts +15 -0
- package/dist/diagrams/ecomap/index.js +5 -0
- package/dist/diagrams/ecomap/index.js.map +1 -0
- package/dist/diagrams/entity/index.cjs +26 -0
- package/dist/diagrams/entity/index.cjs.map +1 -0
- package/dist/diagrams/entity/index.d.cts +54 -0
- package/dist/diagrams/entity/index.d.ts +54 -0
- package/dist/diagrams/entity/index.js +5 -0
- package/dist/diagrams/entity/index.js.map +1 -0
- package/dist/diagrams/fishbone/index.cjs +34 -0
- package/dist/diagrams/fishbone/index.cjs.map +1 -0
- package/dist/diagrams/fishbone/index.d.cts +185 -0
- package/dist/diagrams/fishbone/index.d.ts +185 -0
- package/dist/diagrams/fishbone/index.js +5 -0
- package/dist/diagrams/fishbone/index.js.map +1 -0
- package/dist/diagrams/flowchart/index.cjs +34 -0
- package/dist/diagrams/flowchart/index.cjs.map +1 -0
- package/dist/diagrams/flowchart/index.d.cts +2 -0
- package/dist/diagrams/flowchart/index.d.ts +2 -0
- package/dist/diagrams/flowchart/index.js +5 -0
- package/dist/diagrams/flowchart/index.js.map +1 -0
- package/dist/diagrams/genogram/index.cjs +38 -0
- package/dist/diagrams/genogram/index.cjs.map +1 -0
- package/dist/diagrams/genogram/index.d.cts +20 -0
- package/dist/diagrams/genogram/index.d.ts +20 -0
- package/dist/diagrams/genogram/index.js +5 -0
- package/dist/diagrams/genogram/index.js.map +1 -0
- package/dist/diagrams/ladder/index.cjs +26 -0
- package/dist/diagrams/ladder/index.cjs.map +1 -0
- package/dist/diagrams/ladder/index.d.cts +49 -0
- package/dist/diagrams/ladder/index.d.ts +49 -0
- package/dist/diagrams/ladder/index.js +5 -0
- package/dist/diagrams/ladder/index.js.map +1 -0
- package/dist/diagrams/logic/index.cjs +26 -0
- package/dist/diagrams/logic/index.cjs.map +1 -0
- package/dist/diagrams/logic/index.d.cts +73 -0
- package/dist/diagrams/logic/index.d.ts +73 -0
- package/dist/diagrams/logic/index.js +5 -0
- package/dist/diagrams/logic/index.js.map +1 -0
- package/dist/diagrams/orgchart/index.cjs +30 -0
- package/dist/diagrams/orgchart/index.cjs.map +1 -0
- package/dist/diagrams/orgchart/index.d.cts +100 -0
- package/dist/diagrams/orgchart/index.d.ts +100 -0
- package/dist/diagrams/orgchart/index.js +5 -0
- package/dist/diagrams/orgchart/index.js.map +1 -0
- package/dist/diagrams/pedigree/index.cjs +30 -0
- package/dist/diagrams/pedigree/index.cjs.map +1 -0
- package/dist/diagrams/pedigree/index.d.cts +15 -0
- package/dist/diagrams/pedigree/index.d.ts +15 -0
- package/dist/diagrams/pedigree/index.js +5 -0
- package/dist/diagrams/pedigree/index.js.map +1 -0
- package/dist/diagrams/phylo/index.cjs +30 -0
- package/dist/diagrams/phylo/index.cjs.map +1 -0
- package/dist/diagrams/phylo/index.d.cts +32 -0
- package/dist/diagrams/phylo/index.d.ts +32 -0
- package/dist/diagrams/phylo/index.js +5 -0
- package/dist/diagrams/phylo/index.js.map +1 -0
- package/dist/diagrams/sld/index.cjs +26 -0
- package/dist/diagrams/sld/index.cjs.map +1 -0
- package/dist/diagrams/sld/index.d.cts +58 -0
- package/dist/diagrams/sld/index.d.ts +58 -0
- package/dist/diagrams/sld/index.js +5 -0
- package/dist/diagrams/sld/index.js.map +1 -0
- package/dist/diagrams/sociogram/index.cjs +26 -0
- package/dist/diagrams/sociogram/index.cjs.map +1 -0
- package/dist/diagrams/sociogram/index.d.cts +76 -0
- package/dist/diagrams/sociogram/index.d.ts +76 -0
- package/dist/diagrams/sociogram/index.js +5 -0
- package/dist/diagrams/sociogram/index.js.map +1 -0
- package/dist/diagrams/timing/index.cjs +21 -0
- package/dist/diagrams/timing/index.cjs.map +1 -0
- package/dist/diagrams/timing/index.d.cts +9 -0
- package/dist/diagrams/timing/index.d.ts +9 -0
- package/dist/diagrams/timing/index.js +4 -0
- package/dist/diagrams/timing/index.js.map +1 -0
- package/dist/diagrams/venn/index.cjs +38 -0
- package/dist/diagrams/venn/index.cjs.map +1 -0
- package/dist/diagrams/venn/index.d.cts +69 -0
- package/dist/diagrams/venn/index.d.ts +69 -0
- package/dist/diagrams/venn/index.js +5 -0
- package/dist/diagrams/venn/index.js.map +1 -0
- package/dist/index-BSlza1YY.d.ts +150 -0
- package/dist/index-BXefHVce.d.cts +150 -0
- package/dist/index.cjs +2033 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +1944 -0
- package/dist/index.js.map +1 -0
- package/dist/types-DqfcYkcY.d.cts +741 -0
- package/dist/types-DqfcYkcY.d.ts +741 -0
- package/package.json +163 -0
|
@@ -0,0 +1,1851 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkN7KOXOMX_cjs = require('./chunk-N7KOXOMX.cjs');
|
|
4
|
+
var chunkHDKDQAEQ_cjs = require('./chunk-HDKDQAEQ.cjs');
|
|
5
|
+
|
|
6
|
+
// src/diagrams/circuit/netlist.ts
|
|
7
|
+
var NetlistParseError = class extends Error {
|
|
8
|
+
constructor(message, line) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.line = line;
|
|
11
|
+
this.name = "NetlistParseError";
|
|
12
|
+
}
|
|
13
|
+
line;
|
|
14
|
+
};
|
|
15
|
+
var PREFIX_MAP = {
|
|
16
|
+
R: { type: "resistor", pins: ["start", "end"] },
|
|
17
|
+
C: { type: "capacitor", pins: ["start", "end"] },
|
|
18
|
+
L: { type: "inductor", pins: ["start", "end"] },
|
|
19
|
+
D: { type: "diode", pins: ["start", "end"] },
|
|
20
|
+
// anode → start, cathode → end
|
|
21
|
+
V: { type: "voltage_source", pins: ["plus", "minus"] },
|
|
22
|
+
I: { type: "current_source", pins: ["plus", "minus"] },
|
|
23
|
+
Q: { type: "npn", pins: ["c", "b", "e"] },
|
|
24
|
+
M: { type: "nmos", pins: ["d", "g", "s"] },
|
|
25
|
+
J: { type: "jfet_n", pins: ["d", "g", "s"] },
|
|
26
|
+
S: { type: "switch_spst", pins: ["start", "end"] },
|
|
27
|
+
F: { type: "fuse", pins: ["start", "end"] },
|
|
28
|
+
B: { type: "battery", pins: ["plus", "minus"] },
|
|
29
|
+
K: { type: "relay_coil", pins: ["start", "end"] },
|
|
30
|
+
U: { type: "generic_ic", pins: [] },
|
|
31
|
+
// pins declared via pins="..." attr
|
|
32
|
+
X: { type: "generic_ic", pins: [] }
|
|
33
|
+
};
|
|
34
|
+
var TYPE_ALIASES = {
|
|
35
|
+
vsource: "voltage_source",
|
|
36
|
+
isource: "current_source",
|
|
37
|
+
acsource: "ac_source",
|
|
38
|
+
ecap: "electrolytic_cap",
|
|
39
|
+
pot: "potentiometer",
|
|
40
|
+
gnd: "ground",
|
|
41
|
+
ic: "generic_ic",
|
|
42
|
+
reg: "voltage_regulator",
|
|
43
|
+
timer555: "555_timer",
|
|
44
|
+
transistor: "npn"
|
|
45
|
+
};
|
|
46
|
+
var GROUND_NETS = /* @__PURE__ */ new Set(["0", "gnd", "GND", "Gnd", "ground", "Ground"]);
|
|
47
|
+
function tokenize(line) {
|
|
48
|
+
const tokens = [];
|
|
49
|
+
let i = 0;
|
|
50
|
+
while (i < line.length) {
|
|
51
|
+
const ch = line[i];
|
|
52
|
+
if (ch === " " || ch === " ") {
|
|
53
|
+
i++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (ch === '"') {
|
|
57
|
+
const end = line.indexOf('"', i + 1);
|
|
58
|
+
tokens.push(line.slice(i, end < 0 ? line.length : end + 1));
|
|
59
|
+
i = end < 0 ? line.length : end + 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let j = i;
|
|
63
|
+
while (j < line.length && line[j] !== " " && line[j] !== " ") {
|
|
64
|
+
if (line[j] === "=" && line[j + 1] === '"') {
|
|
65
|
+
const end = line.indexOf('"', j + 2);
|
|
66
|
+
j = end < 0 ? line.length : end + 1;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
j++;
|
|
70
|
+
}
|
|
71
|
+
tokens.push(line.slice(i, j));
|
|
72
|
+
i = j;
|
|
73
|
+
}
|
|
74
|
+
return tokens;
|
|
75
|
+
}
|
|
76
|
+
function isKeyEqVal(tok) {
|
|
77
|
+
const eq = tok.indexOf("=");
|
|
78
|
+
return eq > 0 && /^[a-zA-Z_][\w]*$/.test(tok.slice(0, eq));
|
|
79
|
+
}
|
|
80
|
+
function parseKV(tok) {
|
|
81
|
+
const eq = tok.indexOf("=");
|
|
82
|
+
const key = tok.slice(0, eq).trim();
|
|
83
|
+
let val = tok.slice(eq + 1).trim();
|
|
84
|
+
if (val.startsWith('"') && val.endsWith('"')) val = val.slice(1, -1);
|
|
85
|
+
return [key, val];
|
|
86
|
+
}
|
|
87
|
+
function parseNetlist(body, title2) {
|
|
88
|
+
const components = [];
|
|
89
|
+
const netByName = /* @__PURE__ */ new Map();
|
|
90
|
+
const pinMap = {};
|
|
91
|
+
let autoGnd = 0;
|
|
92
|
+
const ensureNet = (name) => {
|
|
93
|
+
let n = netByName.get(name);
|
|
94
|
+
if (!n) {
|
|
95
|
+
n = { id: name, anchors: [] };
|
|
96
|
+
netByName.set(name, n);
|
|
97
|
+
}
|
|
98
|
+
return n;
|
|
99
|
+
};
|
|
100
|
+
const lines = body.split("\n").map((l) => l.replace(/\r$/, ""));
|
|
101
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
102
|
+
const raw = lines[lineIdx];
|
|
103
|
+
const stripped = raw.replace(/#.*$/, "").trim();
|
|
104
|
+
if (!stripped) continue;
|
|
105
|
+
const tokens = tokenize(stripped);
|
|
106
|
+
if (tokens.length < 2) {
|
|
107
|
+
throw new NetlistParseError(
|
|
108
|
+
`Netlist line must have at least ID + one net: "${stripped}"`,
|
|
109
|
+
lineIdx + 1
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const id = tokens[0];
|
|
113
|
+
if (!/^[a-zA-Z_][\w]*$/.test(id)) {
|
|
114
|
+
throw new NetlistParseError(`Invalid component id: "${id}"`, lineIdx + 1);
|
|
115
|
+
}
|
|
116
|
+
let cursor = 1;
|
|
117
|
+
const netRefs = [];
|
|
118
|
+
while (cursor < tokens.length && !isKeyEqVal(tokens[cursor])) {
|
|
119
|
+
netRefs.push(tokens[cursor]);
|
|
120
|
+
cursor++;
|
|
121
|
+
}
|
|
122
|
+
const kv = {};
|
|
123
|
+
for (; cursor < tokens.length; cursor++) {
|
|
124
|
+
if (!isKeyEqVal(tokens[cursor])) {
|
|
125
|
+
throw new NetlistParseError(
|
|
126
|
+
`Expected key=value after nets, got "${tokens[cursor]}"`,
|
|
127
|
+
lineIdx + 1
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
const [k, v] = parseKV(tokens[cursor]);
|
|
131
|
+
kv[k] = v;
|
|
132
|
+
}
|
|
133
|
+
const prefix = id[0].toUpperCase();
|
|
134
|
+
const defaults = PREFIX_MAP[prefix];
|
|
135
|
+
let cType;
|
|
136
|
+
let pinOrder;
|
|
137
|
+
if (kv.type) {
|
|
138
|
+
const t = kv.type.toLowerCase();
|
|
139
|
+
cType = TYPE_ALIASES[t] ?? t;
|
|
140
|
+
pinOrder = defaults?.pins ?? ["p1", "p2"];
|
|
141
|
+
} else if (defaults) {
|
|
142
|
+
cType = defaults.type;
|
|
143
|
+
pinOrder = defaults.pins;
|
|
144
|
+
} else {
|
|
145
|
+
throw new NetlistParseError(
|
|
146
|
+
`Cannot infer type from id "${id}" \u2014 use type= override`,
|
|
147
|
+
lineIdx + 1
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const expectedPins = pinOrder.length;
|
|
151
|
+
let valueFromTail;
|
|
152
|
+
if (netRefs.length > expectedPins && expectedPins > 0) {
|
|
153
|
+
const tail = netRefs.slice(expectedPins);
|
|
154
|
+
netRefs.length = expectedPins;
|
|
155
|
+
const first = tail[0].toLowerCase();
|
|
156
|
+
if (TYPE_ALIASES[first]) {
|
|
157
|
+
cType = TYPE_ALIASES[first];
|
|
158
|
+
} else if (first === "npn" || first === "pnp" || first === "nmos" || first === "pmos" || first === "jfet_n" || first === "jfet_p" || first === "zener" || first === "schottky" || first === "led" || first === "photodiode") {
|
|
159
|
+
cType = first;
|
|
160
|
+
if (first === "pnp") pinOrder = ["c", "b", "e"];
|
|
161
|
+
if (first === "pmos" || first === "jfet_p") pinOrder = ["d", "g", "s"];
|
|
162
|
+
} else {
|
|
163
|
+
valueFromTail = tail.join(" ");
|
|
164
|
+
}
|
|
165
|
+
if (tail.length > 1 && !valueFromTail) {
|
|
166
|
+
valueFromTail = tail.slice(1).join(" ");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (cType === "ground" || cType === "gnd_signal" || cType === "gnd_chassis" || cType === "gnd_digital") {
|
|
170
|
+
pinOrder = ["start"];
|
|
171
|
+
}
|
|
172
|
+
if (netRefs.length < pinOrder.length) {
|
|
173
|
+
throw new NetlistParseError(
|
|
174
|
+
`Component ${id} (${cType}) expects ${pinOrder.length} nets, got ${netRefs.length}`,
|
|
175
|
+
lineIdx + 1
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const pins = {};
|
|
179
|
+
for (let p = 0; p < pinOrder.length; p++) {
|
|
180
|
+
let net = netRefs[p];
|
|
181
|
+
if (GROUND_NETS.has(net)) net = "GND";
|
|
182
|
+
pins[pinOrder[p]] = net;
|
|
183
|
+
ensureNet(net).anchors.push(`${id}.${pinOrder[p]}`);
|
|
184
|
+
}
|
|
185
|
+
pinMap[id] = pins;
|
|
186
|
+
const comp = {
|
|
187
|
+
id,
|
|
188
|
+
componentType: cType,
|
|
189
|
+
direction: "right",
|
|
190
|
+
label: kv.label ?? id,
|
|
191
|
+
value: kv.value ?? valueFromTail,
|
|
192
|
+
attrs: {}
|
|
193
|
+
};
|
|
194
|
+
for (const [k, v] of Object.entries(kv)) {
|
|
195
|
+
if (k === "label" || k === "value" || k === "type") continue;
|
|
196
|
+
comp.attrs[k] = v;
|
|
197
|
+
}
|
|
198
|
+
components.push(comp);
|
|
199
|
+
}
|
|
200
|
+
if (netByName.has("GND")) {
|
|
201
|
+
const hasGroundSym = components.some(
|
|
202
|
+
(c) => c.componentType === "ground" || c.componentType === "gnd_signal" || c.componentType === "gnd_chassis" || c.componentType === "gnd_digital"
|
|
203
|
+
);
|
|
204
|
+
if (!hasGroundSym) {
|
|
205
|
+
const gId = `_GND${autoGnd++}`;
|
|
206
|
+
components.push({
|
|
207
|
+
id: gId,
|
|
208
|
+
componentType: "ground",
|
|
209
|
+
direction: "down",
|
|
210
|
+
label: void 0,
|
|
211
|
+
value: void 0,
|
|
212
|
+
attrs: { auto: "true" }
|
|
213
|
+
});
|
|
214
|
+
pinMap[gId] = { start: "GND" };
|
|
215
|
+
ensureNet("GND").anchors.push(`${gId}.start`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const nets = Array.from(netByName.values());
|
|
219
|
+
return {
|
|
220
|
+
type: "circuit",
|
|
221
|
+
title: title2,
|
|
222
|
+
components,
|
|
223
|
+
nets,
|
|
224
|
+
pinMap,
|
|
225
|
+
mode: "netlist"
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/diagrams/circuit/parser.ts
|
|
230
|
+
var CircuitParseError = class extends Error {
|
|
231
|
+
constructor(message) {
|
|
232
|
+
super(message);
|
|
233
|
+
this.name = "CircuitParseError";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var COMPONENT_TYPES = /* @__PURE__ */ new Set([
|
|
237
|
+
"resistor",
|
|
238
|
+
"potentiometer",
|
|
239
|
+
"rheostat",
|
|
240
|
+
"thermistor_ntc",
|
|
241
|
+
"thermistor_ptc",
|
|
242
|
+
"ldr",
|
|
243
|
+
"varistor",
|
|
244
|
+
"fuse",
|
|
245
|
+
"fuse_slow",
|
|
246
|
+
"capacitor",
|
|
247
|
+
"electrolytic_cap",
|
|
248
|
+
"variable_cap",
|
|
249
|
+
"inductor",
|
|
250
|
+
"inductor_iron",
|
|
251
|
+
"inductor_ferrite",
|
|
252
|
+
"variable_inductor",
|
|
253
|
+
"ferrite_bead",
|
|
254
|
+
"crystal",
|
|
255
|
+
"transformer",
|
|
256
|
+
"diode",
|
|
257
|
+
"zener",
|
|
258
|
+
"schottky",
|
|
259
|
+
"led",
|
|
260
|
+
"photodiode",
|
|
261
|
+
"varactor",
|
|
262
|
+
"tvs_diode",
|
|
263
|
+
"bridge_rectifier",
|
|
264
|
+
"npn",
|
|
265
|
+
"pnp",
|
|
266
|
+
"darlington_npn",
|
|
267
|
+
"darlington_pnp",
|
|
268
|
+
"nmos",
|
|
269
|
+
"pmos",
|
|
270
|
+
"nmos_depletion",
|
|
271
|
+
"jfet_n",
|
|
272
|
+
"jfet_p",
|
|
273
|
+
"igbt",
|
|
274
|
+
"scr",
|
|
275
|
+
"triac",
|
|
276
|
+
"diac",
|
|
277
|
+
"phototransistor",
|
|
278
|
+
"optocoupler",
|
|
279
|
+
"opamp",
|
|
280
|
+
"comparator",
|
|
281
|
+
"schmitt_buffer",
|
|
282
|
+
"tri_state_buffer",
|
|
283
|
+
"instrumentation_amp",
|
|
284
|
+
"generic_ic",
|
|
285
|
+
"voltage_regulator",
|
|
286
|
+
"dc_dc_converter",
|
|
287
|
+
"555_timer",
|
|
288
|
+
"voltage_source",
|
|
289
|
+
"current_source",
|
|
290
|
+
"ac_source",
|
|
291
|
+
"battery",
|
|
292
|
+
"vcc",
|
|
293
|
+
"ground",
|
|
294
|
+
"gnd_signal",
|
|
295
|
+
"gnd_chassis",
|
|
296
|
+
"gnd_digital",
|
|
297
|
+
"switch_spst",
|
|
298
|
+
"switch_spdt",
|
|
299
|
+
"switch_dpdt",
|
|
300
|
+
"push_no",
|
|
301
|
+
"push_nc",
|
|
302
|
+
"relay_coil",
|
|
303
|
+
"relay_no",
|
|
304
|
+
"relay_nc",
|
|
305
|
+
"motor",
|
|
306
|
+
"speaker",
|
|
307
|
+
"microphone",
|
|
308
|
+
"buzzer",
|
|
309
|
+
"ammeter",
|
|
310
|
+
"voltmeter",
|
|
311
|
+
"wattmeter",
|
|
312
|
+
"oscilloscope",
|
|
313
|
+
"wire",
|
|
314
|
+
"dot",
|
|
315
|
+
"label",
|
|
316
|
+
"port",
|
|
317
|
+
"test_point",
|
|
318
|
+
"no_connect",
|
|
319
|
+
"antenna"
|
|
320
|
+
]);
|
|
321
|
+
var ALIASES = {
|
|
322
|
+
vsource: "voltage_source",
|
|
323
|
+
isource: "current_source",
|
|
324
|
+
acsource: "ac_source",
|
|
325
|
+
ecap: "electrolytic_cap",
|
|
326
|
+
pot: "potentiometer",
|
|
327
|
+
xtal: "crystal",
|
|
328
|
+
xfmr: "transformer",
|
|
329
|
+
transistor: "npn",
|
|
330
|
+
bjt_npn: "npn",
|
|
331
|
+
bjt_pnp: "pnp",
|
|
332
|
+
mosfet_n: "nmos",
|
|
333
|
+
mosfet_p: "pmos",
|
|
334
|
+
gnd: "ground",
|
|
335
|
+
ic: "generic_ic",
|
|
336
|
+
reg: "voltage_regulator",
|
|
337
|
+
timer555: "555_timer",
|
|
338
|
+
therm: "thermistor_ntc",
|
|
339
|
+
ntc: "thermistor_ntc",
|
|
340
|
+
ptc: "thermistor_ptc",
|
|
341
|
+
ths: "thermistor_ntc"
|
|
342
|
+
};
|
|
343
|
+
var EXTRA_TYPES = /* @__PURE__ */ new Set(["lamp"]);
|
|
344
|
+
function normalizeType(raw) {
|
|
345
|
+
const lower = raw.toLowerCase();
|
|
346
|
+
if (ALIASES[lower]) return ALIASES[lower];
|
|
347
|
+
if (COMPONENT_TYPES.has(lower)) {
|
|
348
|
+
return lower;
|
|
349
|
+
}
|
|
350
|
+
if (EXTRA_TYPES.has(lower)) {
|
|
351
|
+
return lower;
|
|
352
|
+
}
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
var DIRECTIONS = /* @__PURE__ */ new Set(["right", "left", "up", "down"]);
|
|
356
|
+
function parseAttrs(rest) {
|
|
357
|
+
const out = { attrs: {} };
|
|
358
|
+
const tokens = [];
|
|
359
|
+
let i = 0;
|
|
360
|
+
while (i < rest.length) {
|
|
361
|
+
const ch = rest[i];
|
|
362
|
+
if (ch === " " || ch === " ") {
|
|
363
|
+
i++;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (ch === '"') {
|
|
367
|
+
const end = rest.indexOf('"', i + 1);
|
|
368
|
+
const tok = rest.slice(i, end < 0 ? rest.length : end + 1);
|
|
369
|
+
tokens.push(tok);
|
|
370
|
+
i = end < 0 ? rest.length : end + 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
let j = i;
|
|
374
|
+
while (j < rest.length && rest[j] !== " " && rest[j] !== " ") {
|
|
375
|
+
if (rest[j] === "=" && rest[j + 1] === '"') {
|
|
376
|
+
const end = rest.indexOf('"', j + 2);
|
|
377
|
+
j = end < 0 ? rest.length : end + 1;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
j++;
|
|
381
|
+
}
|
|
382
|
+
tokens.push(rest.slice(i, j));
|
|
383
|
+
i = j;
|
|
384
|
+
}
|
|
385
|
+
for (const tok of tokens) {
|
|
386
|
+
if (!tok) continue;
|
|
387
|
+
if (DIRECTIONS.has(tok.toLowerCase())) {
|
|
388
|
+
out.direction = tok.toLowerCase();
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
const eq = tok.indexOf("=");
|
|
392
|
+
if (eq > 0) {
|
|
393
|
+
const key = tok.slice(0, eq).trim();
|
|
394
|
+
let val = tok.slice(eq + 1).trim();
|
|
395
|
+
if (val.startsWith('"') && val.endsWith('"')) {
|
|
396
|
+
val = val.slice(1, -1);
|
|
397
|
+
}
|
|
398
|
+
if (key === "label") out.label = val;
|
|
399
|
+
else if (key === "value") out.value = val;
|
|
400
|
+
else if (key === "at") out.at = val;
|
|
401
|
+
else if (key === "length") out.length = val;
|
|
402
|
+
else out.attrs[key] = val;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
out.attrs[tok] = "true";
|
|
406
|
+
}
|
|
407
|
+
return out;
|
|
408
|
+
}
|
|
409
|
+
function parseCircuit(text2) {
|
|
410
|
+
const rawLines = text2.split("\n");
|
|
411
|
+
const firstMeaningful = rawLines.map((l) => l.replace(/#.*$/, "").trim()).find((l) => l.length > 0) ?? "";
|
|
412
|
+
if (/^circuit\b.*\bnetlist\s*$/i.test(firstMeaningful)) {
|
|
413
|
+
const titleMatch = firstMeaningful.match(/"([^"]*)"/);
|
|
414
|
+
let headerIdx = -1;
|
|
415
|
+
for (let i = 0; i < rawLines.length; i++) {
|
|
416
|
+
const s = rawLines[i].replace(/#.*$/, "").trim();
|
|
417
|
+
if (s.length > 0) {
|
|
418
|
+
headerIdx = i;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
const body = rawLines.slice(headerIdx + 1).join("\n");
|
|
423
|
+
return parseNetlist(body, titleMatch?.[1]);
|
|
424
|
+
}
|
|
425
|
+
const lines = text2.split("\n").map((l) => l.replace(/\r$/, ""));
|
|
426
|
+
let title2;
|
|
427
|
+
const components = [];
|
|
428
|
+
const nets = [];
|
|
429
|
+
const netByName = /* @__PURE__ */ new Map();
|
|
430
|
+
let autoId = 0;
|
|
431
|
+
let pendingAt;
|
|
432
|
+
const mkId = (prefix) => `${prefix}_${autoId++}`;
|
|
433
|
+
for (const rawLine of lines) {
|
|
434
|
+
const stripped = rawLine.replace(/#.*$/, "").trim();
|
|
435
|
+
if (!stripped) continue;
|
|
436
|
+
if (/^circuit\b/i.test(stripped)) {
|
|
437
|
+
const t = stripped.match(/"([^"]*)"/);
|
|
438
|
+
if (t) title2 = t[1];
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const atMatch = stripped.match(/^at:\s*(.+)$/i);
|
|
442
|
+
if (atMatch) {
|
|
443
|
+
pendingAt = atMatch[1].trim();
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
const netDecl = stripped.match(/^net\s+([a-zA-Z_][\w]*)\s*$/i);
|
|
447
|
+
if (netDecl) {
|
|
448
|
+
const name = netDecl[1];
|
|
449
|
+
if (!netByName.has(name)) {
|
|
450
|
+
const n = { id: name, anchors: [] };
|
|
451
|
+
netByName.set(name, n);
|
|
452
|
+
nets.push(n);
|
|
453
|
+
}
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
const netDotMatch = stripped.match(/^net\s+([a-zA-Z_][\w]*)\s*:\s*dot\s*$/i);
|
|
457
|
+
if (netDotMatch) {
|
|
458
|
+
const name = netDotMatch[1];
|
|
459
|
+
let n = netByName.get(name);
|
|
460
|
+
if (!n) {
|
|
461
|
+
n = { id: name, anchors: [] };
|
|
462
|
+
netByName.set(name, n);
|
|
463
|
+
nets.push(n);
|
|
464
|
+
}
|
|
465
|
+
const id = mkId("dot");
|
|
466
|
+
components.push({
|
|
467
|
+
id,
|
|
468
|
+
componentType: "dot",
|
|
469
|
+
direction: "right",
|
|
470
|
+
at: pendingAt,
|
|
471
|
+
attrs: { net: name }
|
|
472
|
+
});
|
|
473
|
+
n.anchors.push(`${id}.end`);
|
|
474
|
+
pendingAt = `${id}.end`;
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const labelMatch = stripped.match(/^label\s+"([^"]*)"(?:\s+(right|left|up|down))?\s*$/i);
|
|
478
|
+
if (labelMatch) {
|
|
479
|
+
const id = mkId("lbl");
|
|
480
|
+
components.push({
|
|
481
|
+
id,
|
|
482
|
+
componentType: "label",
|
|
483
|
+
direction: labelMatch[2]?.toLowerCase() ?? "right",
|
|
484
|
+
at: pendingAt,
|
|
485
|
+
label: labelMatch[1]
|
|
486
|
+
});
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
const wireMatch = stripped.match(/^wire(?:\s+(right|left|up|down))?(?:\s+(\d+)(?:px)?)?\s*$/i);
|
|
490
|
+
if (wireMatch) {
|
|
491
|
+
const id = mkId("w");
|
|
492
|
+
components.push({
|
|
493
|
+
id,
|
|
494
|
+
componentType: "wire",
|
|
495
|
+
direction: wireMatch[1]?.toLowerCase() ?? "right",
|
|
496
|
+
at: pendingAt,
|
|
497
|
+
attrs: wireMatch[2] ? { length: wireMatch[2] } : {}
|
|
498
|
+
});
|
|
499
|
+
pendingAt = `${id}.end`;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
const bareMatch = stripped.match(/^([a-zA-Z_][\w]*)(\s+.*)?$/);
|
|
503
|
+
const colonMatch = stripped.match(/^([a-zA-Z_][\w]*)\s*:\s*([a-zA-Z_][\w]*)(\s+.*)?$/);
|
|
504
|
+
if (colonMatch) {
|
|
505
|
+
const id = colonMatch[1];
|
|
506
|
+
const typeStr = colonMatch[2];
|
|
507
|
+
const norm = normalizeType(typeStr);
|
|
508
|
+
if (!norm) {
|
|
509
|
+
throw new CircuitParseError(`Unknown component type: ${typeStr}`);
|
|
510
|
+
}
|
|
511
|
+
const rest = colonMatch[3] ?? "";
|
|
512
|
+
const parsed = parseAttrs(rest);
|
|
513
|
+
const comp = {
|
|
514
|
+
id,
|
|
515
|
+
componentType: norm,
|
|
516
|
+
direction: parsed.direction ?? "right",
|
|
517
|
+
at: parsed.at ?? pendingAt,
|
|
518
|
+
label: parsed.label,
|
|
519
|
+
value: parsed.value,
|
|
520
|
+
attrs: parsed.attrs
|
|
521
|
+
};
|
|
522
|
+
if (parsed.length) {
|
|
523
|
+
comp.attrs = { ...comp.attrs, length: parsed.length };
|
|
524
|
+
}
|
|
525
|
+
components.push(comp);
|
|
526
|
+
pendingAt = `${id}.end`;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (bareMatch) {
|
|
530
|
+
const typeStr = bareMatch[1];
|
|
531
|
+
const norm = normalizeType(typeStr);
|
|
532
|
+
if (!norm) {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const rest = bareMatch[2] ?? "";
|
|
536
|
+
const parsed = parseAttrs(rest);
|
|
537
|
+
const id = mkId(norm);
|
|
538
|
+
const comp = {
|
|
539
|
+
id,
|
|
540
|
+
componentType: norm,
|
|
541
|
+
direction: parsed.direction ?? "right",
|
|
542
|
+
at: parsed.at ?? pendingAt,
|
|
543
|
+
label: parsed.label,
|
|
544
|
+
value: parsed.value,
|
|
545
|
+
attrs: parsed.attrs
|
|
546
|
+
};
|
|
547
|
+
components.push(comp);
|
|
548
|
+
pendingAt = `${id}.end`;
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
type: "circuit",
|
|
554
|
+
title: title2,
|
|
555
|
+
components,
|
|
556
|
+
nets,
|
|
557
|
+
mode: "positional"
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/diagrams/circuit/symbols.ts
|
|
562
|
+
var BODY = 'class="schematex-circuit-body"';
|
|
563
|
+
var FILL = 'class="schematex-circuit-fill"';
|
|
564
|
+
var WIRE = 'class="schematex-circuit-wire"';
|
|
565
|
+
function lineWire(x1, y1, x2, y2) {
|
|
566
|
+
return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" ${WIRE}/>`;
|
|
567
|
+
}
|
|
568
|
+
var resistor = {
|
|
569
|
+
length: 40,
|
|
570
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
571
|
+
svg: () => `<path d="M 0,0 L 5,0 L 8,-8 L 12,8 L 16,-8 L 20,8 L 24,-8 L 28,8 L 32,-8 L 35,0 L 40,0" ${BODY}/>`
|
|
572
|
+
};
|
|
573
|
+
var capacitor = {
|
|
574
|
+
length: 20,
|
|
575
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
576
|
+
svg: () => [
|
|
577
|
+
lineWire(0, 0, 8, 0),
|
|
578
|
+
`<line x1="8" y1="-10" x2="8" y2="10" ${BODY}/>`,
|
|
579
|
+
`<line x1="12" y1="-10" x2="12" y2="10" ${BODY}/>`,
|
|
580
|
+
lineWire(12, 0, 20, 0)
|
|
581
|
+
].join("")
|
|
582
|
+
};
|
|
583
|
+
var electrolytic_cap = {
|
|
584
|
+
length: 20,
|
|
585
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
586
|
+
svg: () => [
|
|
587
|
+
lineWire(0, 0, 8, 0),
|
|
588
|
+
`<line x1="8" y1="-10" x2="8" y2="10" ${BODY}/>`,
|
|
589
|
+
`<path d="M 12,-10 Q 16,0 12,10" fill="none" class="schematex-circuit-body"/>`,
|
|
590
|
+
lineWire(12, 0, 20, 0),
|
|
591
|
+
`<text x="5" y="-12" class="schematex-circuit-pol">\u2212</text>`,
|
|
592
|
+
`<text x="15" y="-12" class="schematex-circuit-pol">+</text>`
|
|
593
|
+
].join("")
|
|
594
|
+
};
|
|
595
|
+
var inductor = {
|
|
596
|
+
length: 40,
|
|
597
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
598
|
+
svg: () => `<path d="M 0,0 L 5,0 A 5,5 0 0 1 15,0 A 5,5 0 0 1 25,0 A 5,5 0 0 1 35,0 L 40,0" fill="none" ${BODY}/>`
|
|
599
|
+
};
|
|
600
|
+
var fuse = {
|
|
601
|
+
length: 30,
|
|
602
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
603
|
+
svg: () => [
|
|
604
|
+
lineWire(0, 0, 5, 0),
|
|
605
|
+
`<rect x="5" y="-5" width="20" height="10" rx="5" fill="none" ${BODY}/>`,
|
|
606
|
+
`<line x1="5" y1="0" x2="25" y2="0" ${BODY}/>`,
|
|
607
|
+
lineWire(25, 0, 30, 0)
|
|
608
|
+
].join("")
|
|
609
|
+
};
|
|
610
|
+
var crystal = {
|
|
611
|
+
length: 40,
|
|
612
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
613
|
+
svg: () => [
|
|
614
|
+
lineWire(0, 0, 10, 0),
|
|
615
|
+
`<line x1="10" y1="-9" x2="10" y2="9" ${BODY}/>`,
|
|
616
|
+
`<rect x="14" y="-7" width="12" height="14" fill="none" ${BODY}/>`,
|
|
617
|
+
`<line x1="30" y1="-9" x2="30" y2="9" ${BODY}/>`,
|
|
618
|
+
lineWire(30, 0, 40, 0)
|
|
619
|
+
].join("")
|
|
620
|
+
};
|
|
621
|
+
var transformer = {
|
|
622
|
+
length: 60,
|
|
623
|
+
anchors: {
|
|
624
|
+
start: { x: 0, y: 0 },
|
|
625
|
+
end: { x: 60, y: 0 },
|
|
626
|
+
p1: { x: 0, y: 0 },
|
|
627
|
+
p2: { x: 0, y: 0 },
|
|
628
|
+
s1: { x: 60, y: 0 },
|
|
629
|
+
s2: { x: 60, y: 0 }
|
|
630
|
+
},
|
|
631
|
+
svg: () => [
|
|
632
|
+
// Primary coils (left)
|
|
633
|
+
`<path d="M 5,-18 A 5,5 0 0 1 5,-8 A 5,5 0 0 1 5,2 A 5,5 0 0 1 5,12 A 5,5 0 0 1 5,22" fill="none" ${BODY}/>`,
|
|
634
|
+
lineWire(0, 0, 5, 0),
|
|
635
|
+
// Core lines
|
|
636
|
+
`<line x1="28" y1="-20" x2="28" y2="22" ${BODY}/>`,
|
|
637
|
+
`<line x1="32" y1="-20" x2="32" y2="22" ${BODY}/>`,
|
|
638
|
+
// Secondary coils (right)
|
|
639
|
+
`<path d="M 55,-18 A 5,5 0 0 0 55,-8 A 5,5 0 0 0 55,2 A 5,5 0 0 0 55,12 A 5,5 0 0 0 55,22" fill="none" ${BODY}/>`,
|
|
640
|
+
lineWire(55, 0, 60, 0)
|
|
641
|
+
].join("")
|
|
642
|
+
};
|
|
643
|
+
var voltage_source = {
|
|
644
|
+
length: 40,
|
|
645
|
+
// plus/minus aliases: end = +, start = − (matches on-symbol label)
|
|
646
|
+
anchors: {
|
|
647
|
+
start: { x: 0, y: 0 },
|
|
648
|
+
end: { x: 40, y: 0 },
|
|
649
|
+
minus: { x: 0, y: 0 },
|
|
650
|
+
plus: { x: 40, y: 0 }
|
|
651
|
+
},
|
|
652
|
+
svg: () => [
|
|
653
|
+
lineWire(0, 0, 8, 0),
|
|
654
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
655
|
+
`<text x="16" y="-2" class="schematex-circuit-pol">+</text>`,
|
|
656
|
+
`<text x="23" y="8" class="schematex-circuit-pol">\u2212</text>`,
|
|
657
|
+
lineWire(32, 0, 40, 0)
|
|
658
|
+
].join("")
|
|
659
|
+
};
|
|
660
|
+
var current_source = {
|
|
661
|
+
length: 40,
|
|
662
|
+
anchors: {
|
|
663
|
+
start: { x: 0, y: 0 },
|
|
664
|
+
end: { x: 40, y: 0 },
|
|
665
|
+
minus: { x: 0, y: 0 },
|
|
666
|
+
plus: { x: 40, y: 0 }
|
|
667
|
+
},
|
|
668
|
+
svg: () => [
|
|
669
|
+
lineWire(0, 0, 8, 0),
|
|
670
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
671
|
+
`<line x1="14" y1="0" x2="24" y2="0" ${BODY}/>`,
|
|
672
|
+
`<polygon points="26,0 20,-4 20,4" ${FILL}/>`,
|
|
673
|
+
lineWire(32, 0, 40, 0)
|
|
674
|
+
].join("")
|
|
675
|
+
};
|
|
676
|
+
var ac_source = {
|
|
677
|
+
length: 40,
|
|
678
|
+
anchors: {
|
|
679
|
+
start: { x: 0, y: 0 },
|
|
680
|
+
end: { x: 40, y: 0 },
|
|
681
|
+
minus: { x: 0, y: 0 },
|
|
682
|
+
plus: { x: 40, y: 0 }
|
|
683
|
+
},
|
|
684
|
+
svg: () => [
|
|
685
|
+
lineWire(0, 0, 8, 0),
|
|
686
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
687
|
+
`<path d="M 14,0 Q 17,-6 20,0 Q 23,6 26,0" fill="none" ${BODY}/>`,
|
|
688
|
+
lineWire(32, 0, 40, 0)
|
|
689
|
+
].join("")
|
|
690
|
+
};
|
|
691
|
+
var battery = {
|
|
692
|
+
length: 24,
|
|
693
|
+
anchors: {
|
|
694
|
+
start: { x: 0, y: 0 },
|
|
695
|
+
end: { x: 24, y: 0 },
|
|
696
|
+
minus: { x: 0, y: 0 },
|
|
697
|
+
plus: { x: 24, y: 0 }
|
|
698
|
+
},
|
|
699
|
+
svg: () => [
|
|
700
|
+
lineWire(0, 0, 8, 0),
|
|
701
|
+
`<line x1="8" y1="-8" x2="8" y2="8" ${BODY}/>`,
|
|
702
|
+
`<line x1="12" y1="-4" x2="12" y2="4" ${BODY}/>`,
|
|
703
|
+
`<line x1="14" y1="-8" x2="14" y2="8" ${BODY}/>`,
|
|
704
|
+
`<line x1="18" y1="-4" x2="18" y2="4" ${BODY}/>`,
|
|
705
|
+
lineWire(18, 0, 24, 0)
|
|
706
|
+
].join("")
|
|
707
|
+
};
|
|
708
|
+
var ground = {
|
|
709
|
+
length: 20,
|
|
710
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
711
|
+
// Drawn as a "terminal" — vertical connection at start, earth lines below
|
|
712
|
+
svg: () => [
|
|
713
|
+
`<line x1="0" y1="0" x2="10" y2="0" ${WIRE}/>`,
|
|
714
|
+
`<line x1="10" y1="-8" x2="10" y2="8" ${BODY}/>`,
|
|
715
|
+
`<line x1="6" y1="4" x2="14" y2="4" ${BODY}/>`,
|
|
716
|
+
`<line x1="8" y1="8" x2="12" y2="8" ${BODY}/>`
|
|
717
|
+
].join("")
|
|
718
|
+
};
|
|
719
|
+
var gnd_signal = {
|
|
720
|
+
length: 20,
|
|
721
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
722
|
+
svg: () => [
|
|
723
|
+
`<line x1="0" y1="0" x2="8" y2="0" ${WIRE}/>`,
|
|
724
|
+
`<polygon points="8,-6 8,6 16,0" ${FILL}/>`
|
|
725
|
+
].join("")
|
|
726
|
+
};
|
|
727
|
+
var vcc = {
|
|
728
|
+
length: 20,
|
|
729
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
730
|
+
svg: () => [
|
|
731
|
+
`<line x1="0" y1="0" x2="10" y2="0" ${WIRE}/>`,
|
|
732
|
+
`<line x1="4" y1="-6" x2="16" y2="-6" ${BODY}/>`
|
|
733
|
+
].join("")
|
|
734
|
+
};
|
|
735
|
+
var diode = {
|
|
736
|
+
length: 30,
|
|
737
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
738
|
+
svg: () => [
|
|
739
|
+
lineWire(0, 0, 8, 0),
|
|
740
|
+
`<polygon points="8,-8 8,8 22,0" ${FILL}/>`,
|
|
741
|
+
`<line x1="22" y1="-8" x2="22" y2="8" ${BODY}/>`,
|
|
742
|
+
lineWire(22, 0, 30, 0)
|
|
743
|
+
].join("")
|
|
744
|
+
};
|
|
745
|
+
var zener = {
|
|
746
|
+
length: 30,
|
|
747
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
748
|
+
svg: () => [
|
|
749
|
+
lineWire(0, 0, 8, 0),
|
|
750
|
+
`<polygon points="8,-8 8,8 22,0" ${FILL}/>`,
|
|
751
|
+
`<path d="M 18,-10 L 22,-8 L 22,8 L 26,10" fill="none" ${BODY}/>`,
|
|
752
|
+
lineWire(22, 0, 30, 0)
|
|
753
|
+
].join("")
|
|
754
|
+
};
|
|
755
|
+
var schottky = {
|
|
756
|
+
length: 30,
|
|
757
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
758
|
+
svg: () => [
|
|
759
|
+
lineWire(0, 0, 8, 0),
|
|
760
|
+
`<polygon points="8,-8 8,8 22,0" ${FILL}/>`,
|
|
761
|
+
`<path d="M 18,-4 L 18,-8 L 22,-8 L 22,8 L 26,8 L 26,4" fill="none" ${BODY}/>`,
|
|
762
|
+
lineWire(22, 0, 30, 0)
|
|
763
|
+
].join("")
|
|
764
|
+
};
|
|
765
|
+
var led = {
|
|
766
|
+
length: 30,
|
|
767
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
768
|
+
svg: () => [
|
|
769
|
+
lineWire(0, 0, 8, 0),
|
|
770
|
+
`<polygon points="8,-8 8,8 22,0" ${FILL}/>`,
|
|
771
|
+
`<line x1="22" y1="-8" x2="22" y2="8" ${BODY}/>`,
|
|
772
|
+
lineWire(22, 0, 30, 0),
|
|
773
|
+
// outward light arrows
|
|
774
|
+
`<path d="M 12,-10 L 20,-18 M 18,-18 L 20,-18 L 20,-16" fill="none" ${BODY}/>`,
|
|
775
|
+
`<path d="M 16,-10 L 24,-18 M 22,-18 L 24,-18 L 24,-16" fill="none" ${BODY}/>`
|
|
776
|
+
].join("")
|
|
777
|
+
};
|
|
778
|
+
var photodiode = {
|
|
779
|
+
length: 30,
|
|
780
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
781
|
+
svg: () => [
|
|
782
|
+
lineWire(0, 0, 8, 0),
|
|
783
|
+
`<polygon points="8,-8 8,8 22,0" ${FILL}/>`,
|
|
784
|
+
`<line x1="22" y1="-8" x2="22" y2="8" ${BODY}/>`,
|
|
785
|
+
lineWire(22, 0, 30, 0),
|
|
786
|
+
// inward light arrows
|
|
787
|
+
`<path d="M 20,-18 L 12,-10 M 12,-12 L 12,-10 L 14,-10" fill="none" ${BODY}/>`,
|
|
788
|
+
`<path d="M 24,-18 L 16,-10 M 16,-12 L 16,-10 L 18,-10" fill="none" ${BODY}/>`
|
|
789
|
+
].join("")
|
|
790
|
+
};
|
|
791
|
+
var npn = {
|
|
792
|
+
length: 40,
|
|
793
|
+
// base at left, collector up-right, emitter down-right
|
|
794
|
+
anchors: {
|
|
795
|
+
start: { x: 0, y: 0 },
|
|
796
|
+
end: { x: 40, y: -16 },
|
|
797
|
+
base: { x: 0, y: 0 },
|
|
798
|
+
collector: { x: 40, y: -16 },
|
|
799
|
+
emitter: { x: 40, y: 16 },
|
|
800
|
+
b: { x: 0, y: 0 },
|
|
801
|
+
c: { x: 40, y: -16 },
|
|
802
|
+
e: { x: 40, y: 16 }
|
|
803
|
+
},
|
|
804
|
+
svg: () => [
|
|
805
|
+
`<circle cx="20" cy="0" r="16" fill="white" ${BODY}/>`,
|
|
806
|
+
`<line x1="14" y1="-10" x2="14" y2="10" ${BODY}/>`,
|
|
807
|
+
lineWire(0, 0, 14, 0),
|
|
808
|
+
`<line x1="14" y1="-6" x2="30" y2="-12" ${BODY}/>`,
|
|
809
|
+
lineWire(30, -12, 40, -16),
|
|
810
|
+
`<line x1="14" y1="6" x2="30" y2="12" ${BODY}/>`,
|
|
811
|
+
lineWire(30, 12, 40, 16),
|
|
812
|
+
// NPN arrow (outward on emitter)
|
|
813
|
+
`<polygon points="30,12 24,10 26,16" ${FILL}/>`
|
|
814
|
+
].join("")
|
|
815
|
+
};
|
|
816
|
+
var pnp = {
|
|
817
|
+
length: 40,
|
|
818
|
+
anchors: {
|
|
819
|
+
start: { x: 0, y: 0 },
|
|
820
|
+
end: { x: 40, y: -16 },
|
|
821
|
+
base: { x: 0, y: 0 },
|
|
822
|
+
collector: { x: 40, y: 16 },
|
|
823
|
+
emitter: { x: 40, y: -16 },
|
|
824
|
+
b: { x: 0, y: 0 },
|
|
825
|
+
c: { x: 40, y: 16 },
|
|
826
|
+
e: { x: 40, y: -16 }
|
|
827
|
+
},
|
|
828
|
+
svg: () => [
|
|
829
|
+
`<circle cx="20" cy="0" r="16" fill="white" ${BODY}/>`,
|
|
830
|
+
`<line x1="14" y1="-10" x2="14" y2="10" ${BODY}/>`,
|
|
831
|
+
lineWire(0, 0, 14, 0),
|
|
832
|
+
`<line x1="14" y1="-6" x2="30" y2="-12" ${BODY}/>`,
|
|
833
|
+
lineWire(30, -12, 40, -16),
|
|
834
|
+
`<line x1="14" y1="6" x2="30" y2="12" ${BODY}/>`,
|
|
835
|
+
lineWire(30, 12, 40, 16),
|
|
836
|
+
// PNP arrow (inward on emitter → toward base line)
|
|
837
|
+
`<polygon points="14,-6 20,-4 18,-10" ${FILL}/>`
|
|
838
|
+
].join("")
|
|
839
|
+
};
|
|
840
|
+
var nmos = {
|
|
841
|
+
length: 40,
|
|
842
|
+
anchors: {
|
|
843
|
+
start: { x: 0, y: 0 },
|
|
844
|
+
end: { x: 40, y: -16 },
|
|
845
|
+
gate: { x: 0, y: 0 },
|
|
846
|
+
drain: { x: 40, y: -16 },
|
|
847
|
+
source: { x: 40, y: 16 },
|
|
848
|
+
g: { x: 0, y: 0 },
|
|
849
|
+
d: { x: 40, y: -16 },
|
|
850
|
+
s: { x: 40, y: 16 }
|
|
851
|
+
},
|
|
852
|
+
svg: () => [
|
|
853
|
+
lineWire(0, 0, 14, 0),
|
|
854
|
+
`<line x1="14" y1="-12" x2="14" y2="12" ${BODY}/>`,
|
|
855
|
+
`<line x1="18" y1="-10" x2="18" y2="-4" ${BODY}/>`,
|
|
856
|
+
`<line x1="18" y1="-2" x2="18" y2="2" ${BODY}/>`,
|
|
857
|
+
`<line x1="18" y1="4" x2="18" y2="10" ${BODY}/>`,
|
|
858
|
+
`<line x1="18" y1="-8" x2="32" y2="-8" ${BODY}/>`,
|
|
859
|
+
lineWire(32, -8, 40, -16),
|
|
860
|
+
`<line x1="18" y1="8" x2="32" y2="8" ${BODY}/>`,
|
|
861
|
+
lineWire(32, 8, 40, 16),
|
|
862
|
+
`<polygon points="22,0 18,-4 18,4" ${FILL}/>`
|
|
863
|
+
].join("")
|
|
864
|
+
};
|
|
865
|
+
var pmos = {
|
|
866
|
+
length: 40,
|
|
867
|
+
anchors: {
|
|
868
|
+
start: { x: 0, y: 0 },
|
|
869
|
+
end: { x: 40, y: -16 },
|
|
870
|
+
gate: { x: 0, y: 0 },
|
|
871
|
+
source: { x: 40, y: -16 },
|
|
872
|
+
drain: { x: 40, y: 16 },
|
|
873
|
+
g: { x: 0, y: 0 },
|
|
874
|
+
s: { x: 40, y: -16 },
|
|
875
|
+
d: { x: 40, y: 16 }
|
|
876
|
+
},
|
|
877
|
+
svg: () => [
|
|
878
|
+
lineWire(0, 0, 14, 0),
|
|
879
|
+
`<line x1="14" y1="-12" x2="14" y2="12" ${BODY}/>`,
|
|
880
|
+
`<line x1="18" y1="-10" x2="18" y2="-4" ${BODY}/>`,
|
|
881
|
+
`<line x1="18" y1="-2" x2="18" y2="2" ${BODY}/>`,
|
|
882
|
+
`<line x1="18" y1="4" x2="18" y2="10" ${BODY}/>`,
|
|
883
|
+
`<line x1="18" y1="-8" x2="32" y2="-8" ${BODY}/>`,
|
|
884
|
+
lineWire(32, -8, 40, -16),
|
|
885
|
+
`<line x1="18" y1="8" x2="32" y2="8" ${BODY}/>`,
|
|
886
|
+
lineWire(32, 8, 40, 16),
|
|
887
|
+
`<polygon points="14,0 18,-4 18,4" ${FILL}/>`
|
|
888
|
+
].join("")
|
|
889
|
+
};
|
|
890
|
+
var jfet_n = {
|
|
891
|
+
length: 40,
|
|
892
|
+
anchors: {
|
|
893
|
+
start: { x: 0, y: 0 },
|
|
894
|
+
end: { x: 40, y: -16 },
|
|
895
|
+
gate: { x: 0, y: 0 },
|
|
896
|
+
drain: { x: 40, y: -16 },
|
|
897
|
+
source: { x: 40, y: 16 }
|
|
898
|
+
},
|
|
899
|
+
svg: () => [
|
|
900
|
+
lineWire(0, 0, 14, 0),
|
|
901
|
+
`<line x1="14" y1="-12" x2="14" y2="12" ${BODY}/>`,
|
|
902
|
+
`<line x1="14" y1="-8" x2="32" y2="-8" ${BODY}/>`,
|
|
903
|
+
lineWire(32, -8, 40, -16),
|
|
904
|
+
`<line x1="14" y1="8" x2="32" y2="8" ${BODY}/>`,
|
|
905
|
+
lineWire(32, 8, 40, 16),
|
|
906
|
+
`<polygon points="14,0 10,-4 10,4" ${FILL}/>`
|
|
907
|
+
].join("")
|
|
908
|
+
};
|
|
909
|
+
var jfet_p = {
|
|
910
|
+
length: 40,
|
|
911
|
+
anchors: {
|
|
912
|
+
start: { x: 0, y: 0 },
|
|
913
|
+
end: { x: 40, y: -16 },
|
|
914
|
+
gate: { x: 0, y: 0 },
|
|
915
|
+
drain: { x: 40, y: -16 },
|
|
916
|
+
source: { x: 40, y: 16 }
|
|
917
|
+
},
|
|
918
|
+
svg: () => [
|
|
919
|
+
lineWire(0, 0, 14, 0),
|
|
920
|
+
`<line x1="14" y1="-12" x2="14" y2="12" ${BODY}/>`,
|
|
921
|
+
`<line x1="14" y1="-8" x2="32" y2="-8" ${BODY}/>`,
|
|
922
|
+
lineWire(32, -8, 40, -16),
|
|
923
|
+
`<line x1="14" y1="8" x2="32" y2="8" ${BODY}/>`,
|
|
924
|
+
lineWire(32, 8, 40, 16),
|
|
925
|
+
`<polygon points="10,0 14,-4 14,4" ${FILL}/>`
|
|
926
|
+
].join("")
|
|
927
|
+
};
|
|
928
|
+
var opamp = {
|
|
929
|
+
length: 50,
|
|
930
|
+
anchors: {
|
|
931
|
+
start: { x: 0, y: 0 },
|
|
932
|
+
end: { x: 50, y: 0 },
|
|
933
|
+
plus: { x: 0, y: -10 },
|
|
934
|
+
minus: { x: 0, y: 10 },
|
|
935
|
+
out: { x: 50, y: 0 },
|
|
936
|
+
"supply+": { x: 25, y: -20 },
|
|
937
|
+
"supply-": { x: 25, y: 20 }
|
|
938
|
+
},
|
|
939
|
+
svg: () => [
|
|
940
|
+
`<polygon points="0,-20 0,20 50,0" fill="white" ${BODY}/>`,
|
|
941
|
+
`<text x="5" y="-6" class="schematex-circuit-pol">+</text>`,
|
|
942
|
+
`<text x="5" y="14" class="schematex-circuit-pol">\u2212</text>`
|
|
943
|
+
].join("")
|
|
944
|
+
};
|
|
945
|
+
var comparator = {
|
|
946
|
+
length: 50,
|
|
947
|
+
anchors: {
|
|
948
|
+
start: { x: 0, y: 0 },
|
|
949
|
+
end: { x: 50, y: 0 },
|
|
950
|
+
plus: { x: 0, y: -10 },
|
|
951
|
+
minus: { x: 0, y: 10 },
|
|
952
|
+
out: { x: 50, y: 0 }
|
|
953
|
+
},
|
|
954
|
+
svg: () => [
|
|
955
|
+
`<polygon points="0,-20 0,20 50,0" fill="white" ${BODY}/>`,
|
|
956
|
+
`<text x="5" y="-6" class="schematex-circuit-pol">+</text>`,
|
|
957
|
+
`<text x="5" y="14" class="schematex-circuit-pol">\u2212</text>`,
|
|
958
|
+
`<circle cx="48" cy="0" r="3" fill="white" ${BODY}/>`
|
|
959
|
+
].join("")
|
|
960
|
+
};
|
|
961
|
+
var switch_spst = {
|
|
962
|
+
length: 40,
|
|
963
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
964
|
+
svg: () => [
|
|
965
|
+
lineWire(0, 0, 10, 0),
|
|
966
|
+
`<line x1="10" y1="0" x2="30" y2="-10" ${BODY}/>`,
|
|
967
|
+
`<circle cx="10" cy="0" r="2" ${FILL}/>`,
|
|
968
|
+
`<circle cx="30" cy="0" r="2" ${FILL}/>`,
|
|
969
|
+
lineWire(30, 0, 40, 0)
|
|
970
|
+
].join("")
|
|
971
|
+
};
|
|
972
|
+
var push_no = {
|
|
973
|
+
length: 40,
|
|
974
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
975
|
+
svg: () => [
|
|
976
|
+
lineWire(0, 0, 12, 0),
|
|
977
|
+
lineWire(28, 0, 40, 0),
|
|
978
|
+
`<circle cx="12" cy="0" r="2" ${FILL}/>`,
|
|
979
|
+
`<circle cx="28" cy="0" r="2" ${FILL}/>`,
|
|
980
|
+
`<line x1="12" y1="-4" x2="28" y2="-4" ${BODY}/>`,
|
|
981
|
+
`<line x1="20" y1="-4" x2="20" y2="-12" ${BODY}/>`,
|
|
982
|
+
`<line x1="14" y1="-12" x2="26" y2="-12" ${BODY}/>`
|
|
983
|
+
].join("")
|
|
984
|
+
};
|
|
985
|
+
var meterSvg = (letter) => () => [
|
|
986
|
+
lineWire(0, 0, 8, 0),
|
|
987
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
988
|
+
`<text x="20" y="4" text-anchor="middle" class="schematex-circuit-meter">${letter}</text>`,
|
|
989
|
+
lineWire(32, 0, 40, 0)
|
|
990
|
+
].join("");
|
|
991
|
+
var ammeter = { length: 40, anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } }, svg: meterSvg("A") };
|
|
992
|
+
var voltmeter = { length: 40, anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } }, svg: meterSvg("V") };
|
|
993
|
+
var wattmeter = { length: 40, anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } }, svg: meterSvg("W") };
|
|
994
|
+
var motor = { length: 40, anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } }, svg: meterSvg("M") };
|
|
995
|
+
var lamp = {
|
|
996
|
+
length: 40,
|
|
997
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
998
|
+
svg: () => [
|
|
999
|
+
lineWire(0, 0, 8, 0),
|
|
1000
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
1001
|
+
`<line x1="12" y1="-8" x2="28" y2="8" ${BODY}/>`,
|
|
1002
|
+
`<line x1="12" y1="8" x2="28" y2="-8" ${BODY}/>`,
|
|
1003
|
+
lineWire(32, 0, 40, 0)
|
|
1004
|
+
].join("")
|
|
1005
|
+
};
|
|
1006
|
+
var buzzer = {
|
|
1007
|
+
length: 40,
|
|
1008
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
1009
|
+
svg: () => [
|
|
1010
|
+
lineWire(0, 0, 8, 0),
|
|
1011
|
+
`<path d="M 8,0 A 12,12 0 0 1 32,0 L 8,0 Z" fill="white" ${BODY}/>`,
|
|
1012
|
+
lineWire(32, 0, 40, 0)
|
|
1013
|
+
].join("")
|
|
1014
|
+
};
|
|
1015
|
+
var speaker = {
|
|
1016
|
+
length: 40,
|
|
1017
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
1018
|
+
svg: () => [
|
|
1019
|
+
lineWire(0, 0, 6, 0),
|
|
1020
|
+
`<rect x="6" y="-8" width="10" height="16" fill="white" ${BODY}/>`,
|
|
1021
|
+
`<path d="M 16,-8 L 28,-16 L 28,16 L 16,8 Z" fill="white" ${BODY}/>`,
|
|
1022
|
+
lineWire(0, 8, 6, 8)
|
|
1023
|
+
].join("")
|
|
1024
|
+
};
|
|
1025
|
+
var microphone = {
|
|
1026
|
+
length: 40,
|
|
1027
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
1028
|
+
svg: () => [
|
|
1029
|
+
lineWire(0, 0, 8, 0),
|
|
1030
|
+
`<circle cx="20" cy="0" r="12" fill="white" ${BODY}/>`,
|
|
1031
|
+
`<line x1="20" y1="-10" x2="20" y2="10" ${BODY}/>`,
|
|
1032
|
+
lineWire(32, 0, 40, 0)
|
|
1033
|
+
].join("")
|
|
1034
|
+
};
|
|
1035
|
+
var rheostat = {
|
|
1036
|
+
length: 50,
|
|
1037
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 50, y: 0 } },
|
|
1038
|
+
svg: () => [
|
|
1039
|
+
`<path d="M 0,0 L 10,0 L 13,-8 L 18,8 L 23,-8 L 28,8 L 33,-8 L 38,8 L 40,0 L 50,0" ${BODY}/>`,
|
|
1040
|
+
`<line x1="5" y1="12" x2="45" y2="-12" ${BODY}/>`,
|
|
1041
|
+
`<polygon points="45,-12 40,-9 44,-5" ${FILL}/>`
|
|
1042
|
+
].join("")
|
|
1043
|
+
};
|
|
1044
|
+
var thermistor_ntc = {
|
|
1045
|
+
length: 50,
|
|
1046
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 50, y: 0 } },
|
|
1047
|
+
svg: () => [
|
|
1048
|
+
`<path d="M 0,0 L 10,0 L 13,-8 L 18,8 L 23,-8 L 28,8 L 33,-8 L 38,8 L 40,0 L 50,0" ${BODY}/>`,
|
|
1049
|
+
`<line x1="5" y1="10" x2="45" y2="-10" ${BODY}/>`,
|
|
1050
|
+
`<text x="40" y="-14" class="schematex-circuit-pol">-t\xB0</text>`
|
|
1051
|
+
].join("")
|
|
1052
|
+
};
|
|
1053
|
+
var thermistor_ptc = {
|
|
1054
|
+
length: 50,
|
|
1055
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 50, y: 0 } },
|
|
1056
|
+
svg: () => [
|
|
1057
|
+
`<path d="M 0,0 L 10,0 L 13,-8 L 18,8 L 23,-8 L 28,8 L 33,-8 L 38,8 L 40,0 L 50,0" ${BODY}/>`,
|
|
1058
|
+
`<line x1="5" y1="10" x2="45" y2="-10" ${BODY}/>`,
|
|
1059
|
+
`<text x="40" y="-14" class="schematex-circuit-pol">+t\xB0</text>`
|
|
1060
|
+
].join("")
|
|
1061
|
+
};
|
|
1062
|
+
var ldr = {
|
|
1063
|
+
length: 50,
|
|
1064
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 50, y: 0 } },
|
|
1065
|
+
svg: () => [
|
|
1066
|
+
`<path d="M 0,0 L 10,0 L 13,-8 L 18,8 L 23,-8 L 28,8 L 33,-8 L 38,8 L 40,0 L 50,0" ${BODY}/>`,
|
|
1067
|
+
`<circle cx="25" cy="-2" r="14" fill="none" ${BODY}/>`,
|
|
1068
|
+
`<path d="M 10,-24 L 18,-16 M 14,-16 L 18,-16 L 18,-20" fill="none" ${BODY}/>`,
|
|
1069
|
+
`<path d="M 20,-24 L 28,-16 M 24,-16 L 28,-16 L 28,-20" fill="none" ${BODY}/>`
|
|
1070
|
+
].join("")
|
|
1071
|
+
};
|
|
1072
|
+
var variable_cap = {
|
|
1073
|
+
length: 24,
|
|
1074
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 24, y: 0 } },
|
|
1075
|
+
svg: () => [
|
|
1076
|
+
lineWire(0, 0, 10, 0),
|
|
1077
|
+
`<line x1="10" y1="-10" x2="10" y2="10" ${BODY}/>`,
|
|
1078
|
+
`<line x1="14" y1="-10" x2="14" y2="10" ${BODY}/>`,
|
|
1079
|
+
lineWire(14, 0, 24, 0),
|
|
1080
|
+
`<line x1="3" y1="10" x2="21" y2="-12" ${BODY}/>`,
|
|
1081
|
+
`<polygon points="21,-12 15,-10 19,-6" ${FILL}/>`
|
|
1082
|
+
].join("")
|
|
1083
|
+
};
|
|
1084
|
+
var variable_inductor = {
|
|
1085
|
+
length: 40,
|
|
1086
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
1087
|
+
svg: () => [
|
|
1088
|
+
`<path d="M 0,0 L 5,0 A 5,5 0 0 1 15,0 A 5,5 0 0 1 25,0 A 5,5 0 0 1 35,0 L 40,0" fill="none" ${BODY}/>`,
|
|
1089
|
+
`<line x1="0" y1="10" x2="38" y2="-14" ${BODY}/>`,
|
|
1090
|
+
`<polygon points="38,-14 32,-12 36,-8" ${FILL}/>`
|
|
1091
|
+
].join("")
|
|
1092
|
+
};
|
|
1093
|
+
var switch_spdt = {
|
|
1094
|
+
length: 50,
|
|
1095
|
+
anchors: {
|
|
1096
|
+
start: { x: 0, y: 0 },
|
|
1097
|
+
end: { x: 50, y: 0 },
|
|
1098
|
+
common: { x: 0, y: 0 },
|
|
1099
|
+
nc: { x: 50, y: -12 },
|
|
1100
|
+
no: { x: 50, y: 12 }
|
|
1101
|
+
},
|
|
1102
|
+
svg: () => [
|
|
1103
|
+
lineWire(0, 0, 10, 0),
|
|
1104
|
+
`<circle cx="10" cy="0" r="2" ${FILL}/>`,
|
|
1105
|
+
`<line x1="10" y1="0" x2="40" y2="-12" ${BODY}/>`,
|
|
1106
|
+
`<circle cx="42" cy="-12" r="2" ${FILL}/>`,
|
|
1107
|
+
lineWire(42, -12, 50, -12),
|
|
1108
|
+
`<circle cx="42" cy="12" r="2" ${FILL}/>`,
|
|
1109
|
+
lineWire(42, 12, 50, 12)
|
|
1110
|
+
].join("")
|
|
1111
|
+
};
|
|
1112
|
+
var push_nc = {
|
|
1113
|
+
length: 40,
|
|
1114
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 40, y: 0 } },
|
|
1115
|
+
svg: () => [
|
|
1116
|
+
lineWire(0, 0, 12, 0),
|
|
1117
|
+
lineWire(28, 0, 40, 0),
|
|
1118
|
+
`<circle cx="12" cy="0" r="2" ${FILL}/>`,
|
|
1119
|
+
`<circle cx="28" cy="0" r="2" ${FILL}/>`,
|
|
1120
|
+
`<line x1="10" y1="0" x2="30" y2="0" ${BODY}/>`,
|
|
1121
|
+
`<line x1="20" y1="0" x2="20" y2="-10" ${BODY}/>`,
|
|
1122
|
+
`<line x1="14" y1="-10" x2="26" y2="-10" ${BODY}/>`
|
|
1123
|
+
].join("")
|
|
1124
|
+
};
|
|
1125
|
+
var gnd_chassis = {
|
|
1126
|
+
length: 20,
|
|
1127
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
1128
|
+
svg: () => [
|
|
1129
|
+
`<line x1="0" y1="0" x2="10" y2="0" ${WIRE}/>`,
|
|
1130
|
+
`<line x1="10" y1="-6" x2="10" y2="6" ${BODY}/>`,
|
|
1131
|
+
`<line x1="10" y1="6" x2="14" y2="10" ${BODY}/>`,
|
|
1132
|
+
`<line x1="10" y1="2" x2="14" y2="6" ${BODY}/>`,
|
|
1133
|
+
`<line x1="10" y1="-2" x2="14" y2="2" ${BODY}/>`
|
|
1134
|
+
].join("")
|
|
1135
|
+
};
|
|
1136
|
+
var gnd_digital = {
|
|
1137
|
+
length: 20,
|
|
1138
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 20, y: 0 } },
|
|
1139
|
+
svg: () => [
|
|
1140
|
+
`<line x1="0" y1="0" x2="10" y2="0" ${WIRE}/>`,
|
|
1141
|
+
`<polygon points="8,-6 8,6 16,0" fill="none" ${BODY}/>`
|
|
1142
|
+
].join("")
|
|
1143
|
+
};
|
|
1144
|
+
var test_point = {
|
|
1145
|
+
length: 16,
|
|
1146
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 16, y: 0 } },
|
|
1147
|
+
svg: () => [
|
|
1148
|
+
lineWire(0, 0, 6, 0),
|
|
1149
|
+
`<circle cx="10" cy="0" r="4" fill="white" ${BODY}/>`
|
|
1150
|
+
].join("")
|
|
1151
|
+
};
|
|
1152
|
+
var no_connect = {
|
|
1153
|
+
length: 0,
|
|
1154
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } },
|
|
1155
|
+
svg: () => [
|
|
1156
|
+
`<line x1="-5" y1="-5" x2="5" y2="5" ${BODY}/>`,
|
|
1157
|
+
`<line x1="5" y1="-5" x2="-5" y2="5" ${BODY}/>`
|
|
1158
|
+
].join("")
|
|
1159
|
+
};
|
|
1160
|
+
var antenna = {
|
|
1161
|
+
length: 30,
|
|
1162
|
+
anchors: { start: { x: 0, y: 0 }, end: { x: 30, y: 0 } },
|
|
1163
|
+
svg: () => [
|
|
1164
|
+
lineWire(0, 0, 0, -10),
|
|
1165
|
+
`<line x1="0" y1="-10" x2="-10" y2="-24" ${BODY}/>`,
|
|
1166
|
+
`<line x1="0" y1="-10" x2="10" y2="-24" ${BODY}/>`
|
|
1167
|
+
].join("")
|
|
1168
|
+
};
|
|
1169
|
+
function icSymbol(defaultLeft, defaultRight, bodyLabel) {
|
|
1170
|
+
const BODY_W = 80;
|
|
1171
|
+
return {
|
|
1172
|
+
length: BODY_W,
|
|
1173
|
+
anchors: {
|
|
1174
|
+
start: { x: 0, y: 0 },
|
|
1175
|
+
end: { x: BODY_W, y: 0 }
|
|
1176
|
+
},
|
|
1177
|
+
svg: (_label, _value, attrs) => {
|
|
1178
|
+
const left = attrs?.pins_left ? attrs.pins_left.split(",").map((s) => s.trim()) : defaultLeft;
|
|
1179
|
+
const right = attrs?.pins_right ? attrs.pins_right.split(",").map((s) => s.trim()) : defaultRight;
|
|
1180
|
+
const n = Math.max(left.length, right.length, 2);
|
|
1181
|
+
const pitch = 16;
|
|
1182
|
+
const bodyH = pitch * (n + 1);
|
|
1183
|
+
const topY = -bodyH / 2;
|
|
1184
|
+
const parts = [];
|
|
1185
|
+
parts.push(`<rect x="0" y="${topY}" width="${BODY_W}" height="${bodyH}" fill="white" ${BODY}/>`);
|
|
1186
|
+
const labelText = attrs?.ic_label ?? bodyLabel ?? "";
|
|
1187
|
+
if (labelText) {
|
|
1188
|
+
parts.push(`<text x="${BODY_W / 2}" y="3" text-anchor="middle" class="schematex-circuit-meter">${labelText}</text>`);
|
|
1189
|
+
}
|
|
1190
|
+
for (let i = 0; i < left.length; i++) {
|
|
1191
|
+
const y = topY + pitch * (i + 1);
|
|
1192
|
+
parts.push(`<line x1="-8" y1="${y}" x2="0" y2="${y}" ${WIRE}/>`);
|
|
1193
|
+
parts.push(`<text x="4" y="${y + 3}" class="schematex-circuit-pol">${left[i]}</text>`);
|
|
1194
|
+
}
|
|
1195
|
+
for (let i = 0; i < right.length; i++) {
|
|
1196
|
+
const y = topY + pitch * (i + 1);
|
|
1197
|
+
parts.push(`<line x1="${BODY_W}" y1="${y}" x2="${BODY_W + 8}" y2="${y}" ${WIRE}/>`);
|
|
1198
|
+
parts.push(`<text x="${BODY_W - 4}" y="${y + 3}" text-anchor="end" class="schematex-circuit-pol">${right[i]}</text>`);
|
|
1199
|
+
}
|
|
1200
|
+
return parts.join("");
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
var generic_ic = icSymbol(
|
|
1205
|
+
["1", "2", "3", "4"],
|
|
1206
|
+
["8", "7", "6", "5"],
|
|
1207
|
+
"IC"
|
|
1208
|
+
);
|
|
1209
|
+
var timer_555 = (() => {
|
|
1210
|
+
const left = ["GND", "TRG", "OUT", "RST"];
|
|
1211
|
+
const right = ["VCC", "DIS", "THR", "CTL"];
|
|
1212
|
+
const sym = icSymbol(left, right, "555");
|
|
1213
|
+
const BODY_W = 80;
|
|
1214
|
+
const pitch = 16;
|
|
1215
|
+
const n = 4;
|
|
1216
|
+
const topY = -80 / 2;
|
|
1217
|
+
const anchors = {
|
|
1218
|
+
start: { x: 0, y: 0 },
|
|
1219
|
+
end: { x: BODY_W, y: 0 }
|
|
1220
|
+
};
|
|
1221
|
+
const leftNames = ["gnd", "trg", "out", "rst"];
|
|
1222
|
+
const rightNames = ["vcc", "dis", "thr", "ctl"];
|
|
1223
|
+
for (let i = 0; i < n; i++) {
|
|
1224
|
+
const y = topY + pitch * (i + 1);
|
|
1225
|
+
anchors[leftNames[i]] = { x: -8, y };
|
|
1226
|
+
anchors[rightNames[i]] = { x: BODY_W + 8, y };
|
|
1227
|
+
}
|
|
1228
|
+
return { ...sym, anchors };
|
|
1229
|
+
})();
|
|
1230
|
+
var voltage_regulator = {
|
|
1231
|
+
length: 60,
|
|
1232
|
+
anchors: {
|
|
1233
|
+
start: { x: 0, y: 0 },
|
|
1234
|
+
end: { x: 60, y: 0 },
|
|
1235
|
+
in: { x: 0, y: 0 },
|
|
1236
|
+
out: { x: 60, y: 0 },
|
|
1237
|
+
gnd: { x: 30, y: 20 }
|
|
1238
|
+
},
|
|
1239
|
+
svg: (_l, _v, attrs) => [
|
|
1240
|
+
lineWire(0, 0, 10, 0),
|
|
1241
|
+
`<rect x="10" y="-15" width="40" height="30" fill="white" ${BODY}/>`,
|
|
1242
|
+
`<text x="30" y="4" text-anchor="middle" class="schematex-circuit-meter">${attrs?.model ?? "REG"}</text>`,
|
|
1243
|
+
lineWire(50, 0, 60, 0),
|
|
1244
|
+
lineWire(30, 15, 30, 20)
|
|
1245
|
+
].join("")
|
|
1246
|
+
};
|
|
1247
|
+
var potentiometer = {
|
|
1248
|
+
length: 50,
|
|
1249
|
+
anchors: {
|
|
1250
|
+
start: { x: 0, y: 0 },
|
|
1251
|
+
end: { x: 50, y: 0 },
|
|
1252
|
+
wiper: { x: 25, y: -22 }
|
|
1253
|
+
},
|
|
1254
|
+
svg: () => [
|
|
1255
|
+
`<path d="M 0,0 L 10,0 L 13,-8 L 18,8 L 23,-8 L 28,8 L 33,-8 L 38,8 L 40,0 L 50,0" ${BODY}/>`,
|
|
1256
|
+
`<line x1="25" y1="-22" x2="25" y2="-10" ${BODY}/>`,
|
|
1257
|
+
`<polygon points="25,-10 21,-16 29,-16" ${FILL}/>`
|
|
1258
|
+
].join("")
|
|
1259
|
+
};
|
|
1260
|
+
var SYMBOLS = {
|
|
1261
|
+
resistor,
|
|
1262
|
+
capacitor,
|
|
1263
|
+
electrolytic_cap,
|
|
1264
|
+
inductor,
|
|
1265
|
+
fuse,
|
|
1266
|
+
crystal,
|
|
1267
|
+
transformer,
|
|
1268
|
+
voltage_source,
|
|
1269
|
+
current_source,
|
|
1270
|
+
ac_source,
|
|
1271
|
+
battery,
|
|
1272
|
+
ground,
|
|
1273
|
+
gnd_signal,
|
|
1274
|
+
vcc,
|
|
1275
|
+
diode,
|
|
1276
|
+
zener,
|
|
1277
|
+
schottky,
|
|
1278
|
+
led,
|
|
1279
|
+
photodiode,
|
|
1280
|
+
npn,
|
|
1281
|
+
pnp,
|
|
1282
|
+
nmos,
|
|
1283
|
+
pmos,
|
|
1284
|
+
jfet_n,
|
|
1285
|
+
jfet_p,
|
|
1286
|
+
opamp,
|
|
1287
|
+
comparator,
|
|
1288
|
+
switch_spst,
|
|
1289
|
+
push_no,
|
|
1290
|
+
ammeter,
|
|
1291
|
+
voltmeter,
|
|
1292
|
+
wattmeter,
|
|
1293
|
+
motor,
|
|
1294
|
+
speaker,
|
|
1295
|
+
microphone,
|
|
1296
|
+
buzzer,
|
|
1297
|
+
potentiometer,
|
|
1298
|
+
rheostat,
|
|
1299
|
+
thermistor_ntc,
|
|
1300
|
+
thermistor_ptc,
|
|
1301
|
+
ldr,
|
|
1302
|
+
variable_cap,
|
|
1303
|
+
variable_inductor,
|
|
1304
|
+
switch_spdt,
|
|
1305
|
+
push_nc,
|
|
1306
|
+
gnd_chassis,
|
|
1307
|
+
gnd_digital,
|
|
1308
|
+
test_point,
|
|
1309
|
+
no_connect,
|
|
1310
|
+
antenna,
|
|
1311
|
+
generic_ic,
|
|
1312
|
+
"555_timer": timer_555,
|
|
1313
|
+
voltage_regulator
|
|
1314
|
+
// Lamp reuses buzzer slot? No, needs its own entry but our CircuitComponentType
|
|
1315
|
+
// doesn't have "lamp". We map it via parser alias to "buzzer" or add specifically.
|
|
1316
|
+
};
|
|
1317
|
+
var EXTRA_SYMBOLS = {
|
|
1318
|
+
lamp
|
|
1319
|
+
};
|
|
1320
|
+
function getSymbol(t) {
|
|
1321
|
+
return SYMBOLS[t] ?? EXTRA_SYMBOLS[t];
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// src/diagrams/circuit/layout.ts
|
|
1325
|
+
function rotationDeg(d) {
|
|
1326
|
+
return d === "right" ? 0 : d === "down" ? 90 : d === "left" ? 180 : 270;
|
|
1327
|
+
}
|
|
1328
|
+
function rotatePoint(p, angleDeg) {
|
|
1329
|
+
const r = angleDeg * Math.PI / 180;
|
|
1330
|
+
const c = Math.cos(r);
|
|
1331
|
+
const s = Math.sin(r);
|
|
1332
|
+
return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
|
|
1333
|
+
}
|
|
1334
|
+
function resolveAnchorRef(ref, byId, nets) {
|
|
1335
|
+
if (ref === "origin") return { x: 0, y: 0 };
|
|
1336
|
+
if (nets.has(ref)) return nets.get(ref);
|
|
1337
|
+
const dot = ref.indexOf(".");
|
|
1338
|
+
if (dot < 0) {
|
|
1339
|
+
const c2 = byId.get(ref);
|
|
1340
|
+
if (c2) return c2.anchors.end ?? c2.anchors.center ?? { x: c2.x, y: c2.y };
|
|
1341
|
+
return void 0;
|
|
1342
|
+
}
|
|
1343
|
+
const id = ref.slice(0, dot);
|
|
1344
|
+
const pin = ref.slice(dot + 1);
|
|
1345
|
+
const c = byId.get(id);
|
|
1346
|
+
if (!c) return void 0;
|
|
1347
|
+
return c.anchors[pin];
|
|
1348
|
+
}
|
|
1349
|
+
function layoutCircuit(ast) {
|
|
1350
|
+
const items = [];
|
|
1351
|
+
const byId = /* @__PURE__ */ new Map();
|
|
1352
|
+
const nets = /* @__PURE__ */ new Map();
|
|
1353
|
+
let cursor = { x: 0, y: 0 };
|
|
1354
|
+
for (const comp of ast.components) {
|
|
1355
|
+
let startPt = cursor;
|
|
1356
|
+
if (comp.at) {
|
|
1357
|
+
const resolved = resolveAnchorRef(comp.at, byId, nets);
|
|
1358
|
+
if (resolved) startPt = resolved;
|
|
1359
|
+
}
|
|
1360
|
+
const sym = getSymbol(comp.componentType);
|
|
1361
|
+
const rot = rotationDeg(comp.direction);
|
|
1362
|
+
if (comp.componentType === "wire") {
|
|
1363
|
+
const len = parseInt(comp.attrs?.length ?? "20", 10);
|
|
1364
|
+
const endOffset = rotatePoint({ x: len, y: 0 }, rot);
|
|
1365
|
+
const end = { x: startPt.x + endOffset.x, y: startPt.y + endOffset.y };
|
|
1366
|
+
const laid2 = {
|
|
1367
|
+
component: comp,
|
|
1368
|
+
x: startPt.x,
|
|
1369
|
+
y: startPt.y,
|
|
1370
|
+
rotation: rot,
|
|
1371
|
+
length: len,
|
|
1372
|
+
anchors: { start: startPt, end }
|
|
1373
|
+
};
|
|
1374
|
+
items.push(laid2);
|
|
1375
|
+
byId.set(comp.id, laid2);
|
|
1376
|
+
cursor = end;
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
if (comp.componentType === "dot") {
|
|
1380
|
+
const laid2 = {
|
|
1381
|
+
component: comp,
|
|
1382
|
+
x: startPt.x,
|
|
1383
|
+
y: startPt.y,
|
|
1384
|
+
rotation: 0,
|
|
1385
|
+
length: 0,
|
|
1386
|
+
anchors: { start: startPt, end: startPt, center: startPt }
|
|
1387
|
+
};
|
|
1388
|
+
items.push(laid2);
|
|
1389
|
+
byId.set(comp.id, laid2);
|
|
1390
|
+
if (comp.attrs?.net) nets.set(comp.attrs.net, startPt);
|
|
1391
|
+
cursor = startPt;
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
if (comp.componentType === "label") {
|
|
1395
|
+
const laid2 = {
|
|
1396
|
+
component: comp,
|
|
1397
|
+
x: startPt.x,
|
|
1398
|
+
y: startPt.y,
|
|
1399
|
+
rotation: rot,
|
|
1400
|
+
length: 0,
|
|
1401
|
+
anchors: { start: startPt, end: startPt }
|
|
1402
|
+
};
|
|
1403
|
+
items.push(laid2);
|
|
1404
|
+
byId.set(comp.id, laid2);
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
if (!sym) {
|
|
1408
|
+
const endOffset = rotatePoint({ x: 30, y: 0 }, rot);
|
|
1409
|
+
const end = { x: startPt.x + endOffset.x, y: startPt.y + endOffset.y };
|
|
1410
|
+
const laid2 = {
|
|
1411
|
+
component: comp,
|
|
1412
|
+
x: startPt.x,
|
|
1413
|
+
y: startPt.y,
|
|
1414
|
+
rotation: rot,
|
|
1415
|
+
length: 30,
|
|
1416
|
+
anchors: { start: startPt, end }
|
|
1417
|
+
};
|
|
1418
|
+
items.push(laid2);
|
|
1419
|
+
byId.set(comp.id, laid2);
|
|
1420
|
+
cursor = end;
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
const worldAnchors = {};
|
|
1424
|
+
for (const [name, pt] of Object.entries(sym.anchors)) {
|
|
1425
|
+
const rp = rotatePoint(pt, rot);
|
|
1426
|
+
worldAnchors[name] = { x: startPt.x + rp.x, y: startPt.y + rp.y };
|
|
1427
|
+
}
|
|
1428
|
+
const laid = {
|
|
1429
|
+
component: comp,
|
|
1430
|
+
x: startPt.x,
|
|
1431
|
+
y: startPt.y,
|
|
1432
|
+
rotation: rot,
|
|
1433
|
+
length: sym.length,
|
|
1434
|
+
anchors: worldAnchors
|
|
1435
|
+
};
|
|
1436
|
+
items.push(laid);
|
|
1437
|
+
byId.set(comp.id, laid);
|
|
1438
|
+
cursor = worldAnchors.end ?? startPt;
|
|
1439
|
+
}
|
|
1440
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
1441
|
+
for (const it of items) {
|
|
1442
|
+
for (const a of Object.values(it.anchors)) {
|
|
1443
|
+
if (a.x < minX) minX = a.x;
|
|
1444
|
+
if (a.y < minY) minY = a.y;
|
|
1445
|
+
if (a.x > maxX) maxX = a.x;
|
|
1446
|
+
if (a.y > maxY) maxY = a.y;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
if (!isFinite(minX)) {
|
|
1450
|
+
minX = 0;
|
|
1451
|
+
minY = 0;
|
|
1452
|
+
maxX = 100;
|
|
1453
|
+
maxY = 100;
|
|
1454
|
+
}
|
|
1455
|
+
const pad = 40;
|
|
1456
|
+
minX -= pad;
|
|
1457
|
+
minY -= pad;
|
|
1458
|
+
maxX += pad;
|
|
1459
|
+
maxY += pad;
|
|
1460
|
+
const width = maxX - minX;
|
|
1461
|
+
const height = maxY - minY;
|
|
1462
|
+
return {
|
|
1463
|
+
width,
|
|
1464
|
+
height,
|
|
1465
|
+
offsetX: -minX,
|
|
1466
|
+
offsetY: -minY,
|
|
1467
|
+
items
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// src/diagrams/circuit/autolayout.ts
|
|
1472
|
+
var COL_W = 120;
|
|
1473
|
+
var ROW_H = 100;
|
|
1474
|
+
var RAIL_PAD = 60;
|
|
1475
|
+
var LEFT_MARGIN = 80;
|
|
1476
|
+
var TOP_MARGIN = 60;
|
|
1477
|
+
function isPowerSource(c) {
|
|
1478
|
+
return c.componentType === "voltage_source" || c.componentType === "current_source" || c.componentType === "ac_source" || c.componentType === "battery" || c.componentType === "vcc";
|
|
1479
|
+
}
|
|
1480
|
+
function isGround(c) {
|
|
1481
|
+
return c.componentType === "ground" || c.componentType === "gnd_signal" || c.componentType === "gnd_chassis" || c.componentType === "gnd_digital";
|
|
1482
|
+
}
|
|
1483
|
+
function rotatePt(p, angleDeg) {
|
|
1484
|
+
const r = angleDeg * Math.PI / 180;
|
|
1485
|
+
const c = Math.cos(r);
|
|
1486
|
+
const s = Math.sin(r);
|
|
1487
|
+
return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
|
|
1488
|
+
}
|
|
1489
|
+
function rotationOf(dir) {
|
|
1490
|
+
return dir === "right" ? 0 : dir === "down" ? 90 : dir === "left" ? 180 : 270;
|
|
1491
|
+
}
|
|
1492
|
+
function defaultDirection(c) {
|
|
1493
|
+
if (isPowerSource(c)) return "up";
|
|
1494
|
+
if (isGround(c)) return "down";
|
|
1495
|
+
return "right";
|
|
1496
|
+
}
|
|
1497
|
+
function extendBBox(bbox, pt) {
|
|
1498
|
+
if (pt.x < bbox.minX) bbox.minX = pt.x;
|
|
1499
|
+
if (pt.y < bbox.minY) bbox.minY = pt.y;
|
|
1500
|
+
if (pt.x > bbox.maxX) bbox.maxX = pt.x;
|
|
1501
|
+
if (pt.y > bbox.maxY) bbox.maxY = pt.y;
|
|
1502
|
+
}
|
|
1503
|
+
function layoutCircuitNetlist(ast) {
|
|
1504
|
+
const pinMap = ast.pinMap ?? {};
|
|
1505
|
+
const powerComps = [];
|
|
1506
|
+
const groundComps = [];
|
|
1507
|
+
const middleComps = [];
|
|
1508
|
+
for (const c of ast.components) {
|
|
1509
|
+
if (isPowerSource(c)) powerComps.push(c);
|
|
1510
|
+
else if (isGround(c)) groundComps.push(c);
|
|
1511
|
+
else middleComps.push(c);
|
|
1512
|
+
}
|
|
1513
|
+
const ranks = [];
|
|
1514
|
+
const mainRank = [...powerComps, ...middleComps];
|
|
1515
|
+
if (mainRank.length) ranks.push(mainRank);
|
|
1516
|
+
if (groundComps.length) ranks.push(groundComps);
|
|
1517
|
+
if (ranks.length === 0) ranks.push(ast.components);
|
|
1518
|
+
const placed = /* @__PURE__ */ new Map();
|
|
1519
|
+
const items = [];
|
|
1520
|
+
let maxCols = 0;
|
|
1521
|
+
for (const rank of ranks) maxCols = Math.max(maxCols, rank.length);
|
|
1522
|
+
for (let r = 0; r < ranks.length; r++) {
|
|
1523
|
+
const rank = ranks[r];
|
|
1524
|
+
const rowY = TOP_MARGIN + r * (ROW_H + RAIL_PAD);
|
|
1525
|
+
const startX = LEFT_MARGIN + (maxCols - rank.length) * COL_W / 2;
|
|
1526
|
+
for (let i = 0; i < rank.length; i++) {
|
|
1527
|
+
const comp = rank[i];
|
|
1528
|
+
const direction = defaultDirection(comp);
|
|
1529
|
+
comp.direction = direction;
|
|
1530
|
+
const rot = rotationOf(direction);
|
|
1531
|
+
const sym = getSymbol(comp.componentType);
|
|
1532
|
+
const x = startX + i * COL_W;
|
|
1533
|
+
const y = rowY;
|
|
1534
|
+
const worldAnchors = {};
|
|
1535
|
+
if (sym) {
|
|
1536
|
+
for (const [name, pt] of Object.entries(sym.anchors)) {
|
|
1537
|
+
const rp = rotatePt(pt, rot);
|
|
1538
|
+
worldAnchors[name] = { x: x + rp.x, y: y + rp.y };
|
|
1539
|
+
}
|
|
1540
|
+
} else {
|
|
1541
|
+
worldAnchors.start = { x, y };
|
|
1542
|
+
worldAnchors.end = { x: x + 30, y };
|
|
1543
|
+
}
|
|
1544
|
+
const laid = {
|
|
1545
|
+
component: comp,
|
|
1546
|
+
x,
|
|
1547
|
+
y,
|
|
1548
|
+
rotation: rot,
|
|
1549
|
+
length: sym?.length ?? 30,
|
|
1550
|
+
anchors: worldAnchors
|
|
1551
|
+
};
|
|
1552
|
+
items.push(laid);
|
|
1553
|
+
placed.set(comp.id, laid);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
const netPins = /* @__PURE__ */ new Map();
|
|
1557
|
+
for (const comp of ast.components) {
|
|
1558
|
+
const pins = pinMap[comp.id];
|
|
1559
|
+
if (!pins) continue;
|
|
1560
|
+
const laid = placed.get(comp.id);
|
|
1561
|
+
if (!laid) continue;
|
|
1562
|
+
for (const [pinName, netId] of Object.entries(pins)) {
|
|
1563
|
+
const pt = laid.anchors[pinName];
|
|
1564
|
+
if (!pt) continue;
|
|
1565
|
+
if (!netPins.has(netId)) netPins.set(netId, []);
|
|
1566
|
+
netPins.get(netId).push({ compId: comp.id, pinName, pt });
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
const routes = [];
|
|
1570
|
+
const bbox = {
|
|
1571
|
+
minX: Infinity,
|
|
1572
|
+
minY: Infinity,
|
|
1573
|
+
maxX: -Infinity,
|
|
1574
|
+
maxY: -Infinity
|
|
1575
|
+
};
|
|
1576
|
+
for (const it of items) {
|
|
1577
|
+
for (const a of Object.values(it.anchors)) extendBBox(bbox, a);
|
|
1578
|
+
}
|
|
1579
|
+
if (!isFinite(bbox.minX)) {
|
|
1580
|
+
bbox.minX = 0;
|
|
1581
|
+
bbox.minY = 0;
|
|
1582
|
+
bbox.maxX = 200;
|
|
1583
|
+
bbox.maxY = 200;
|
|
1584
|
+
}
|
|
1585
|
+
for (const [netId, pins] of netPins) {
|
|
1586
|
+
if (pins.length < 2) continue;
|
|
1587
|
+
if (netId === "GND") {
|
|
1588
|
+
const railY = bbox.maxY + 30;
|
|
1589
|
+
const minX2 = Math.min(...pins.map((p) => p.pt.x));
|
|
1590
|
+
const maxX2 = Math.max(...pins.map((p) => p.pt.x));
|
|
1591
|
+
if (pins.length > 1) {
|
|
1592
|
+
routes.push({
|
|
1593
|
+
netId,
|
|
1594
|
+
points: [
|
|
1595
|
+
{ x: minX2, y: railY },
|
|
1596
|
+
{ x: maxX2, y: railY }
|
|
1597
|
+
]
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
for (const p of pins) {
|
|
1601
|
+
routes.push({
|
|
1602
|
+
netId: `${netId}.${p.compId}`,
|
|
1603
|
+
points: [
|
|
1604
|
+
p.pt,
|
|
1605
|
+
{ x: p.pt.x, y: railY }
|
|
1606
|
+
]
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
bbox.maxY = Math.max(bbox.maxY, railY);
|
|
1610
|
+
continue;
|
|
1611
|
+
}
|
|
1612
|
+
const touchesPowerSource = pins.some((p) => {
|
|
1613
|
+
const comp = ast.components.find((c) => c.id === p.compId);
|
|
1614
|
+
return !!comp && isPowerSource(comp);
|
|
1615
|
+
});
|
|
1616
|
+
if (touchesPowerSource && pins.length > 1) {
|
|
1617
|
+
const railY = bbox.minY - 30;
|
|
1618
|
+
const minX2 = Math.min(...pins.map((p) => p.pt.x));
|
|
1619
|
+
const maxX2 = Math.max(...pins.map((p) => p.pt.x));
|
|
1620
|
+
routes.push({
|
|
1621
|
+
netId,
|
|
1622
|
+
points: [
|
|
1623
|
+
{ x: minX2, y: railY },
|
|
1624
|
+
{ x: maxX2, y: railY }
|
|
1625
|
+
]
|
|
1626
|
+
});
|
|
1627
|
+
for (const p of pins) {
|
|
1628
|
+
routes.push({
|
|
1629
|
+
netId: `${netId}.${p.compId}`,
|
|
1630
|
+
points: [p.pt, { x: p.pt.x, y: railY }]
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
bbox.minY = Math.min(bbox.minY, railY);
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
if (pins.length === 2) {
|
|
1637
|
+
const [a, b] = pins;
|
|
1638
|
+
const points = Math.abs(a.pt.y - b.pt.y) < 0.5 ? [a.pt, b.pt] : Math.abs(a.pt.x - b.pt.x) < 0.5 ? [a.pt, b.pt] : [a.pt, { x: a.pt.x, y: b.pt.y }, b.pt];
|
|
1639
|
+
routes.push({ netId, points });
|
|
1640
|
+
} else {
|
|
1641
|
+
const ys = pins.map((p) => p.pt.y).sort((x, y) => x - y);
|
|
1642
|
+
const spineY = ys[Math.floor(ys.length / 2)];
|
|
1643
|
+
const xs = pins.map((p) => p.pt.x).sort((x, y) => x - y);
|
|
1644
|
+
const spineLeft = xs[0];
|
|
1645
|
+
const spineRight = xs[xs.length - 1];
|
|
1646
|
+
routes.push({
|
|
1647
|
+
netId,
|
|
1648
|
+
points: [
|
|
1649
|
+
{ x: spineLeft, y: spineY },
|
|
1650
|
+
{ x: spineRight, y: spineY }
|
|
1651
|
+
]
|
|
1652
|
+
});
|
|
1653
|
+
const junctions = [];
|
|
1654
|
+
for (const p of pins) {
|
|
1655
|
+
if (Math.abs(p.pt.y - spineY) < 0.5) {
|
|
1656
|
+
if (p.pt.x > spineLeft && p.pt.x < spineRight) {
|
|
1657
|
+
junctions.push(p.pt);
|
|
1658
|
+
}
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
routes.push({
|
|
1662
|
+
netId: `${netId}.${p.compId}`,
|
|
1663
|
+
points: [p.pt, { x: p.pt.x, y: spineY }]
|
|
1664
|
+
});
|
|
1665
|
+
if (p.pt.x > spineLeft && p.pt.x < spineRight) {
|
|
1666
|
+
junctions.push({ x: p.pt.x, y: spineY });
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (junctions.length > 0) {
|
|
1670
|
+
routes[routes.length - 1 - pins.filter(
|
|
1671
|
+
(p) => Math.abs(p.pt.y - spineY) >= 0.5
|
|
1672
|
+
).length].junctions = junctions;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
for (const r of routes) {
|
|
1677
|
+
for (const p of r.points) extendBBox(bbox, p);
|
|
1678
|
+
}
|
|
1679
|
+
const pad = 40;
|
|
1680
|
+
const minX = bbox.minX - pad;
|
|
1681
|
+
const minY = bbox.minY - pad;
|
|
1682
|
+
const maxX = bbox.maxX + pad;
|
|
1683
|
+
const maxY = bbox.maxY + pad;
|
|
1684
|
+
return {
|
|
1685
|
+
width: maxX - minX,
|
|
1686
|
+
height: maxY - minY,
|
|
1687
|
+
offsetX: -minX,
|
|
1688
|
+
offsetY: -minY,
|
|
1689
|
+
items,
|
|
1690
|
+
routes
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
// src/diagrams/circuit/renderer.ts
|
|
1695
|
+
function renderItem(it, offX, offY) {
|
|
1696
|
+
const comp = it.component;
|
|
1697
|
+
const tx = it.x + offX;
|
|
1698
|
+
const ty = it.y + offY;
|
|
1699
|
+
if (comp.componentType === "wire") {
|
|
1700
|
+
const x2 = it.anchors.end.x + offX;
|
|
1701
|
+
const y2 = it.anchors.end.y + offY;
|
|
1702
|
+
return `<line x1="${tx}" y1="${ty}" x2="${x2}" y2="${y2}" class="schematex-circuit-wire"/>`;
|
|
1703
|
+
}
|
|
1704
|
+
if (comp.componentType === "dot") {
|
|
1705
|
+
return chunkHDKDQAEQ_cjs.circle({
|
|
1706
|
+
cx: tx,
|
|
1707
|
+
cy: ty,
|
|
1708
|
+
r: 3.5,
|
|
1709
|
+
class: "schematex-circuit-dot",
|
|
1710
|
+
"data-id": comp.id
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
if (comp.componentType === "label") {
|
|
1714
|
+
const dir = comp.direction;
|
|
1715
|
+
const anchor = dir === "left" ? "end" : dir === "right" ? "start" : "middle";
|
|
1716
|
+
const dx = dir === "right" ? 6 : dir === "left" ? -6 : 0;
|
|
1717
|
+
const dy = dir === "down" ? 14 : dir === "up" ? -6 : 4;
|
|
1718
|
+
return chunkHDKDQAEQ_cjs.text(
|
|
1719
|
+
{
|
|
1720
|
+
x: tx + dx,
|
|
1721
|
+
y: ty + dy,
|
|
1722
|
+
class: "schematex-circuit-net-label",
|
|
1723
|
+
"text-anchor": anchor
|
|
1724
|
+
},
|
|
1725
|
+
comp.label ?? ""
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
const sym = getSymbol(comp.componentType);
|
|
1729
|
+
if (!sym) {
|
|
1730
|
+
return `<rect x="${tx - 10}" y="${ty - 10}" width="20" height="20" fill="none" class="schematex-circuit-err" stroke-dasharray="3,2"/><text x="${tx}" y="${ty + 3}" text-anchor="middle" font-size="9" class="schematex-circuit-err">?${chunkHDKDQAEQ_cjs.escapeXml(comp.componentType)}</text>`;
|
|
1731
|
+
}
|
|
1732
|
+
const body = sym.svg(comp.label, comp.value, comp.attrs);
|
|
1733
|
+
const transform = `translate(${tx}, ${ty}) rotate(${it.rotation})`;
|
|
1734
|
+
const labels = [];
|
|
1735
|
+
if (comp.label || comp.value) {
|
|
1736
|
+
const labelX = it.x + offX + it.length * Math.cos(it.rotation * Math.PI / 180) / 2;
|
|
1737
|
+
const labelY = it.y + offY + it.length * Math.sin(it.rotation * Math.PI / 180) / 2;
|
|
1738
|
+
const perpDX = Math.sin(it.rotation * Math.PI / 180);
|
|
1739
|
+
const perpDY = -Math.cos(it.rotation * Math.PI / 180);
|
|
1740
|
+
const off = 16;
|
|
1741
|
+
if (comp.label) {
|
|
1742
|
+
labels.push(
|
|
1743
|
+
chunkHDKDQAEQ_cjs.text(
|
|
1744
|
+
{
|
|
1745
|
+
x: labelX + perpDX * off,
|
|
1746
|
+
y: labelY + perpDY * off - 2,
|
|
1747
|
+
class: "schematex-circuit-label",
|
|
1748
|
+
"text-anchor": "middle"
|
|
1749
|
+
},
|
|
1750
|
+
comp.label
|
|
1751
|
+
)
|
|
1752
|
+
);
|
|
1753
|
+
}
|
|
1754
|
+
if (comp.value) {
|
|
1755
|
+
labels.push(
|
|
1756
|
+
chunkHDKDQAEQ_cjs.text(
|
|
1757
|
+
{
|
|
1758
|
+
x: labelX + perpDX * off,
|
|
1759
|
+
y: labelY + perpDY * off + 10,
|
|
1760
|
+
class: "schematex-circuit-value",
|
|
1761
|
+
"text-anchor": "middle"
|
|
1762
|
+
},
|
|
1763
|
+
comp.value
|
|
1764
|
+
)
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return `<g transform="${transform}" data-id="${chunkHDKDQAEQ_cjs.escapeXml(comp.id)}" data-type="${chunkHDKDQAEQ_cjs.escapeXml(comp.componentType)}">${body}</g>` + labels.join("");
|
|
1769
|
+
}
|
|
1770
|
+
function renderRoute(r, offX, offY) {
|
|
1771
|
+
if (r.points.length < 2) return "";
|
|
1772
|
+
const pts = r.points.map((p) => `${p.x + offX},${p.y + offY}`).join(" ");
|
|
1773
|
+
const line = `<polyline points="${pts}" class="schematex-circuit-wire" fill="none"/>`;
|
|
1774
|
+
const dots = (r.junctions ?? []).map(
|
|
1775
|
+
(j) => `<circle cx="${j.x + offX}" cy="${j.y + offY}" r="3.5" class="schematex-circuit-dot"/>`
|
|
1776
|
+
).join("");
|
|
1777
|
+
return line + dots;
|
|
1778
|
+
}
|
|
1779
|
+
function renderCircuit(ast, config) {
|
|
1780
|
+
const isNetlist = ast.mode === "netlist";
|
|
1781
|
+
const layout = isNetlist ? layoutCircuitNetlist(ast) : layoutCircuit(ast);
|
|
1782
|
+
const { width, height, offsetX, offsetY } = layout;
|
|
1783
|
+
const t = chunkN7KOXOMX_cjs.resolveIndustrialTheme(config?.theme ?? "default");
|
|
1784
|
+
const routeSvg = (layout.routes ?? []).map((r) => renderRoute(r, offsetX, offsetY)).join("");
|
|
1785
|
+
const items = layout.items.map((it) => renderItem(it, offsetX, offsetY)).join("");
|
|
1786
|
+
const css = `
|
|
1787
|
+
.schematex-circuit { background: ${t.bg}; font-family: system-ui, -apple-system, sans-serif; }
|
|
1788
|
+
.schematex-circuit-body { stroke: ${t.stroke}; stroke-width: 1.75; fill: none; stroke-linejoin: round; stroke-linecap: round; }
|
|
1789
|
+
.schematex-circuit-fill { stroke: ${t.stroke}; stroke-width: 1.5; fill: ${t.stroke}; }
|
|
1790
|
+
.schematex-circuit-wire { stroke: ${t.stroke}; stroke-width: 1.75; fill: none; stroke-linecap: square; }
|
|
1791
|
+
.schematex-circuit-dot { fill: ${t.stroke}; stroke: none; }
|
|
1792
|
+
.schematex-circuit-label { font: 600 11px system-ui, sans-serif; fill: ${t.text}; }
|
|
1793
|
+
.schematex-circuit-value { font: italic 10px system-ui, sans-serif; fill: ${t.textMuted}; }
|
|
1794
|
+
.schematex-circuit-net-label { font: 600 11px system-ui, sans-serif; fill: ${t.accent}; }
|
|
1795
|
+
.schematex-circuit-pol { font: 9px sans-serif; fill: ${t.stroke}; }
|
|
1796
|
+
.schematex-circuit-meter { font: bold 12px sans-serif; fill: ${t.stroke}; }
|
|
1797
|
+
.schematex-circuit-title { font: bold 14px sans-serif; fill: ${t.text}; }
|
|
1798
|
+
.schematex-circuit-err { stroke: ${t.error}; fill: ${t.error}; }
|
|
1799
|
+
`.trim();
|
|
1800
|
+
const titleBar = ast.title ? chunkHDKDQAEQ_cjs.text(
|
|
1801
|
+
{
|
|
1802
|
+
x: width / 2,
|
|
1803
|
+
y: 18,
|
|
1804
|
+
"text-anchor": "middle",
|
|
1805
|
+
class: "schematex-circuit-title"
|
|
1806
|
+
},
|
|
1807
|
+
ast.title
|
|
1808
|
+
) : "";
|
|
1809
|
+
const topOff = ast.title ? 24 : 0;
|
|
1810
|
+
return chunkHDKDQAEQ_cjs.svgRoot(
|
|
1811
|
+
{
|
|
1812
|
+
class: "schematex-circuit",
|
|
1813
|
+
viewBox: `0 0 ${Math.round(width)} ${Math.round(height + topOff)}`,
|
|
1814
|
+
width: Math.round(width),
|
|
1815
|
+
height: Math.round(height + topOff),
|
|
1816
|
+
role: "img",
|
|
1817
|
+
"data-diagram-type": "circuit"
|
|
1818
|
+
},
|
|
1819
|
+
[
|
|
1820
|
+
chunkHDKDQAEQ_cjs.title(ast.title ?? "Circuit Schematic"),
|
|
1821
|
+
chunkHDKDQAEQ_cjs.desc(
|
|
1822
|
+
`Circuit schematic with ${ast.components.length} components`
|
|
1823
|
+
),
|
|
1824
|
+
chunkHDKDQAEQ_cjs.defs([chunkHDKDQAEQ_cjs.el("style", {}, css)]),
|
|
1825
|
+
titleBar,
|
|
1826
|
+
chunkHDKDQAEQ_cjs.group({ transform: `translate(0, ${topOff})` }, [routeSvg + items])
|
|
1827
|
+
]
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// src/diagrams/circuit/index.ts
|
|
1832
|
+
var circuit = {
|
|
1833
|
+
type: "circuit",
|
|
1834
|
+
detect(text2) {
|
|
1835
|
+
const first = text2.trim().split("\n")[0]?.trim().toLowerCase() ?? "";
|
|
1836
|
+
return first.startsWith("circuit");
|
|
1837
|
+
},
|
|
1838
|
+
render(text2, config) {
|
|
1839
|
+
const ast = parseCircuit(text2);
|
|
1840
|
+
return renderCircuit(ast, config);
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1843
|
+
|
|
1844
|
+
exports.circuit = circuit;
|
|
1845
|
+
exports.layoutCircuit = layoutCircuit;
|
|
1846
|
+
exports.layoutCircuitNetlist = layoutCircuitNetlist;
|
|
1847
|
+
exports.parseCircuit = parseCircuit;
|
|
1848
|
+
exports.parseNetlist = parseNetlist;
|
|
1849
|
+
exports.renderCircuit = renderCircuit;
|
|
1850
|
+
//# sourceMappingURL=chunk-FGPTCDUT.cjs.map
|
|
1851
|
+
//# sourceMappingURL=chunk-FGPTCDUT.cjs.map
|