@tscircuit/core 0.0.1305 → 0.0.1306
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 +30 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9343,6 +9343,20 @@ var getFacingDirectionFromSide = (side) => {
|
|
|
9343
9343
|
}
|
|
9344
9344
|
return null;
|
|
9345
9345
|
};
|
|
9346
|
+
var schematicPrimitiveTypesWithStrokeWidth = [
|
|
9347
|
+
"schematic_line",
|
|
9348
|
+
"schematic_rect",
|
|
9349
|
+
"schematic_circle",
|
|
9350
|
+
"schematic_arc",
|
|
9351
|
+
"schematic_path"
|
|
9352
|
+
];
|
|
9353
|
+
var isSchematicPrimitiveWithStrokeWidth = (elm) => schematicPrimitiveTypesWithStrokeWidth.includes(
|
|
9354
|
+
elm.type
|
|
9355
|
+
);
|
|
9356
|
+
var getSchematicSymbolId = (elm) => {
|
|
9357
|
+
if (!("schematic_symbol_id" in elm)) return void 0;
|
|
9358
|
+
return typeof elm.schematic_symbol_id === "string" ? elm.schematic_symbol_id : void 0;
|
|
9359
|
+
};
|
|
9346
9360
|
var createComponentsFromCircuitJson = ({
|
|
9347
9361
|
componentName,
|
|
9348
9362
|
componentRotation,
|
|
@@ -9353,6 +9367,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
9353
9367
|
const components = [];
|
|
9354
9368
|
const schematicSymbolsByImportedId = /* @__PURE__ */ new Map();
|
|
9355
9369
|
const schematicComponentsByImportedId = /* @__PURE__ */ new Map();
|
|
9370
|
+
const schematicStrokeWidthBySymbolId = /* @__PURE__ */ new Map();
|
|
9356
9371
|
for (const elm of circuitJson) {
|
|
9357
9372
|
if (elm.type !== "schematic_symbol") continue;
|
|
9358
9373
|
const schematicSymbol = new SymbolComponent({
|
|
@@ -9361,13 +9376,22 @@ var createComponentsFromCircuitJson = ({
|
|
|
9361
9376
|
schematicSymbolsByImportedId.set(elm.schematic_symbol_id, schematicSymbol);
|
|
9362
9377
|
components.push(schematicSymbol);
|
|
9363
9378
|
}
|
|
9379
|
+
for (const elm of circuitJson) {
|
|
9380
|
+
if (!isSchematicPrimitiveWithStrokeWidth(elm)) continue;
|
|
9381
|
+
const schematicSymbolId = getSchematicSymbolId(elm);
|
|
9382
|
+
const strokeWidth = elm.stroke_width;
|
|
9383
|
+
if (!schematicSymbolId || typeof strokeWidth !== "number" || !Number.isFinite(strokeWidth) || schematicStrokeWidthBySymbolId.has(schematicSymbolId)) {
|
|
9384
|
+
continue;
|
|
9385
|
+
}
|
|
9386
|
+
schematicStrokeWidthBySymbolId.set(schematicSymbolId, strokeWidth);
|
|
9387
|
+
}
|
|
9364
9388
|
for (const elm of circuitJson) {
|
|
9365
9389
|
if (elm.type !== "schematic_component") continue;
|
|
9366
9390
|
schematicComponentsByImportedId.set(elm.schematic_component_id, elm);
|
|
9367
9391
|
}
|
|
9368
9392
|
const addSchematicPrimitive = (elm, primitive) => {
|
|
9369
|
-
const schematicSymbolId = elm
|
|
9370
|
-
const parentSymbol =
|
|
9393
|
+
const schematicSymbolId = getSchematicSymbolId(elm);
|
|
9394
|
+
const parentSymbol = schematicSymbolId ? schematicSymbolsByImportedId.get(schematicSymbolId) : void 0;
|
|
9371
9395
|
if (parentSymbol) {
|
|
9372
9396
|
parentSymbol.add(primitive);
|
|
9373
9397
|
} else {
|
|
@@ -9930,6 +9954,9 @@ var createComponentsFromCircuitJson = ({
|
|
|
9930
9954
|
y1: elm.center.y,
|
|
9931
9955
|
x2: portCenter.x,
|
|
9932
9956
|
y2: portCenter.y,
|
|
9957
|
+
strokeWidth: typeof schematicSymbolId === "string" ? optional(
|
|
9958
|
+
schematicStrokeWidthBySymbolId.get(schematicSymbolId)
|
|
9959
|
+
) : void 0,
|
|
9933
9960
|
isDashed: false
|
|
9934
9961
|
})
|
|
9935
9962
|
);
|
|
@@ -23429,7 +23456,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
23429
23456
|
var package_default = {
|
|
23430
23457
|
name: "@tscircuit/core",
|
|
23431
23458
|
type: "module",
|
|
23432
|
-
version: "0.0.
|
|
23459
|
+
version: "0.0.1305",
|
|
23433
23460
|
types: "dist/index.d.ts",
|
|
23434
23461
|
main: "dist/index.js",
|
|
23435
23462
|
module: "dist/index.js",
|