schematic-symbols 0.0.13 → 0.0.15

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,22 +1,3 @@
1
- declare const _default: {
2
- boxresistor_horz: SchSymbol;
3
- boxresistor_vert: SchSymbol;
4
- diode_horz: SchSymbol;
5
- diode_vert: SchSymbol;
6
- fuse_horz: SchSymbol;
7
- fuse_vert: SchSymbol;
8
- led_horz: SchSymbol;
9
- led_vert: SchSymbol;
10
- mosfet_depletion_normally_on_horz: SchSymbol;
11
- mosfet_depletion_normally_on_vert: SchSymbol;
12
- potentiometer_horz: SchSymbol;
13
- potentiometer_vert: SchSymbol;
14
- potentiometer2_horz: SchSymbol;
15
- potentiometer2_vert: SchSymbol;
16
- varistor_horz: SchSymbol;
17
- varistor_vert: SchSymbol;
18
- };
19
-
20
1
  interface Point {
21
2
  x: number;
22
3
  y: number;
@@ -83,12 +64,33 @@ declare function resizeSymbol(symbol: SchSymbol, newSize: {
83
64
  height?: number;
84
65
  }): SchSymbol;
85
66
 
86
- type BaseSymbolName = keyof typeof _default extends `${infer T}_${infer U}` ? `${T}` : never;
67
+ declare const _default: {
68
+ boxresistor_horz: undefined;
69
+ boxresistor_vert: undefined;
70
+ diode_horz: undefined;
71
+ diode_vert: undefined;
72
+ fuse_horz: undefined;
73
+ fuse_vert: undefined;
74
+ led_horz: undefined;
75
+ led_vert: undefined;
76
+ mosfet_depletion_normally_on_horz: undefined;
77
+ mosfet_depletion_normally_on_vert: undefined;
78
+ potentiometer_horz: undefined;
79
+ potentiometer_vert: undefined;
80
+ potentiometer2_horz: undefined;
81
+ potentiometer2_vert: undefined;
82
+ varistor_horz: undefined;
83
+ varistor_vert: undefined;
84
+ };
85
+
86
+ type BaseSymbolName = "boxresistor | diode | fuse | led | mosfet_depletion_normally_on | potentiometer | potentiometer2 | varistor";
87
+
87
88
  /**
88
89
  * Utility for easier autocomplete:
89
90
  *
90
- * BASE_SYMBOLS.boxresistor
91
- * // "boxresistor"
91
+ * ```ts
92
+ * BASE_SYMBOLS.boxresistor // "boxresistor"
93
+ * ```
92
94
  */
93
95
  declare const BASE_SYMBOLS: Record<BaseSymbolName, BaseSymbolName>;
94
96
 
package/dist/index.js ADDED
@@ -0,0 +1,445 @@
1
+ // symbols/boxresistor_horz.ts
2
+ import { path } from "drawing/path";
3
+ import { text } from "drawing/text";
4
+ import { defineSymbol } from "drawing/defineSymbol";
5
+ var boxresistor_horz_default = defineSymbol({
6
+ primitives: [
7
+ path({
8
+ points: [
9
+ { x: 0, y: 0 },
10
+ { x: 0.2, y: 0 },
11
+ { x: 0.2, y: -0.12 },
12
+ { x: 0.8, y: -0.12 },
13
+ { x: 0.8, y: 0.12 },
14
+ { x: 0.2, y: 0.12 },
15
+ { x: 0.2, y: 0 }
16
+ ],
17
+ color: "primary"
18
+ }),
19
+ path({
20
+ points: [
21
+ { x: 0.8, y: 0 },
22
+ { x: 1, y: 0 }
23
+ ],
24
+ color: "primary"
25
+ }),
26
+ text("{REF}", { x: 0.5, y: -0.2, anchor: "middle_bottom" }),
27
+ text("{VAL}", { x: 0.5, y: 0.2, anchor: "middle_top" })
28
+ ],
29
+ ports: [
30
+ { x: 0, y: 0, labels: ["1", "-", "left"] },
31
+ { x: 1, y: 0, labels: ["2", "+", "right"] }
32
+ ],
33
+ center: { x: 0.5, y: 0 },
34
+ size: { width: 1, height: 0.55 }
35
+ });
36
+
37
+ // symbols/boxresistor_vert.ts
38
+ import { rotateSymbol } from "drawing/rotateSymbol";
39
+ var boxresistor_vert_default = rotateSymbol(boxresistor_horz_default);
40
+
41
+ // symbols/diode_horz.ts
42
+ import { defineSymbol as defineSymbol2 } from "drawing/defineSymbol";
43
+ import svgJson from "assets/symbols-svg-json/diode.json";
44
+ var { paths, texts, bounds, refblocks } = svgJson;
45
+ var diode_horz_default = defineSymbol2({
46
+ primitives: [
47
+ ...Object.values(paths),
48
+ { ...texts.top1, anchor: "middle_left" },
49
+ { ...texts.bottom1, anchor: "middle_left" }
50
+ ],
51
+ ports: [
52
+ { ...refblocks.left1, labels: ["1"] },
53
+ // TODO add more "standard" labels
54
+ { ...refblocks.right1, labels: ["2"] }
55
+ // TODO add more "standard" labels
56
+ ],
57
+ size: { width: bounds.width, height: bounds.height },
58
+ center: { x: bounds.centerX, y: bounds.centerY }
59
+ });
60
+
61
+ // symbols/diode_vert.ts
62
+ import { rotateSymbol as rotateSymbol2 } from "drawing/rotateSymbol";
63
+ var diode_vert_default = rotateSymbol2(diode_horz_default);
64
+
65
+ // symbols/fuse_horz.ts
66
+ import { defineSymbol as defineSymbol3 } from "drawing/defineSymbol";
67
+ import svgJson2 from "assets/symbols-svg-json/fuse.json";
68
+ var { paths: paths2, texts: texts2, bounds: bounds2, refblocks: refblocks2 } = svgJson2;
69
+ var fuse_horz_default = defineSymbol3({
70
+ primitives: [
71
+ ...Object.values(paths2),
72
+ { ...texts2.top1, anchor: "middle_bottom" },
73
+ {
74
+ type: "text",
75
+ text: "{VAL}",
76
+ x: 0,
77
+ y: 0.2,
78
+ anchor: "middle_top"
79
+ }
80
+ ],
81
+ ports: [
82
+ { ...refblocks2.left1, labels: ["1"] },
83
+ // TODO add more "standard" labels
84
+ { ...refblocks2.right1, labels: ["2"] }
85
+ // TODO add more "standard" labels
86
+ ],
87
+ size: { width: bounds2.width, height: bounds2.height },
88
+ center: { x: bounds2.centerX, y: bounds2.centerY }
89
+ });
90
+
91
+ // symbols/fuse_vert.ts
92
+ import { rotateSymbol as rotateSymbol3 } from "drawing/rotateSymbol";
93
+ var fuse_vert_default = rotateSymbol3(fuse_horz_default);
94
+
95
+ // symbols/led_horz.ts
96
+ import { defineSymbol as defineSymbol4 } from "drawing/defineSymbol";
97
+ import svgJson3 from "assets/symbols-svg-json/led.json";
98
+ var { paths: paths3, texts: texts3, bounds: bounds3, refblocks: refblocks3 } = svgJson3;
99
+ var led_horz_default = defineSymbol4({
100
+ primitives: [
101
+ ...Object.values(paths3),
102
+ { ...texts3.bottom1, anchor: "middle_left" },
103
+ { ...texts3.right1, anchor: "middle_left" }
104
+ ],
105
+ ports: [
106
+ { ...refblocks3.left1, labels: ["1", "anode", "pos"] },
107
+ { ...refblocks3.right1, labels: ["2", "cathode", "neg"] }
108
+ ],
109
+ size: { width: bounds3.width, height: bounds3.height },
110
+ center: { x: bounds3.centerX, y: bounds3.centerY + 0.1 }
111
+ });
112
+
113
+ // symbols/led_vert.ts
114
+ import { rotateSymbol as rotateSymbol4 } from "drawing/rotateSymbol";
115
+ var led_vert_default = rotateSymbol4(led_horz_default);
116
+
117
+ // symbols/mosfet_depletion_normally_on_horz.ts
118
+ import { defineSymbol as defineSymbol5 } from "drawing/defineSymbol";
119
+ import svgJson4 from "assets/symbols-svg-json/mosfet_depletion_normally_on.json";
120
+ var { paths: paths4, texts: texts4, bounds: bounds4, refblocks: refblocks4 } = svgJson4;
121
+ var mosfet_depletion_normally_on_horz_default = defineSymbol5({
122
+ primitives: [
123
+ ...Object.values(paths4),
124
+ { ...texts4.right1, anchor: "middle_left" },
125
+ { ...texts4.right2, anchor: "middle_left" }
126
+ ],
127
+ ports: [
128
+ { ...refblocks4.top1, labels: ["1"] },
129
+ // TODO add more "standard" labels
130
+ { ...refblocks4.bottom1, labels: ["2"] },
131
+ // TODO add more "standard" labels
132
+ { ...refblocks4.left1, labels: ["3"] }
133
+ // TODO add more "standard" labels
134
+ ],
135
+ size: { width: bounds4.width + 0.4, height: bounds4.height },
136
+ center: { x: bounds4.centerX + 0.2, y: bounds4.centerY }
137
+ });
138
+
139
+ // symbols/mosfet_depletion_normally_on_vert.ts
140
+ import { rotateSymbol as rotateSymbol5 } from "drawing/rotateSymbol";
141
+ var rotated = rotateSymbol5(mosfet_depletion_normally_on_horz_default);
142
+ var ref = rotated.primitives.find(
143
+ (p) => p.type === "text" && p.text === "{REF}"
144
+ );
145
+ var val = rotated.primitives.find(
146
+ (p) => p.type === "text" && p.text === "{VAL}"
147
+ );
148
+ ref.anchor = "middle_top";
149
+ val.anchor = "middle_top";
150
+ ref.x = val.x;
151
+ val.y += 0.15;
152
+ var mosfet_depletion_normally_on_vert_default = rotated;
153
+
154
+ // symbols/potentiometer_horz.ts
155
+ import { defineSymbol as defineSymbol6 } from "drawing/defineSymbol";
156
+ import svgJson5 from "assets/symbols-svg-json/potentiometer.json";
157
+ var { paths: paths5, texts: texts5, bounds: bounds5, refblocks: refblocks5 } = svgJson5;
158
+ var potentiometer_horz_default = defineSymbol6({
159
+ primitives: [
160
+ ...Object.values(paths5),
161
+ { ...texts5.bottom1, y: 0.35, anchor: "middle_top" },
162
+ { ...texts5.right1, anchor: "middle_left" }
163
+ ],
164
+ ports: [
165
+ { ...refblocks5.left1, labels: ["1"] },
166
+ // TODO add more "standard" labels
167
+ { ...refblocks5.right1, labels: ["2"] }
168
+ // TODO add more "standard" labels
169
+ ],
170
+ size: { width: bounds5.width + 0.05, height: bounds5.height },
171
+ center: { x: bounds5.centerX, y: bounds5.centerY }
172
+ });
173
+
174
+ // symbols/potentiometer_vert.ts
175
+ import { rotateSymbol as rotateSymbol6 } from "drawing/rotateSymbol";
176
+ var rotated2 = rotateSymbol6(potentiometer_horz_default);
177
+ var potentiometer_vert_default = rotated2;
178
+
179
+ // symbols/potentiometer2_horz.ts
180
+ import { defineSymbol as defineSymbol7 } from "drawing/defineSymbol";
181
+ import svgJson6 from "assets/symbols-svg-json/potentiometer2.json";
182
+ var { paths: paths6, texts: texts6, bounds: bounds6, refblocks: refblocks6 } = svgJson6;
183
+ var potentiometer2_horz_default = defineSymbol7({
184
+ primitives: [...Object.values(paths6), ...Object.values(texts6)],
185
+ ports: [
186
+ { ...refblocks6.left1, labels: ["1"] },
187
+ // TODO add more "standard" labels
188
+ { ...refblocks6.right1, labels: ["2"] }
189
+ // TODO add more "standard" labels
190
+ ],
191
+ size: { width: bounds6.width, height: bounds6.height },
192
+ center: { x: bounds6.centerX, y: bounds6.centerY }
193
+ });
194
+
195
+ // symbols/potentiometer2_vert.ts
196
+ import { rotateSymbol as rotateSymbol7 } from "drawing/rotateSymbol";
197
+ var potentiometer2_vert_default = rotateSymbol7(potentiometer2_horz_default);
198
+
199
+ // symbols/varistor_horz.ts
200
+ import { defineSymbol as defineSymbol8 } from "drawing/defineSymbol";
201
+ import svgJson7 from "assets/symbols-svg-json/varistor.json";
202
+ var { paths: paths7, texts: texts7, bounds: bounds7, refblocks: refblocks7 } = svgJson7;
203
+ var varistor_horz_default = defineSymbol8({
204
+ primitives: [
205
+ ...Object.values(paths7),
206
+ { ...texts7.top1, anchor: "middle_left" },
207
+ { ...texts7.bottom1, anchor: "middle_right" }
208
+ ],
209
+ ports: [
210
+ {
211
+ ...refblocks7.left1,
212
+ labels: ["1", "-"]
213
+ },
214
+ {
215
+ ...refblocks7.right1,
216
+ labels: ["2", "+"]
217
+ }
218
+ ],
219
+ size: { width: bounds7.width, height: bounds7.height },
220
+ //{ width: 1, height: 0.24 },
221
+ center: { x: bounds7.centerX, y: bounds7.centerY }
222
+ });
223
+
224
+ // symbols/varistor_vert.ts
225
+ import { rotateSymbol as rotateSymbol8 } from "drawing/rotateSymbol";
226
+ var varistor_vert_default = rotateSymbol8(varistor_horz_default, {});
227
+
228
+ // generated/symbols-index.ts
229
+ var symbols_index_default = {
230
+ "boxresistor_horz": boxresistor_horz_default,
231
+ "boxresistor_vert": boxresistor_vert_default,
232
+ "diode_horz": diode_horz_default,
233
+ "diode_vert": diode_vert_default,
234
+ "fuse_horz": fuse_horz_default,
235
+ "fuse_vert": fuse_vert_default,
236
+ "led_horz": led_horz_default,
237
+ "led_vert": led_vert_default,
238
+ "mosfet_depletion_normally_on_horz": mosfet_depletion_normally_on_horz_default,
239
+ "mosfet_depletion_normally_on_vert": mosfet_depletion_normally_on_vert_default,
240
+ "potentiometer_horz": potentiometer_horz_default,
241
+ "potentiometer_vert": potentiometer_vert_default,
242
+ "potentiometer2_horz": potentiometer2_horz_default,
243
+ "potentiometer2_vert": potentiometer2_vert_default,
244
+ "varistor_horz": varistor_horz_default,
245
+ "varistor_vert": varistor_vert_default
246
+ };
247
+
248
+ // drawing/svgPathToPoints.ts
249
+ import { parseSVG, makeAbsolute } from "svg-path-parser";
250
+
251
+ // drawing/pathToSvgD.ts
252
+ function pathToSvgD(points, closed = false) {
253
+ const pathCommands = points.map((point, index) => `${index === 0 ? "M" : "L"}${point.x},${point.y}`).join(" ");
254
+ return closed ? `${pathCommands} Z` : pathCommands;
255
+ }
256
+
257
+ // drawing/mapColor.ts
258
+ var mapColor = (color) => {
259
+ switch (color) {
260
+ case "primary":
261
+ return "black";
262
+ case "secondary":
263
+ return "gray";
264
+ default:
265
+ return color;
266
+ }
267
+ };
268
+
269
+ // drawing/getSvg.ts
270
+ function createDiamondElement(center, size = 0.05) {
271
+ const { x, y } = center;
272
+ const halfSize = size / 2;
273
+ return `<path d="M ${x} ${y - halfSize} L ${x + halfSize} ${y} L ${x} ${y + halfSize} L ${x - halfSize} ${y} Z" fill="green" />`;
274
+ }
275
+ function createTextElement(primitive) {
276
+ const { x, y, text: text2, fontSize = 0.1, anchor } = primitive;
277
+ let textAnchor;
278
+ let dx = 0;
279
+ let dy = 0;
280
+ const capHeight = fontSize * 0.75;
281
+ switch (anchor) {
282
+ case "top_left":
283
+ textAnchor = "start";
284
+ dy = fontSize;
285
+ break;
286
+ case "top_right":
287
+ textAnchor = "end";
288
+ dy = fontSize;
289
+ break;
290
+ case "bottom_left":
291
+ textAnchor = "start";
292
+ break;
293
+ case "bottom_right":
294
+ textAnchor = "end";
295
+ break;
296
+ case "center":
297
+ textAnchor = "middle";
298
+ dy = fontSize / 2;
299
+ break;
300
+ case "middle_top":
301
+ textAnchor = "middle";
302
+ dy = capHeight;
303
+ break;
304
+ case "middle_bottom":
305
+ textAnchor = "middle";
306
+ break;
307
+ case "middle_left":
308
+ textAnchor = "start";
309
+ dy = capHeight / 2;
310
+ break;
311
+ case "middle_right":
312
+ textAnchor = "end";
313
+ dy = capHeight / 2;
314
+ break;
315
+ }
316
+ return {
317
+ text: `<text x="${x}" y="${y}" dx="${dx}" dy="${dy}" text-anchor="${textAnchor}" style="font: ${fontSize ?? 0.1}px monospace; fill: ${mapColor("primary")}">${text2}</text>`,
318
+ anchor: `<rect x="${x - 0.025 / 2}" y="${y - 0.025 / 2}" width="0.025" height="0.025" fill="blue" />`
319
+ };
320
+ }
321
+ function createPortElement(port) {
322
+ const { x, y, labels } = port;
323
+ const rectSize = 0.05;
324
+ const labelFontSize = 0.08;
325
+ const label = labels[0] || "";
326
+ return `
327
+ <rect x="${x - rectSize / 2}" y="${y - rectSize / 2}" width="${rectSize}" height="${rectSize}" fill="red" />
328
+ <text x="${x - labelFontSize / 2}" y="${y + rectSize + labelFontSize / 2}" text-anchor="middle" style="font: ${labelFontSize}px monospace; fill: #833;">${label}</text>
329
+ `;
330
+ }
331
+ function getInnerSvg(symbol, options = {}) {
332
+ const { debug = false } = options;
333
+ const { primitives, size, ports } = symbol;
334
+ const svgElements = primitives.map((primitive) => {
335
+ switch (primitive.type) {
336
+ case "path":
337
+ return `<path d="${pathToSvgD(primitive.points, primitive.closed)}" fill="${primitive.fill ? mapColor(primitive.color) : "none"}" stroke="${mapColor(primitive.color)}" stroke-width="0.02" stroke-linecap="round" stroke-linejoin="round" />`;
338
+ case "text":
339
+ const textElements = createTextElement(primitive);
340
+ return textElements.text + (debug ? textElements.anchor : "");
341
+ case "circle":
342
+ return `<circle cx="${primitive.x}" cy="${primitive.y}" r="${primitive.radius}" fill="${mapColor("primary")}" />`;
343
+ case "box":
344
+ return `<rect x="${primitive.x}" y="${primitive.y}" width="${primitive.width}" height="${primitive.height}" fill="${mapColor("primary")}" />`;
345
+ default:
346
+ return "";
347
+ }
348
+ });
349
+ const portElements = ports.map(createPortElement).join("\n ");
350
+ const centerDiamond = createDiamondElement(symbol.center);
351
+ return [svgElements.join("\n "), portElements, centerDiamond].join("\n");
352
+ }
353
+ function getSvg(symbol, options = {}) {
354
+ const { size } = symbol;
355
+ const innerSvg = getInnerSvg(symbol, options);
356
+ const bufferMultiple = 1.1;
357
+ const w = size.width * bufferMultiple;
358
+ const h = size.height * bufferMultiple;
359
+ const viewBox = {
360
+ x: symbol.center.x - w / 2,
361
+ y: symbol.center.y - h / 2,
362
+ width: w,
363
+ height: h
364
+ };
365
+ if (options.width && !options.height) {
366
+ options.height = options.width * (viewBox.height / viewBox.width);
367
+ } else if (!options.width && options.height) {
368
+ options.width = options.height * (viewBox.width / viewBox.height);
369
+ } else if (!options.width && !options.height) {
370
+ options.width = viewBox.width;
371
+ options.height = viewBox.height;
372
+ }
373
+ return `<svg width="${options.width}" height="${options.height}" viewBox="${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}" xmlns="http://www.w3.org/2000/svg">${innerSvg}</svg>`;
374
+ }
375
+
376
+ // drawing/resizeSymbol.ts
377
+ function resizeSymbol(symbol, newSize) {
378
+ const { width: oldWidth, height: oldHeight } = symbol.size;
379
+ let scaleX = 1, scaleY = 1;
380
+ if (newSize.width && newSize.height) {
381
+ scaleX = newSize.width / oldWidth;
382
+ scaleY = newSize.height / oldHeight;
383
+ } else if (newSize.width) {
384
+ scaleX = scaleY = newSize.width / oldWidth;
385
+ } else if (newSize.height) {
386
+ scaleX = scaleY = newSize.height / oldHeight;
387
+ }
388
+ const resizedPrimitives = symbol.primitives.map((primitive) => {
389
+ switch (primitive.type) {
390
+ case "path":
391
+ return {
392
+ ...primitive,
393
+ points: primitive.points.map((p) => ({
394
+ x: p.x * scaleX,
395
+ y: p.y * scaleY
396
+ }))
397
+ };
398
+ case "text":
399
+ case "circle":
400
+ return {
401
+ ...primitive,
402
+ x: primitive.x * scaleX,
403
+ y: primitive.y * scaleY
404
+ };
405
+ case "box":
406
+ return {
407
+ ...primitive,
408
+ x: primitive.x * scaleX,
409
+ y: primitive.y * scaleY,
410
+ width: primitive.width * scaleX,
411
+ height: primitive.height * scaleY
412
+ };
413
+ default:
414
+ return primitive;
415
+ }
416
+ });
417
+ return {
418
+ ...symbol,
419
+ primitives: resizedPrimitives,
420
+ center: {
421
+ x: symbol.center.x * scaleX,
422
+ y: symbol.center.y * scaleY
423
+ },
424
+ ports: symbol.ports.map((port) => ({
425
+ ...port,
426
+ x: port.x * scaleX,
427
+ y: port.y * scaleY
428
+ })),
429
+ size: {
430
+ width: oldWidth * scaleX,
431
+ height: oldHeight * scaleY
432
+ }
433
+ };
434
+ }
435
+
436
+ // index.ts
437
+ var BASE_SYMBOLS = Object.fromEntries(Object.keys(symbols_index_default).map((k) => [k, k]));
438
+ export {
439
+ BASE_SYMBOLS,
440
+ getInnerSvg,
441
+ getSvg,
442
+ resizeSymbol,
443
+ symbols_index_default as symbols
444
+ };
445
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../symbols/boxresistor_horz.ts","../symbols/boxresistor_vert.ts","../symbols/diode_horz.ts","../symbols/diode_vert.ts","../symbols/fuse_horz.ts","../symbols/fuse_vert.ts","../symbols/led_horz.ts","../symbols/led_vert.ts","../symbols/mosfet_depletion_normally_on_horz.ts","../symbols/mosfet_depletion_normally_on_vert.ts","../symbols/potentiometer_horz.ts","../symbols/potentiometer_vert.ts","../symbols/potentiometer2_horz.ts","../symbols/potentiometer2_vert.ts","../symbols/varistor_horz.ts","../symbols/varistor_vert.ts","../generated/symbols-index.ts","../drawing/svgPathToPoints.ts","../drawing/pathToSvgD.ts","../drawing/mapColor.ts","../drawing/getSvg.ts","../drawing/resizeSymbol.ts","../index.ts"],"sourcesContent":["import { path } from \"drawing/path\"\nimport { text } from \"drawing/text\"\nimport { defineSymbol } from \"drawing/defineSymbol\"\n\nexport default defineSymbol({\n primitives: [\n path({\n points: [\n { x: 0, y: 0 },\n { x: 0.2, y: 0 },\n { x: 0.2, y: -0.12 },\n { x: 0.8, y: -0.12 },\n { x: 0.8, y: 0.12 },\n { x: 0.2, y: 0.12 },\n { x: 0.2, y: 0 },\n ],\n color: \"primary\",\n }),\n path({\n points: [\n { x: 0.8, y: 0 },\n { x: 1, y: 0 },\n ],\n color: \"primary\",\n }),\n text(\"{REF}\", { x: 0.5, y: -0.2, anchor: \"middle_bottom\" }),\n text(\"{VAL}\", { x: 0.5, y: 0.2, anchor: \"middle_top\" }),\n ],\n ports: [\n { x: 0, y: 0, labels: [\"1\", \"-\", \"left\"] },\n { x: 1, y: 0, labels: [\"2\", \"+\", \"right\"] },\n ],\n center: { x: 0.5, y: 0 },\n size: { width: 1, height: 0.55 },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport boxresistor_horz from \"./boxresistor_horz\"\n\nexport default rotateSymbol(boxresistor_horz)\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/diode.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.top1, anchor: \"middle_left\" },\n { ...texts.bottom1, anchor: \"middle_left\" },\n ] as any,\n ports: [\n { ...refblocks.left1, labels: [\"1\"] }, // TODO add more \"standard\" labels\n { ...refblocks.right1, labels: [\"2\"] }, // TODO add more \"standard\" labels\n ],\n size: { width: bounds.width, height: bounds.height },\n center: { x: bounds.centerX, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport diode_horz from \"./diode_horz\"\n\nexport default rotateSymbol(diode_horz)\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/fuse.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.top1, anchor: \"middle_bottom\" },\n {\n type: \"text\",\n text: \"{VAL}\",\n x: 0,\n y: 0.2,\n anchor: \"middle_top\",\n },\n ] as any,\n ports: [\n { ...refblocks.left1, labels: [\"1\"] }, // TODO add more \"standard\" labels\n { ...refblocks.right1, labels: [\"2\"] }, // TODO add more \"standard\" labels\n ],\n size: { width: bounds.width, height: bounds.height },\n center: { x: bounds.centerX, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport fuse_horz from \"./fuse_horz\"\n\nexport default rotateSymbol(fuse_horz)\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/led.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.bottom1, anchor: \"middle_left\" },\n { ...texts.right1, anchor: \"middle_left\" },\n ] as any,\n ports: [\n { ...refblocks.left1, labels: [\"1\", \"anode\", \"pos\"] },\n { ...refblocks.right1, labels: [\"2\", \"cathode\", \"neg\"] },\n ],\n size: { width: bounds.width, height: bounds.height },\n center: { x: bounds.centerX, y: bounds.centerY + 0.1 },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport led_horz from \"./led_horz\"\n\nexport default rotateSymbol(led_horz)\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/mosfet_depletion_normally_on.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.right1, anchor: \"middle_left\" },\n { ...texts.right2, anchor: \"middle_left\" },\n ] as any,\n ports: [\n { ...refblocks.top1, labels: [\"1\"] }, // TODO add more \"standard\" labels\n { ...refblocks.bottom1, labels: [\"2\"] }, // TODO add more \"standard\" labels\n { ...refblocks.left1, labels: [\"3\"] }, // TODO add more \"standard\" labels\n ],\n size: { width: bounds.width + 0.4, height: bounds.height },\n center: { x: bounds.centerX + 0.2, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport mosfet_depletion_normally_on_horz from \"./mosfet_depletion_normally_on_horz\"\nimport type { TextPrimitive } from \"drawing\"\n\nconst rotated = rotateSymbol(mosfet_depletion_normally_on_horz)\n\nconst ref = rotated.primitives.find(\n (p) => p.type === \"text\" && p.text === \"{REF}\",\n)! as TextPrimitive\nconst val = rotated.primitives.find(\n (p) => p.type === \"text\" && p.text === \"{VAL}\",\n)! as TextPrimitive\n\nref.anchor = \"middle_top\"\nval.anchor = \"middle_top\"\n\nref.x = val.x\n\nval.y += 0.15\n\nexport default rotated\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/potentiometer.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.bottom1, y: 0.35, anchor: \"middle_top\" },\n { ...texts.right1, anchor: \"middle_left\" },\n ] as any,\n ports: [\n { ...refblocks.left1, labels: [\"1\"] }, // TODO add more \"standard\" labels\n { ...refblocks.right1, labels: [\"2\"] }, // TODO add more \"standard\" labels\n ],\n size: { width: bounds.width + 0.05, height: bounds.height },\n center: { x: bounds.centerX, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport potentiometer_horz from \"./potentiometer_horz\"\n\nconst rotated = rotateSymbol(potentiometer_horz)\n\nexport default rotated\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/potentiometer2.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [...Object.values(paths), ...Object.values(texts)] as any,\n ports: [\n { ...refblocks.left1, labels: [\"1\"] }, // TODO add more \"standard\" labels\n { ...refblocks.right1, labels: [\"2\"] }, // TODO add more \"standard\" labels\n ],\n size: { width: bounds.width, height: bounds.height },\n center: { x: bounds.centerX, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport potentiometer2_horz from \"./potentiometer2_horz\"\n\nexport default rotateSymbol(potentiometer2_horz)\n","import { defineSymbol } from \"drawing/defineSymbol\"\nimport svgJson from \"assets/symbols-svg-json/varistor.json\"\n\nconst { paths, texts, bounds, refblocks } = svgJson\n\nexport default defineSymbol({\n primitives: [\n ...Object.values(paths),\n { ...texts.top1, anchor: \"middle_left\" },\n { ...texts.bottom1, anchor: \"middle_right\" },\n ] as any,\n ports: [\n {\n ...refblocks.left1,\n labels: [\"1\", \"-\"],\n },\n {\n ...refblocks.right1,\n labels: [\"2\", \"+\"],\n },\n ],\n size: { width: bounds.width, height: bounds.height }, //{ width: 1, height: 0.24 },\n center: { x: bounds.centerX, y: bounds.centerY },\n})\n","import { rotateSymbol } from \"drawing/rotateSymbol\"\nimport varistor_horz from \"./varistor_horz\"\n\nexport default rotateSymbol(varistor_horz, {})\n","import _boxresistor_horz from \"./../symbols/boxresistor_horz\"\nimport _boxresistor_vert from \"./../symbols/boxresistor_vert\"\nimport _diode_horz from \"./../symbols/diode_horz\"\nimport _diode_vert from \"./../symbols/diode_vert\"\nimport _fuse_horz from \"./../symbols/fuse_horz\"\nimport _fuse_vert from \"./../symbols/fuse_vert\"\nimport _led_horz from \"./../symbols/led_horz\"\nimport _led_vert from \"./../symbols/led_vert\"\nimport _mosfet_depletion_normally_on_horz from \"./../symbols/mosfet_depletion_normally_on_horz\"\nimport _mosfet_depletion_normally_on_vert from \"./../symbols/mosfet_depletion_normally_on_vert\"\nimport _potentiometer_horz from \"./../symbols/potentiometer_horz\"\nimport _potentiometer_vert from \"./../symbols/potentiometer_vert\"\nimport _potentiometer2_horz from \"./../symbols/potentiometer2_horz\"\nimport _potentiometer2_vert from \"./../symbols/potentiometer2_vert\"\nimport _varistor_horz from \"./../symbols/varistor_horz\"\nimport _varistor_vert from \"./../symbols/varistor_vert\"\n\nexport default {\n \"boxresistor_horz\": _boxresistor_horz,\n \"boxresistor_vert\": _boxresistor_vert,\n \"diode_horz\": _diode_horz,\n \"diode_vert\": _diode_vert,\n \"fuse_horz\": _fuse_horz,\n \"fuse_vert\": _fuse_vert,\n \"led_horz\": _led_horz,\n \"led_vert\": _led_vert,\n \"mosfet_depletion_normally_on_horz\": _mosfet_depletion_normally_on_horz,\n \"mosfet_depletion_normally_on_vert\": _mosfet_depletion_normally_on_vert,\n \"potentiometer_horz\": _potentiometer_horz,\n \"potentiometer_vert\": _potentiometer_vert,\n \"potentiometer2_horz\": _potentiometer2_horz,\n \"potentiometer2_vert\": _potentiometer2_vert,\n \"varistor_horz\": _varistor_horz,\n \"varistor_vert\": _varistor_vert\n}","import { parseSVG, makeAbsolute } from \"svg-path-parser\"\n\nexport function svgPathToPoints(d: string): Array<{ x: number; y: number }> {\n const parsedPath = parseSVG(d)\n const absolutePath = makeAbsolute(parsedPath)\n\n const points: Array<{ x: number; y: number }> = []\n let firstPoint: { x: number; y: number } | null = null\n\n for (const command of absolutePath) {\n switch (command.code) {\n case \"M\":\n if (!firstPoint) {\n firstPoint = { x: command.x, y: command.y }\n }\n points.push({ x: command.x, y: command.y })\n break\n case \"L\":\n case \"H\":\n case \"V\":\n points.push({ x: command.x, y: command.y })\n break\n case \"C\":\n points.push(\n { x: command.x1, y: command.y1 },\n { x: command.x2, y: command.y2 },\n { x: command.x, y: command.y },\n )\n break\n case \"S\":\n case \"Q\":\n points.push(\n { x: command.x0, y: command.y0 },\n { x: command.x, y: command.y },\n )\n break\n case \"T\":\n case \"A\":\n points.push({ x: command.x, y: command.y })\n break\n case \"Z\":\n if (firstPoint) {\n points.push(firstPoint)\n }\n break\n }\n }\n\n return points\n}\n","import type { Point } from \"drawing\"\n\nexport function pathToSvgD(points: Point[], closed: boolean = false): string {\n const pathCommands = points\n .map((point, index) => `${index === 0 ? \"M\" : \"L\"}${point.x},${point.y}`)\n .join(\" \")\n\n return closed ? `${pathCommands} Z` : pathCommands\n}\n","export const mapColor = (color: string) => {\n switch (color) {\n case \"primary\":\n return \"black\"\n case \"secondary\":\n return \"gray\"\n default:\n return color\n }\n}\n","import { pathToSvgD } from \"./pathToSvgD\"\nimport { mapColor } from \"./mapColor\"\nimport type {\n NinePointAnchor,\n TextPrimitive,\n Port,\n SchSymbol,\n Point,\n} from \"./types\"\n\nfunction createDiamondElement(center: Point, size: number = 0.05): string {\n const { x, y } = center\n const halfSize = size / 2\n return `<path d=\"M ${x} ${y - halfSize} L ${x + halfSize} ${y} L ${x} ${y + halfSize} L ${x - halfSize} ${y} Z\" fill=\"green\" />`\n}\n\nfunction createTextElement(primitive: TextPrimitive): {\n text: string\n anchor: string\n} {\n const { x, y, text, fontSize = 0.1, anchor } = primitive\n let textAnchor: string\n let dx: number = 0\n let dy: number = 0\n\n const capHeight = fontSize * 0.75\n\n switch (anchor) {\n case \"top_left\":\n textAnchor = \"start\"\n dy = fontSize\n break\n case \"top_right\":\n textAnchor = \"end\"\n dy = fontSize\n break\n case \"bottom_left\":\n textAnchor = \"start\"\n break\n case \"bottom_right\":\n textAnchor = \"end\"\n break\n case \"center\":\n textAnchor = \"middle\"\n dy = fontSize / 2\n break\n case \"middle_top\":\n textAnchor = \"middle\"\n dy = capHeight\n break\n case \"middle_bottom\":\n textAnchor = \"middle\"\n break\n case \"middle_left\":\n textAnchor = \"start\"\n dy = capHeight / 2\n break\n case \"middle_right\":\n textAnchor = \"end\"\n dy = capHeight / 2\n break\n }\n\n return {\n text: `<text x=\"${x}\" y=\"${y}\" dx=\"${dx}\" dy=\"${dy}\" text-anchor=\"${textAnchor}\" style=\"font: ${fontSize ?? 0.1}px monospace; fill: ${mapColor(\"primary\")}\">${text}</text>`,\n anchor: `<rect x=\"${x - 0.025 / 2}\" y=\"${y - 0.025 / 2}\" width=\"0.025\" height=\"0.025\" fill=\"blue\" />`,\n }\n}\n\nfunction createPortElement(port: Port): string {\n const { x, y, labels } = port\n const rectSize = 0.05\n const labelFontSize = 0.08\n const label = labels[0] || \"\"\n\n return `\n <rect x=\"${x - rectSize / 2}\" y=\"${y - rectSize / 2}\" width=\"${rectSize}\" height=\"${rectSize}\" fill=\"red\" />\n <text x=\"${x - labelFontSize / 2}\" y=\"${y + rectSize + labelFontSize / 2}\" text-anchor=\"middle\" style=\"font: ${labelFontSize}px monospace; fill: #833;\">${label}</text>\n `\n}\n\nexport function getInnerSvg(\n symbol: SchSymbol,\n options: { width?: number; height?: number; debug?: boolean } = {},\n): string {\n const { debug = false } = options\n const { primitives, size, ports } = symbol\n const svgElements = primitives.map((primitive) => {\n switch (primitive.type) {\n case \"path\":\n return `<path d=\"${pathToSvgD(primitive.points, primitive.closed)}\" fill=\"${primitive.fill ? mapColor(primitive.color) : \"none\"}\" stroke=\"${mapColor(primitive.color)}\" stroke-width=\"0.02\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />`\n case \"text\":\n const textElements = createTextElement(primitive)\n return textElements.text + (debug ? textElements.anchor : \"\")\n case \"circle\":\n return `<circle cx=\"${primitive.x}\" cy=\"${primitive.y}\" r=\"${primitive.radius}\" fill=\"${mapColor(\"primary\")}\" />`\n case \"box\":\n return `<rect x=\"${primitive.x}\" y=\"${primitive.y}\" width=\"${primitive.width}\" height=\"${primitive.height}\" fill=\"${mapColor(\"primary\")}\" />`\n default:\n return \"\"\n }\n })\n\n const portElements = ports.map(createPortElement).join(\"\\n \")\n\n const centerDiamond = createDiamondElement(symbol.center)\n\n return [svgElements.join(\"\\n \"), portElements, centerDiamond].join(\"\\n\")\n}\n\nexport function getSvg(\n symbol: SchSymbol,\n options: { width?: number; height?: number; debug?: boolean } = {},\n): string {\n const { size } = symbol\n const innerSvg = getInnerSvg(symbol, options)\n\n // Use the center and the size to calculate the viewBox\n const bufferMultiple = 1.1\n const w = size.width * bufferMultiple\n const h = size.height * bufferMultiple\n const viewBox = {\n x: symbol.center.x - w / 2,\n y: symbol.center.y - h / 2,\n width: w,\n height: h,\n }\n\n if (options.width && !options.height) {\n options.height = options.width! * (viewBox.height / viewBox.width)\n } else if (!options.width && options.height) {\n options.width = options.height! * (viewBox.width / viewBox.height)\n } else if (!options.width && !options.height) {\n options.width = viewBox.width\n options.height = viewBox.height\n }\n\n return `<svg width=\"${options.width}\" height=\"${options.height}\" viewBox=\"${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}\" xmlns=\"http://www.w3.org/2000/svg\">${innerSvg}</svg>`\n}\n","import { SchSymbol } from \"./types\"\nexport function resizeSymbol(\n symbol: SchSymbol,\n newSize: { width?: number; height?: number },\n): SchSymbol {\n const { width: oldWidth, height: oldHeight } = symbol.size\n let scaleX = 1,\n scaleY = 1\n\n if (newSize.width && newSize.height) {\n scaleX = newSize.width / oldWidth\n scaleY = newSize.height / oldHeight\n } else if (newSize.width) {\n scaleX = scaleY = newSize.width / oldWidth\n } else if (newSize.height) {\n scaleX = scaleY = newSize.height / oldHeight\n }\n\n const resizedPrimitives = symbol.primitives.map((primitive) => {\n switch (primitive.type) {\n case \"path\":\n return {\n ...primitive,\n points: primitive.points.map((p) => ({\n x: p.x * scaleX,\n y: p.y * scaleY,\n })),\n }\n case \"text\":\n case \"circle\":\n return {\n ...primitive,\n x: primitive.x * scaleX,\n y: primitive.y * scaleY,\n }\n case \"box\":\n return {\n ...primitive,\n x: primitive.x * scaleX,\n y: primitive.y * scaleY,\n width: primitive.width * scaleX,\n height: primitive.height * scaleY,\n }\n default:\n return primitive\n }\n })\n\n return {\n ...symbol,\n primitives: resizedPrimitives,\n center: {\n x: symbol.center.x * scaleX,\n y: symbol.center.y * scaleY,\n },\n ports: symbol.ports.map((port) => ({\n ...port,\n x: port.x * scaleX,\n y: port.y * scaleY,\n })),\n size: {\n width: oldWidth * scaleX,\n height: oldHeight * scaleY,\n },\n }\n}\n","import symbols from \"./generated/symbols-index\"\n\nexport type {\n SchSymbol,\n BoxPrimitive,\n CirclePrimitive,\n PathPrimitive,\n TextPrimitive,\n} from \"./drawing/types\"\nimport { getSvg, getInnerSvg, resizeSymbol } from \"./drawing\"\n\nimport { BaseSymbolName } from \"./generated/base-symbol-names\"\n\n/**\n * Utility for easier autocomplete:\n *\n * ```ts\n * BASE_SYMBOLS.boxresistor // \"boxresistor\"\n * ```\n */\nexport const BASE_SYMBOLS: Record<BaseSymbolName, BaseSymbolName> =\n Object.fromEntries(Object.keys(symbols).map((k) => [k, k])) as any\n\nexport { symbols, getSvg, getInnerSvg, resizeSymbol, BaseSymbolName }\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAA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AAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG,UAAU,IAAI;AAAA,UACjB,GAAG,UAAU,IAAI;AAAA,UACjB,OAAO,UAAU,QAAQ;AAAA,UACzB,QAAQ,UAAU,SAAS;AAAA,QAC7B;AAAA,MACF;AACE,eAAO;AAAA,IACX;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,GAAG,OAAO,OAAO,IAAI;AAAA,MACrB,GAAG,OAAO,OAAO,IAAI;AAAA,IACvB;AAAA,IACA,OAAO,OAAO,MAAM,IAAI,CAAC,UAAU;AAAA,MACjC,GAAG;AAAA,MACH,GAAG,KAAK,IAAI;AAAA,MACZ,GAAG,KAAK,IAAI;AAAA,IACd,EAAE;AAAA,IACF,MAAM;AAAA,MACJ,OAAO,WAAW;AAAA,MAClB,QAAQ,YAAY;AAAA,IACtB;AAAA,EACF;AACF;;;AC7CO,IAAM,eACX,OAAO,YAAY,OAAO,KAAK,qBAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;","names":["defineSymbol","rotateSymbol","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotated","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotateSymbol","defineSymbol","svgJson","paths","texts","bounds","refblocks","rotateSymbol","rotateSymbol","text"]}
package/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import symbols from "./symbols"
1
+ import symbols from "./generated/symbols-index"
2
2
 
3
3
  export type {
4
4
  SchSymbol,
@@ -9,16 +9,16 @@ export type {
9
9
  } from "./drawing/types"
10
10
  import { getSvg, getInnerSvg, resizeSymbol } from "./drawing"
11
11
 
12
- export type BaseSymbolName =
13
- keyof typeof symbols extends `${infer T}_${infer U}` ? `${T}` : never
12
+ import { BaseSymbolName } from "./generated/base-symbol-names"
14
13
 
15
14
  /**
16
15
  * Utility for easier autocomplete:
17
16
  *
18
- * BASE_SYMBOLS.boxresistor
19
- * // "boxresistor"
17
+ * ```ts
18
+ * BASE_SYMBOLS.boxresistor // "boxresistor"
19
+ * ```
20
20
  */
21
21
  export const BASE_SYMBOLS: Record<BaseSymbolName, BaseSymbolName> =
22
22
  Object.fromEntries(Object.keys(symbols).map((k) => [k, k])) as any
23
23
 
24
- export { symbols, getSvg, getInnerSvg, resizeSymbol }
24
+ export { symbols, getSvg, getInnerSvg, resizeSymbol, BaseSymbolName }
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "schematic-symbols",
3
- "main": "./dist/index.cjs",
4
- "types": "./index.ts",
5
- "version": "0.0.13",
3
+ "main": "./dist/index.js",
4
+ "version": "0.0.15",
6
5
  "type": "module",
7
6
  "files": [
8
7
  "dist",
@@ -12,7 +11,7 @@
12
11
  ],
13
12
  "scripts": {
14
13
  "start": "bun run build && bun --hot run dev-server.ts",
15
- "build": "rm symbols/index.ts && bunx make-vfs ./symbols --content-format import-default --outfile ./symbols/index.ts && tsup ./index.ts --dts --sourcemap",
14
+ "build": "bunx make-vfs ./symbols --content-format import-default --outfile ./generated/symbols-index.ts && tsup-node ./index.ts --format esm --dts --sourcemap && bun run scripts/generate-base-symbol-names.ts",
16
15
  "generate": "bun run scripts/generate-symbols-from-asset-svgs.ts && bun run format",
17
16
  "format:check": "bunx biome format",
18
17
  "format": "bunx biome format . --write",
@@ -29,7 +28,7 @@
29
28
  "tsup": "^8.2.4"
30
29
  },
31
30
  "peerDependencies": {
32
- "typescript": "^5.0.0"
31
+ "typescript": "^5.5.4"
33
32
  },
34
33
  "dependencies": {}
35
34
  }
@@ -27,8 +27,8 @@ export default defineSymbol({
27
27
  text("{VAL}", { x: 0.5, y: 0.2, anchor: "middle_top" }),
28
28
  ],
29
29
  ports: [
30
- { x: 0, y: 0, labels: ["1", "-"] },
31
- { x: 1, y: 0, labels: ["2", "+"] },
30
+ { x: 0, y: 0, labels: ["1", "-", "left"] },
31
+ { x: 1, y: 0, labels: ["2", "+", "right"] },
32
32
  ],
33
33
  center: { x: 0.5, y: 0 },
34
34
  size: { width: 1, height: 0.55 },