circuit-to-svg 0.0.180 → 0.0.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +94 -42
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1495,7 +1495,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1495
1495
|
var package_default = {
|
|
1496
1496
|
name: "circuit-to-svg",
|
|
1497
1497
|
type: "module",
|
|
1498
|
-
version: "0.0.
|
|
1498
|
+
version: "0.0.181",
|
|
1499
1499
|
description: "Convert Circuit JSON to SVG",
|
|
1500
1500
|
main: "dist/index.js",
|
|
1501
1501
|
files: [
|
|
@@ -1520,9 +1520,10 @@ var package_default = {
|
|
|
1520
1520
|
esbuild: "^0.20.2",
|
|
1521
1521
|
"performance-now": "^2.1.0",
|
|
1522
1522
|
react: "19.1.0",
|
|
1523
|
+
"react-dom": "19.1.0",
|
|
1523
1524
|
"react-cosmos": "7.0.0",
|
|
1524
1525
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
1525
|
-
tscircuit: "^0.0.
|
|
1526
|
+
tscircuit: "^0.0.617",
|
|
1526
1527
|
tsup: "^8.0.2",
|
|
1527
1528
|
typescript: "^5.4.5",
|
|
1528
1529
|
"vite-tsconfig-paths": "^5.0.1"
|
|
@@ -5240,7 +5241,8 @@ function createSchematicTrace({
|
|
|
5240
5241
|
}) {
|
|
5241
5242
|
const edges = trace.edges;
|
|
5242
5243
|
if (edges.length === 0) return [];
|
|
5243
|
-
const
|
|
5244
|
+
const baseObjects = [];
|
|
5245
|
+
const overlayObjects = [];
|
|
5244
5246
|
let path = "";
|
|
5245
5247
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
5246
5248
|
const edge = edges[edgeIndex];
|
|
@@ -5259,6 +5261,38 @@ function createSchematicTrace({
|
|
|
5259
5261
|
path += ` L ${screenToX} ${screenToY}`;
|
|
5260
5262
|
}
|
|
5261
5263
|
}
|
|
5264
|
+
if (path) {
|
|
5265
|
+
baseObjects.push({
|
|
5266
|
+
name: "path",
|
|
5267
|
+
type: "element",
|
|
5268
|
+
attributes: {
|
|
5269
|
+
d: path,
|
|
5270
|
+
class: "trace-invisible-hover-outline",
|
|
5271
|
+
stroke: colorMap2.schematic.wire,
|
|
5272
|
+
fill: "none",
|
|
5273
|
+
"stroke-width": `${getSchStrokeSize(transform) * 8}px`,
|
|
5274
|
+
"stroke-linecap": "round",
|
|
5275
|
+
opacity: "0",
|
|
5276
|
+
"stroke-linejoin": "round"
|
|
5277
|
+
},
|
|
5278
|
+
value: "",
|
|
5279
|
+
children: []
|
|
5280
|
+
});
|
|
5281
|
+
baseObjects.push({
|
|
5282
|
+
name: "path",
|
|
5283
|
+
type: "element",
|
|
5284
|
+
attributes: {
|
|
5285
|
+
d: path,
|
|
5286
|
+
stroke: colorMap2.schematic.wire,
|
|
5287
|
+
fill: "none",
|
|
5288
|
+
"stroke-width": `${getSchStrokeSize(transform)}px`,
|
|
5289
|
+
"stroke-linecap": "round",
|
|
5290
|
+
"stroke-linejoin": "round"
|
|
5291
|
+
},
|
|
5292
|
+
value: "",
|
|
5293
|
+
children: []
|
|
5294
|
+
});
|
|
5295
|
+
}
|
|
5262
5296
|
for (const edge of edges) {
|
|
5263
5297
|
if (!edge.is_crossing) continue;
|
|
5264
5298
|
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
@@ -5279,7 +5313,7 @@ function createSchematicTrace({
|
|
|
5279
5313
|
const perpY = dx / len * hopHeight;
|
|
5280
5314
|
const controlX = midX + perpX;
|
|
5281
5315
|
const controlY = midY - Math.abs(perpY);
|
|
5282
|
-
|
|
5316
|
+
overlayObjects.push({
|
|
5283
5317
|
name: "path",
|
|
5284
5318
|
type: "element",
|
|
5285
5319
|
attributes: {
|
|
@@ -5288,12 +5322,12 @@ function createSchematicTrace({
|
|
|
5288
5322
|
stroke: colorMap2.schematic.background,
|
|
5289
5323
|
fill: "none",
|
|
5290
5324
|
"stroke-width": `${getSchStrokeSize(transform) * 1.5}px`,
|
|
5291
|
-
"stroke-linecap": "
|
|
5325
|
+
"stroke-linecap": "butt"
|
|
5292
5326
|
},
|
|
5293
5327
|
value: "",
|
|
5294
5328
|
children: []
|
|
5295
5329
|
});
|
|
5296
|
-
|
|
5330
|
+
overlayObjects.push({
|
|
5297
5331
|
name: "path",
|
|
5298
5332
|
type: "element",
|
|
5299
5333
|
attributes: {
|
|
@@ -5307,45 +5341,13 @@ function createSchematicTrace({
|
|
|
5307
5341
|
children: []
|
|
5308
5342
|
});
|
|
5309
5343
|
}
|
|
5310
|
-
if (path) {
|
|
5311
|
-
svgObjects.push({
|
|
5312
|
-
name: "path",
|
|
5313
|
-
type: "element",
|
|
5314
|
-
attributes: {
|
|
5315
|
-
d: path,
|
|
5316
|
-
class: "trace-invisible-hover-outline",
|
|
5317
|
-
stroke: colorMap2.schematic.wire,
|
|
5318
|
-
fill: "none",
|
|
5319
|
-
"stroke-width": `${getSchStrokeSize(transform) * 8}px`,
|
|
5320
|
-
"stroke-linecap": "round",
|
|
5321
|
-
opacity: "0",
|
|
5322
|
-
"stroke-linejoin": "round"
|
|
5323
|
-
},
|
|
5324
|
-
value: "",
|
|
5325
|
-
children: []
|
|
5326
|
-
});
|
|
5327
|
-
svgObjects.push({
|
|
5328
|
-
name: "path",
|
|
5329
|
-
type: "element",
|
|
5330
|
-
attributes: {
|
|
5331
|
-
d: path,
|
|
5332
|
-
stroke: colorMap2.schematic.wire,
|
|
5333
|
-
fill: "none",
|
|
5334
|
-
"stroke-width": `${getSchStrokeSize(transform)}px`,
|
|
5335
|
-
"stroke-linecap": "round",
|
|
5336
|
-
"stroke-linejoin": "round"
|
|
5337
|
-
},
|
|
5338
|
-
value: "",
|
|
5339
|
-
children: []
|
|
5340
|
-
});
|
|
5341
|
-
}
|
|
5342
5344
|
if (trace.junctions) {
|
|
5343
5345
|
for (const junction of trace.junctions) {
|
|
5344
5346
|
const [screenX, screenY] = applyToPoint38(transform, [
|
|
5345
5347
|
junction.x,
|
|
5346
5348
|
junction.y
|
|
5347
5349
|
]);
|
|
5348
|
-
|
|
5350
|
+
overlayObjects.push({
|
|
5349
5351
|
name: "circle",
|
|
5350
5352
|
type: "element",
|
|
5351
5353
|
attributes: {
|
|
@@ -5367,10 +5369,29 @@ function createSchematicTrace({
|
|
|
5367
5369
|
value: "",
|
|
5368
5370
|
attributes: {
|
|
5369
5371
|
class: "trace",
|
|
5372
|
+
"data-layer": "base",
|
|
5373
|
+
"data-circuit-json-type": "schematic_trace",
|
|
5374
|
+
"data-schematic-trace-id": trace.schematic_trace_id,
|
|
5375
|
+
...trace.subcircuit_connectivity_map_key && {
|
|
5376
|
+
"data-subcircuit-connectivity-map-key": trace.subcircuit_connectivity_map_key
|
|
5377
|
+
}
|
|
5378
|
+
},
|
|
5379
|
+
children: baseObjects
|
|
5380
|
+
},
|
|
5381
|
+
{
|
|
5382
|
+
name: "g",
|
|
5383
|
+
type: "element",
|
|
5384
|
+
value: "",
|
|
5385
|
+
attributes: {
|
|
5386
|
+
class: "trace-overlays",
|
|
5387
|
+
"data-layer": "overlay",
|
|
5370
5388
|
"data-circuit-json-type": "schematic_trace",
|
|
5371
|
-
"data-schematic-trace-id": trace.schematic_trace_id
|
|
5389
|
+
"data-schematic-trace-id": trace.schematic_trace_id,
|
|
5390
|
+
...trace.subcircuit_connectivity_map_key && {
|
|
5391
|
+
"data-subcircuit-connectivity-map-key": trace.subcircuit_connectivity_map_key
|
|
5392
|
+
}
|
|
5372
5393
|
},
|
|
5373
|
-
children:
|
|
5394
|
+
children: overlayObjects
|
|
5374
5395
|
}
|
|
5375
5396
|
];
|
|
5376
5397
|
}
|
|
@@ -6053,6 +6074,23 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
6053
6074
|
};
|
|
6054
6075
|
|
|
6055
6076
|
// lib/sch/convert-circuit-json-to-schematic-svg.ts
|
|
6077
|
+
function buildNetHoverStyles(connectivityKeys) {
|
|
6078
|
+
const rules = [];
|
|
6079
|
+
const esc = (v) => String(v).replace(/"/g, '\\"');
|
|
6080
|
+
for (const key of connectivityKeys) {
|
|
6081
|
+
const k = esc(key);
|
|
6082
|
+
const keyAttr = `[data-subcircuit-connectivity-map-key="${k}"]`;
|
|
6083
|
+
const baseSel = `g.trace${keyAttr}`;
|
|
6084
|
+
const overlaySel = `g.trace-overlays${keyAttr}`;
|
|
6085
|
+
const hovered = `:is(${baseSel}, ${overlaySel}):hover`;
|
|
6086
|
+
const target = `:is(${baseSel}, ${overlaySel})`;
|
|
6087
|
+
rules.push(`svg:has(${hovered}) ${target} { filter: invert(1); }`);
|
|
6088
|
+
rules.push(
|
|
6089
|
+
`svg:has(${hovered}) ${overlaySel} .trace-crossing-outline { opacity: 0; }`
|
|
6090
|
+
);
|
|
6091
|
+
}
|
|
6092
|
+
return rules.join("\n");
|
|
6093
|
+
}
|
|
6056
6094
|
function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
6057
6095
|
const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
|
|
6058
6096
|
const realWidth = realBounds.maxX - realBounds.minX;
|
|
@@ -6118,6 +6156,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6118
6156
|
const schDebugObjectSvgs = [];
|
|
6119
6157
|
const schComponentSvgs = [];
|
|
6120
6158
|
const schTraceSvgs = [];
|
|
6159
|
+
const connectivityKeys = /* @__PURE__ */ new Set();
|
|
6121
6160
|
const schNetLabel = [];
|
|
6122
6161
|
const schText = [];
|
|
6123
6162
|
const voltageProbeSvgs = [];
|
|
@@ -6164,6 +6203,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6164
6203
|
colorMap: colorMap2
|
|
6165
6204
|
})
|
|
6166
6205
|
);
|
|
6206
|
+
connectivityKeys.add(elm.subcircuit_connectivity_map_key);
|
|
6167
6207
|
} else if (elm.type === "schematic_net_label") {
|
|
6168
6208
|
schNetLabel.push(
|
|
6169
6209
|
...createSvgObjectsForSchNetLabel({
|
|
@@ -6199,9 +6239,16 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6199
6239
|
);
|
|
6200
6240
|
}
|
|
6201
6241
|
}
|
|
6242
|
+
const schTraceBaseSvgs = schTraceSvgs.filter(
|
|
6243
|
+
(o) => o.attributes?.["data-layer"] !== "overlay"
|
|
6244
|
+
);
|
|
6245
|
+
const schTraceOverlaySvgs = schTraceSvgs.filter(
|
|
6246
|
+
(o) => o.attributes?.["data-layer"] === "overlay"
|
|
6247
|
+
);
|
|
6202
6248
|
svgChildren.push(
|
|
6203
6249
|
...schDebugObjectSvgs,
|
|
6204
|
-
...
|
|
6250
|
+
...schTraceBaseSvgs,
|
|
6251
|
+
...schTraceOverlaySvgs,
|
|
6205
6252
|
...schComponentSvgs,
|
|
6206
6253
|
...schPortHoverSvgs,
|
|
6207
6254
|
...schNetLabel,
|
|
@@ -6252,6 +6299,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6252
6299
|
.component { fill: none; stroke: ${colorMap2.schematic.component_outline}; }
|
|
6253
6300
|
.chip { fill: ${colorMap2.schematic.component_body}; stroke: ${colorMap2.schematic.component_outline}; }
|
|
6254
6301
|
.component-pin { fill: none; stroke: ${colorMap2.schematic.component_outline}; }
|
|
6302
|
+
/* Basic per-trace hover fallback */
|
|
6255
6303
|
.trace:hover {
|
|
6256
6304
|
filter: invert(1);
|
|
6257
6305
|
}
|
|
@@ -6261,6 +6309,10 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6261
6309
|
.trace:hover .trace-junction {
|
|
6262
6310
|
filter: invert(1);
|
|
6263
6311
|
}
|
|
6312
|
+
/* Net-hover highlighting: when a trace or its overlays are hovered,
|
|
6313
|
+
invert color for all traces (base + overlays) sharing the same
|
|
6314
|
+
subcircuit connectivity key. Also hide crossing outline during hover. */
|
|
6315
|
+
${buildNetHoverStyles(connectivityKeys)}
|
|
6264
6316
|
.text { font-family: sans-serif; fill: ${colorMap2.schematic.wire}; }
|
|
6265
6317
|
.pin-number { fill: ${colorMap2.schematic.pin_number}; }
|
|
6266
6318
|
.port-label { fill: ${colorMap2.schematic.reference}; }
|