@tscircuit/core 0.0.1384 → 0.0.1386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -6
- package/dist/index.js +274 -58
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -239,9 +239,9 @@ interface IIsolatedCircuit {
|
|
|
239
239
|
interface IRootCircuit extends IIsolatedCircuit {
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicSheetRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbAutoplaceBreakoutPoints", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
|
|
242
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "ResolveFootprintPinLabels", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicSheetRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbAutoplaceBreakoutPoints", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
|
|
243
243
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
244
|
-
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicSheetRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbAutoplaceBreakoutPoints" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
|
|
244
|
+
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "ResolveFootprintPinLabels" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicSheetRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbAutoplaceBreakoutPoints" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
|
|
245
245
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
246
246
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
247
247
|
initialized: boolean;
|
|
@@ -2173,6 +2173,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2173
2173
|
_hasStartedSupplierFootprintMismatchWarningCheck: boolean;
|
|
2174
2174
|
private _invalidFootprintPropMessages;
|
|
2175
2175
|
_invalidPinLabelMessages: string[];
|
|
2176
|
+
_impliedFootprintPinLabels?: Record<string, string | string[]>;
|
|
2176
2177
|
/**
|
|
2177
2178
|
* Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
|
|
2178
2179
|
*/
|
|
@@ -2203,6 +2204,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2203
2204
|
pinCount?: number;
|
|
2204
2205
|
ignoreSymbolPorts?: boolean;
|
|
2205
2206
|
}): void;
|
|
2207
|
+
_resolvePinLabels(): Record<string, string | string[]> | undefined;
|
|
2206
2208
|
_getImpliedFootprintString(): string | null;
|
|
2207
2209
|
resolveFootprint(): any;
|
|
2208
2210
|
_addChildrenFromStringFootprint(): void;
|
|
@@ -2242,6 +2244,8 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2242
2244
|
updateSchematicComponentSizeCalculation(): void;
|
|
2243
2245
|
doInitialPcbComponentAnchorAlignment(): void;
|
|
2244
2246
|
updatePcbComponentAnchorAlignment(): void;
|
|
2247
|
+
doInitialResolveFootprintPinLabels(): void;
|
|
2248
|
+
updateResolveFootprintPinLabels(): void;
|
|
2245
2249
|
_renderReactSubtree(element: ReactElement): ReactSubtree;
|
|
2246
2250
|
doInitialInitializePortsFromChildren(): void;
|
|
2247
2251
|
updateInitializePortsFromChildren(): void;
|
|
@@ -2268,6 +2272,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2268
2272
|
add(componentOrElm: PrimitiveComponent | ReactElement): void;
|
|
2269
2273
|
getPortsFromFootprint(opts?: {
|
|
2270
2274
|
additionalAliases?: Record<string, string[]>;
|
|
2275
|
+
allowImplicitPinNumbers?: boolean;
|
|
2271
2276
|
collectInferredInternallyConnectedPins?: boolean;
|
|
2272
2277
|
}): Port[];
|
|
2273
2278
|
private _queueInvalidFootprintPropMessage;
|
|
@@ -25969,6 +25974,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
25969
25974
|
photo: zod.ZodOptional<zod.ZodBoolean>;
|
|
25970
25975
|
tvs: zod.ZodOptional<zod.ZodBoolean>;
|
|
25971
25976
|
schOrientation: zod.ZodOptional<zod.ZodEnum<["vertical", "horizontal", "pos_top", "pos_bottom", "pos_left", "pos_right", "neg_top", "neg_bottom", "neg_left", "neg_right"]>>;
|
|
25977
|
+
pinLabels: zod.ZodOptional<zod.ZodRecord<zod.ZodEnum<["pin1", "left", "anode", "pos", "pin2", "right", "cathode", "neg"]>, zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodReadonly<zod.ZodArray<zod.ZodString, "many">>]>, zod.ZodArray<zod.ZodString, "many">]>>>;
|
|
25972
25978
|
}, "strip", zod.ZodTypeAny, {
|
|
25973
25979
|
name: string;
|
|
25974
25980
|
variant: "standard" | "schottky" | "zener" | "avalanche" | "photo" | "tvs";
|
|
@@ -26549,6 +26555,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
26549
26555
|
schSectionName?: string | undefined;
|
|
26550
26556
|
schSheetName?: string | undefined;
|
|
26551
26557
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
26558
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
26552
26559
|
standard?: boolean | undefined;
|
|
26553
26560
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
26554
26561
|
schottky?: boolean | undefined;
|
|
@@ -27137,6 +27144,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
27137
27144
|
schSectionName?: string | undefined;
|
|
27138
27145
|
schSheetName?: string | undefined;
|
|
27139
27146
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
27147
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
27140
27148
|
standard?: boolean | undefined;
|
|
27141
27149
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
27142
27150
|
schottky?: boolean | undefined;
|
|
@@ -27725,6 +27733,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
27725
27733
|
schSectionName?: string | undefined;
|
|
27726
27734
|
schSheetName?: string | undefined;
|
|
27727
27735
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
27736
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
27728
27737
|
standard?: boolean | undefined;
|
|
27729
27738
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
27730
27739
|
schottky?: boolean | undefined;
|
|
@@ -28313,6 +28322,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
28313
28322
|
schSectionName?: string | undefined;
|
|
28314
28323
|
schSheetName?: string | undefined;
|
|
28315
28324
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
28325
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
28316
28326
|
standard?: boolean | undefined;
|
|
28317
28327
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
28318
28328
|
schottky?: boolean | undefined;
|
|
@@ -28907,6 +28917,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
28907
28917
|
schSectionName?: string | undefined;
|
|
28908
28918
|
schSheetName?: string | undefined;
|
|
28909
28919
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
28920
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
28910
28921
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
28911
28922
|
}, {
|
|
28912
28923
|
name: string;
|
|
@@ -29489,6 +29500,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
29489
29500
|
schSectionName?: string | undefined;
|
|
29490
29501
|
schSheetName?: string | undefined;
|
|
29491
29502
|
connections?: Partial<Record<"pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
29503
|
+
pinLabels?: Partial<Record<"left" | "right" | "pin1" | "pin2" | "anode" | "pos" | "cathode" | "neg", string | readonly string[] | string[]>> | undefined;
|
|
29492
29504
|
standard?: boolean | undefined;
|
|
29493
29505
|
schOrientation?: "vertical" | "horizontal" | "pos_top" | "pos_bottom" | "pos_left" | "pos_right" | "neg_top" | "neg_bottom" | "neg_left" | "neg_right" | undefined;
|
|
29494
29506
|
schottky?: boolean | undefined;
|
|
@@ -29502,10 +29514,10 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
29502
29514
|
};
|
|
29503
29515
|
initPorts(): void;
|
|
29504
29516
|
doInitialSourceRender(): void;
|
|
29505
|
-
pos: Port;
|
|
29506
|
-
anode: Port;
|
|
29507
|
-
neg: Port;
|
|
29508
|
-
cathode: Port;
|
|
29517
|
+
get pos(): Port;
|
|
29518
|
+
get anode(): Port;
|
|
29519
|
+
get neg(): Port;
|
|
29520
|
+
get cathode(): Port;
|
|
29509
29521
|
}
|
|
29510
29522
|
|
|
29511
29523
|
declare class Fuse extends NormalComponent<typeof fuseProps, PassivePorts> {
|
package/dist/index.js
CHANGED
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
pcb_manual_edit_conflict_warning,
|
|
115
115
|
point3 as point32,
|
|
116
116
|
rotation as rotation2,
|
|
117
|
-
|
|
117
|
+
source_part_not_found_warning as source_part_not_found_warning2
|
|
118
118
|
} from "circuit-json";
|
|
119
119
|
import Debug5 from "debug";
|
|
120
120
|
|
|
@@ -326,6 +326,7 @@ var orderedRenderPhases = [
|
|
|
326
326
|
"SourceNameDuplicateComponentRemoval",
|
|
327
327
|
"PcbFootprintStringRender",
|
|
328
328
|
"FetchPartFootprint",
|
|
329
|
+
"ResolveFootprintPinLabels",
|
|
329
330
|
"InitializePortsFromChildren",
|
|
330
331
|
"CreateNetsFromProps",
|
|
331
332
|
"AssignFallbackProps",
|
|
@@ -386,6 +387,7 @@ var renderPhaseIndexMap = new Map(
|
|
|
386
387
|
);
|
|
387
388
|
var asyncPhaseDependencies = {
|
|
388
389
|
InflateSubcircuitCircuitJson: ["RenderIsolatedSubcircuits"],
|
|
390
|
+
ResolveFootprintPinLabels: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
389
391
|
SchematicComponentRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
390
392
|
SchematicPortRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
391
393
|
SymbolContainerRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
@@ -10246,6 +10248,13 @@ var calculateCcwRotation = (componentRotationStr, elementCcwRotation) => {
|
|
|
10246
10248
|
return normalizedRotation;
|
|
10247
10249
|
};
|
|
10248
10250
|
var optional = (value) => value ?? void 0;
|
|
10251
|
+
var getPinNumberFromPortHints = (portHints) => {
|
|
10252
|
+
for (const hint of portHints ?? []) {
|
|
10253
|
+
if (/^\d+$/.test(hint)) return Number(hint);
|
|
10254
|
+
const pinNameMatch = /^pin(\d+)$/i.exec(hint);
|
|
10255
|
+
if (pinNameMatch) return Number(pinNameMatch[1]);
|
|
10256
|
+
}
|
|
10257
|
+
};
|
|
10249
10258
|
var getFacingDirectionFromSide = (side) => {
|
|
10250
10259
|
switch (side) {
|
|
10251
10260
|
case "left":
|
|
@@ -10282,13 +10291,52 @@ var createComponentsFromCircuitJson = ({
|
|
|
10282
10291
|
const components = [];
|
|
10283
10292
|
const schematicSymbolsByImportedId = /* @__PURE__ */ new Map();
|
|
10284
10293
|
const schematicComponentsByImportedId = /* @__PURE__ */ new Map();
|
|
10294
|
+
const sourceComponentIdByPcbComponentId = /* @__PURE__ */ new Map();
|
|
10285
10295
|
const sourcePortsByImportedId = /* @__PURE__ */ new Map();
|
|
10296
|
+
const sourcePortsByComponentAndPinNumber = /* @__PURE__ */ new Map();
|
|
10286
10297
|
const schematicStrokeWidthBySymbolId = /* @__PURE__ */ new Map();
|
|
10287
10298
|
for (const elm of circuitJson) {
|
|
10299
|
+
if (elm.type === "pcb_component" && typeof elm.source_component_id === "string") {
|
|
10300
|
+
sourceComponentIdByPcbComponentId.set(
|
|
10301
|
+
elm.pcb_component_id,
|
|
10302
|
+
elm.source_component_id
|
|
10303
|
+
);
|
|
10304
|
+
}
|
|
10288
10305
|
if (elm.type === "source_port") {
|
|
10289
10306
|
sourcePortsByImportedId.set(elm.source_port_id, elm);
|
|
10307
|
+
if (typeof elm.pin_number === "number" && typeof elm.source_component_id === "string") {
|
|
10308
|
+
let sourcePortsByPinNumber = sourcePortsByComponentAndPinNumber.get(
|
|
10309
|
+
elm.source_component_id
|
|
10310
|
+
);
|
|
10311
|
+
if (!sourcePortsByPinNumber) {
|
|
10312
|
+
sourcePortsByPinNumber = /* @__PURE__ */ new Map();
|
|
10313
|
+
sourcePortsByComponentAndPinNumber.set(
|
|
10314
|
+
elm.source_component_id,
|
|
10315
|
+
sourcePortsByPinNumber
|
|
10316
|
+
);
|
|
10317
|
+
}
|
|
10318
|
+
sourcePortsByPinNumber.set(elm.pin_number, elm);
|
|
10319
|
+
}
|
|
10290
10320
|
}
|
|
10291
10321
|
}
|
|
10322
|
+
const getPortHintsWithSourcePortAliases = (portHints, pcbComponentId) => {
|
|
10323
|
+
const pinNumber = getPinNumberFromPortHints(portHints);
|
|
10324
|
+
const sourceComponentId = typeof pcbComponentId === "string" ? sourceComponentIdByPcbComponentId.get(pcbComponentId) : void 0;
|
|
10325
|
+
const sourcePort = typeof pinNumber === "number" && sourceComponentId ? sourcePortsByComponentAndPinNumber.get(sourceComponentId)?.get(pinNumber) : void 0;
|
|
10326
|
+
if (!sourcePort) return portHints;
|
|
10327
|
+
const mergedPortHints = Array.from(
|
|
10328
|
+
new Set(
|
|
10329
|
+
[
|
|
10330
|
+
...portHints ?? [],
|
|
10331
|
+
...sourcePort.port_hints ?? [],
|
|
10332
|
+
sourcePort.name
|
|
10333
|
+
].filter(
|
|
10334
|
+
(alias) => typeof alias === "string" && alias.length > 0
|
|
10335
|
+
)
|
|
10336
|
+
)
|
|
10337
|
+
);
|
|
10338
|
+
return mergedPortHints.length > 0 ? mergedPortHints : portHints;
|
|
10339
|
+
};
|
|
10292
10340
|
for (const elm of circuitJson) {
|
|
10293
10341
|
if (elm.type !== "schematic_symbol") continue;
|
|
10294
10342
|
const schematicSymbol = new SymbolComponent({
|
|
@@ -10320,6 +10368,10 @@ var createComponentsFromCircuitJson = ({
|
|
|
10320
10368
|
}
|
|
10321
10369
|
};
|
|
10322
10370
|
for (const elm of circuitJson) {
|
|
10371
|
+
const resolvedPortHints = "port_hints" in elm ? getPortHintsWithSourcePortAliases(
|
|
10372
|
+
elm.port_hints,
|
|
10373
|
+
"pcb_component_id" in elm ? elm.pcb_component_id : void 0
|
|
10374
|
+
) : void 0;
|
|
10323
10375
|
if (elm.type === "pcb_smtpad" && elm.shape === "rect") {
|
|
10324
10376
|
components.push(
|
|
10325
10377
|
new SmtPad({
|
|
@@ -10329,7 +10381,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10329
10381
|
shape: "rect",
|
|
10330
10382
|
height: elm.height,
|
|
10331
10383
|
width: elm.width,
|
|
10332
|
-
portHints:
|
|
10384
|
+
portHints: resolvedPortHints,
|
|
10333
10385
|
rectBorderRadius: elm.rect_border_radius
|
|
10334
10386
|
})
|
|
10335
10387
|
);
|
|
@@ -10341,7 +10393,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10341
10393
|
layer: elm.layer,
|
|
10342
10394
|
shape: "circle",
|
|
10343
10395
|
radius: elm.radius,
|
|
10344
|
-
portHints:
|
|
10396
|
+
portHints: resolvedPortHints
|
|
10345
10397
|
})
|
|
10346
10398
|
);
|
|
10347
10399
|
} else if (elm.type === "pcb_smtpad" && elm.shape === "pill") {
|
|
@@ -10351,7 +10403,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10351
10403
|
height: elm.height,
|
|
10352
10404
|
width: elm.width,
|
|
10353
10405
|
radius: elm.radius,
|
|
10354
|
-
portHints:
|
|
10406
|
+
portHints: resolvedPortHints,
|
|
10355
10407
|
pcbX: elm.x,
|
|
10356
10408
|
pcbY: elm.y,
|
|
10357
10409
|
layer: elm.layer
|
|
@@ -10368,7 +10420,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10368
10420
|
width: elm.width,
|
|
10369
10421
|
ccwRotation: elm.ccw_rotation,
|
|
10370
10422
|
cornerRadius: elm.corner_radius,
|
|
10371
|
-
portHints:
|
|
10423
|
+
portHints: resolvedPortHints
|
|
10372
10424
|
})
|
|
10373
10425
|
);
|
|
10374
10426
|
} else if (elm.type === "pcb_smtpad" && elm.shape === "polygon") {
|
|
@@ -10376,7 +10428,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10376
10428
|
new SmtPad({
|
|
10377
10429
|
shape: "polygon",
|
|
10378
10430
|
points: elm.points,
|
|
10379
|
-
portHints:
|
|
10431
|
+
portHints: resolvedPortHints,
|
|
10380
10432
|
layer: elm.layer
|
|
10381
10433
|
})
|
|
10382
10434
|
);
|
|
@@ -10411,7 +10463,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10411
10463
|
shape: "circle",
|
|
10412
10464
|
holeDiameter: elm.hole_diameter,
|
|
10413
10465
|
outerDiameter: elm.outer_diameter,
|
|
10414
|
-
portHints:
|
|
10466
|
+
portHints: resolvedPortHints
|
|
10415
10467
|
})
|
|
10416
10468
|
);
|
|
10417
10469
|
} else if (elm.shape === "circular_hole_with_rect_pad") {
|
|
@@ -10423,7 +10475,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10423
10475
|
holeDiameter: elm.hole_diameter,
|
|
10424
10476
|
rectPadHeight: elm.rect_pad_height,
|
|
10425
10477
|
rectPadWidth: elm.rect_pad_width,
|
|
10426
|
-
portHints:
|
|
10478
|
+
portHints: resolvedPortHints,
|
|
10427
10479
|
rectBorderRadius: elm.rect_border_radius,
|
|
10428
10480
|
holeOffsetX: elm.hole_offset_x,
|
|
10429
10481
|
holeOffsetY: elm.hole_offset_y
|
|
@@ -10439,7 +10491,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10439
10491
|
holeHeight: elm.hole_height,
|
|
10440
10492
|
outerWidth: elm.outer_width,
|
|
10441
10493
|
outerHeight: elm.outer_height,
|
|
10442
|
-
portHints:
|
|
10494
|
+
portHints: resolvedPortHints
|
|
10443
10495
|
})
|
|
10444
10496
|
);
|
|
10445
10497
|
} else if (elm.shape === "pill_hole_with_rect_pad") {
|
|
@@ -10455,7 +10507,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10455
10507
|
rectPadWidth: elm.rect_pad_width,
|
|
10456
10508
|
rectPadHeight: elm.rect_pad_height,
|
|
10457
10509
|
rectBorderRadius: elm.rect_border_radius,
|
|
10458
|
-
portHints:
|
|
10510
|
+
portHints: resolvedPortHints,
|
|
10459
10511
|
holeOffsetX: elm.hole_offset_x,
|
|
10460
10512
|
holeOffsetY: elm.hole_offset_y
|
|
10461
10513
|
})
|
|
@@ -10473,7 +10525,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10473
10525
|
rectPadWidth: elm.rect_pad_width,
|
|
10474
10526
|
rectPadHeight: elm.rect_pad_height,
|
|
10475
10527
|
rectBorderRadius: elm.rect_border_radius,
|
|
10476
|
-
portHints:
|
|
10528
|
+
portHints: resolvedPortHints,
|
|
10477
10529
|
holeOffsetX: elm.hole_offset_x,
|
|
10478
10530
|
holeOffsetY: elm.hole_offset_y,
|
|
10479
10531
|
pcbRotation: elm.hole_ccw_rotation
|
|
@@ -10492,7 +10544,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
10492
10544
|
padOutline: elm.pad_outline || [],
|
|
10493
10545
|
holeOffsetX: elm.hole_offset_x,
|
|
10494
10546
|
holeOffsetY: elm.hole_offset_y,
|
|
10495
|
-
portHints:
|
|
10547
|
+
portHints: resolvedPortHints
|
|
10496
10548
|
})
|
|
10497
10549
|
);
|
|
10498
10550
|
}
|
|
@@ -12129,7 +12181,8 @@ var shouldAddOutsideFootprintWrapper = (component) => component.componentName ==
|
|
|
12129
12181
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
12130
12182
|
const footprint = component.resolveFootprint();
|
|
12131
12183
|
if (!footprint) return;
|
|
12132
|
-
const { pcbRotation,
|
|
12184
|
+
const { pcbRotation, pcbPinLabels } = component.props;
|
|
12185
|
+
const pinLabels = component._resolvePinLabels();
|
|
12133
12186
|
const fileExtension = getFileExtension(String(footprint));
|
|
12134
12187
|
const footprintParser = fileExtension ? component.root?.platform?.footprintFileParserMap?.[fileExtension] : null;
|
|
12135
12188
|
if (typeof footprint === "string" && (isHttpUrl(footprint) || isStaticAssetPath(footprint)) && footprintParser) {
|
|
@@ -12150,6 +12203,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
|
|
|
12150
12203
|
result.footprintCircuitJson
|
|
12151
12204
|
);
|
|
12152
12205
|
component.addAll(fpComponents);
|
|
12206
|
+
component._markDirty("ResolveFootprintPinLabels");
|
|
12153
12207
|
component._markDirty("InitializePortsFromChildren");
|
|
12154
12208
|
} catch (err) {
|
|
12155
12209
|
const db = component.root?.db;
|
|
@@ -12194,6 +12248,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
|
|
|
12194
12248
|
soup
|
|
12195
12249
|
);
|
|
12196
12250
|
component.addAll(fpComponents);
|
|
12251
|
+
component._markDirty("ResolveFootprintPinLabels");
|
|
12197
12252
|
component._markDirty("InitializePortsFromChildren");
|
|
12198
12253
|
} catch (err) {
|
|
12199
12254
|
const db = component.root?.db;
|
|
@@ -12265,6 +12320,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
|
|
|
12265
12320
|
child._markDirty?.("PcbPortRender");
|
|
12266
12321
|
}
|
|
12267
12322
|
}
|
|
12323
|
+
component._markDirty("ResolveFootprintPinLabels");
|
|
12268
12324
|
component._markDirty("InitializePortsFromChildren");
|
|
12269
12325
|
} catch (err) {
|
|
12270
12326
|
const db = component.root?.db;
|
|
@@ -12324,6 +12380,48 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
|
|
|
12324
12380
|
}
|
|
12325
12381
|
}
|
|
12326
12382
|
|
|
12383
|
+
// lib/components/base-components/NormalComponent/NormalComponent_doInitialResolveFootprintPinLabels.ts
|
|
12384
|
+
function NormalComponent_doInitialResolveFootprintPinLabels(component) {
|
|
12385
|
+
const pinLabelsBeforeFootprint = component._impliedFootprintPinLabels ?? {};
|
|
12386
|
+
const pinLabels = {};
|
|
12387
|
+
const portsFromFootprint = component.getPortsFromFootprint({
|
|
12388
|
+
allowImplicitPinNumbers: !component._parsedProps.pinLabels
|
|
12389
|
+
});
|
|
12390
|
+
for (const port of portsFromFootprint) {
|
|
12391
|
+
const pinNumber = port._parsedProps.pinNumber;
|
|
12392
|
+
if (pinNumber === void 0) continue;
|
|
12393
|
+
const genericPinLabels = /* @__PURE__ */ new Set([`pin${pinNumber}`, `${pinNumber}`]);
|
|
12394
|
+
const labels = port.getNameAndAliases().filter((label) => !genericPinLabels.has(label));
|
|
12395
|
+
if (labels.length > 0) {
|
|
12396
|
+
pinLabels[`pin${pinNumber}`] = labels;
|
|
12397
|
+
}
|
|
12398
|
+
}
|
|
12399
|
+
const impliedFootprintPinLabels = { ...pinLabels };
|
|
12400
|
+
for (const [pinKey, labels] of Object.entries(pinLabelsBeforeFootprint)) {
|
|
12401
|
+
impliedFootprintPinLabels[pinKey] = Array.isArray(labels) ? labels : [labels];
|
|
12402
|
+
}
|
|
12403
|
+
component._impliedFootprintPinLabels = impliedFootprintPinLabels;
|
|
12404
|
+
if (Object.keys(component._impliedFootprintPinLabels).length === 0) {
|
|
12405
|
+
return;
|
|
12406
|
+
}
|
|
12407
|
+
for (const child of component.children) {
|
|
12408
|
+
if (child.componentName !== "Port") continue;
|
|
12409
|
+
const port = child;
|
|
12410
|
+
const pinNumber = port._parsedProps.pinNumber;
|
|
12411
|
+
if (pinNumber === void 0) continue;
|
|
12412
|
+
const pinKey = `pin${pinNumber}`;
|
|
12413
|
+
const labels = component._impliedFootprintPinLabels[pinKey];
|
|
12414
|
+
if (!labels) continue;
|
|
12415
|
+
const labelList = Array.isArray(labels) ? labels : [labels];
|
|
12416
|
+
const existingLabels = port.getNameAndAliases();
|
|
12417
|
+
for (const label of labelList) {
|
|
12418
|
+
if (!existingLabels.includes(label)) {
|
|
12419
|
+
port.externallyAddedAliases.push(label);
|
|
12420
|
+
}
|
|
12421
|
+
}
|
|
12422
|
+
}
|
|
12423
|
+
}
|
|
12424
|
+
|
|
12327
12425
|
// lib/components/base-components/NormalComponent/utils/getPcbTextBounds.ts
|
|
12328
12426
|
function getPcbTextBounds(text) {
|
|
12329
12427
|
const fontSize = text.font_size;
|
|
@@ -12513,8 +12611,8 @@ import {
|
|
|
12513
12611
|
supplierProps
|
|
12514
12612
|
} from "@tscircuit/props";
|
|
12515
12613
|
import {
|
|
12516
|
-
|
|
12517
|
-
|
|
12614
|
+
source_part_not_found_warning,
|
|
12615
|
+
supplier_footprint_mismatch_warning
|
|
12518
12616
|
} from "circuit-json";
|
|
12519
12617
|
var SUPPLIER_FOOTPRINT_IOU_WARNING_THRESHOLD = 0.8;
|
|
12520
12618
|
var supplierNames = supplierProps.shape.supplierPartNumbers.unwrap().keySchema.options;
|
|
@@ -12621,13 +12719,15 @@ function NormalComponent_doInitialSupplierFootprintMismatchWarning(component) {
|
|
|
12621
12719
|
return;
|
|
12622
12720
|
} catch (error) {
|
|
12623
12721
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
12624
|
-
const
|
|
12625
|
-
type: "
|
|
12722
|
+
const warning = source_part_not_found_warning.parse({
|
|
12723
|
+
type: "source_part_not_found_warning",
|
|
12626
12724
|
message: `Failed to fetch supplier footprint for ${component.getString()} (${supplierName}:${supplierPartNumber}): ${errorMessage}`,
|
|
12627
|
-
source_component_id: component.source_component_id,
|
|
12628
|
-
subcircuit_id: component.getSubcircuit()?.subcircuit_id
|
|
12725
|
+
source_component_id: component.source_component_id ?? void 0,
|
|
12726
|
+
subcircuit_id: component.getSubcircuit()?.subcircuit_id ?? void 0,
|
|
12727
|
+
supplier_name: supplierName,
|
|
12728
|
+
supplier_part_number: supplierPartNumber
|
|
12629
12729
|
});
|
|
12630
|
-
db2.
|
|
12730
|
+
db2.source_part_not_found_warning.insert(warning);
|
|
12631
12731
|
return;
|
|
12632
12732
|
}
|
|
12633
12733
|
}
|
|
@@ -12784,7 +12884,14 @@ function getPrimaryPortsFromPortHintGroups(portHintGroups, opts) {
|
|
|
12784
12884
|
(hint) => hint.startsWith("pin") || /^(?:pin)?\d+$/.test(hint)
|
|
12785
12885
|
);
|
|
12786
12886
|
if (!hasPinIdentifier) {
|
|
12787
|
-
|
|
12887
|
+
const explicitPinNumber = portHintsList.map((hint) => opts?.implicitPinNumberByHint?.get(hint)).find((pinNumber2) => pinNumber2 !== void 0);
|
|
12888
|
+
if (explicitPinNumber !== void 0) {
|
|
12889
|
+
portHintsList = [...portHintsList, `pin${explicitPinNumber}`];
|
|
12890
|
+
} else if (opts?.allowImplicitPinNumbers === false) {
|
|
12891
|
+
continue;
|
|
12892
|
+
} else {
|
|
12893
|
+
portHintsList = [...portHintsList, `pin${implicitPinNumber}`];
|
|
12894
|
+
}
|
|
12788
12895
|
}
|
|
12789
12896
|
implicitPinNumber++;
|
|
12790
12897
|
const newPort = getPortFromHints(portHintsList, opts);
|
|
@@ -12891,6 +12998,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12891
12998
|
_hasStartedSupplierFootprintMismatchWarningCheck = false;
|
|
12892
12999
|
_invalidFootprintPropMessages = [];
|
|
12893
13000
|
_invalidPinLabelMessages = [];
|
|
13001
|
+
_impliedFootprintPinLabels;
|
|
12894
13002
|
/**
|
|
12895
13003
|
* Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
|
|
12896
13004
|
*/
|
|
@@ -12980,15 +13088,20 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12980
13088
|
this._inferredInternallyConnectedPinNames = [];
|
|
12981
13089
|
const { config } = this;
|
|
12982
13090
|
const portsToCreate = [];
|
|
13091
|
+
const pinLabels = this._resolvePinLabels();
|
|
13092
|
+
const propsPinLabels = this._parsedProps.pinLabels;
|
|
13093
|
+
const pinLabelsFromProps = propsPinLabels && Array.isArray(propsPinLabels) ? Object.fromEntries(
|
|
13094
|
+
propsPinLabels.map((label, index) => [`pin${index + 1}`, label])
|
|
13095
|
+
) : propsPinLabels;
|
|
12983
13096
|
const schPortArrangement = this._getSchematicPortArrangement();
|
|
12984
|
-
if (schPortArrangement && !
|
|
13097
|
+
if (schPortArrangement && !pinLabels) {
|
|
12985
13098
|
for (const side in schPortArrangement) {
|
|
12986
13099
|
const pins = schPortArrangement[side].pins;
|
|
12987
13100
|
if (Array.isArray(pins)) {
|
|
12988
13101
|
for (const pinNumberOrLabel of pins) {
|
|
12989
13102
|
const pinNumber = parsePinNumberFromLabelsOrThrow(
|
|
12990
13103
|
pinNumberOrLabel,
|
|
12991
|
-
|
|
13104
|
+
pinLabels
|
|
12992
13105
|
);
|
|
12993
13106
|
portsToCreate.push(
|
|
12994
13107
|
new Port(
|
|
@@ -13023,7 +13136,6 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13023
13136
|
}
|
|
13024
13137
|
}
|
|
13025
13138
|
}
|
|
13026
|
-
const pinLabels = this._parsedProps.pinLabels;
|
|
13027
13139
|
if (pinLabels) {
|
|
13028
13140
|
for (const [pinKey, label] of Object.entries(pinLabels)) {
|
|
13029
13141
|
const pinNumber = getPinNumberFromPinLabelsKey(pinKey);
|
|
@@ -13035,16 +13147,20 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13035
13147
|
let existingPort = portsToCreate.find(
|
|
13036
13148
|
(p) => p._parsedProps.pinNumber === pinNumber
|
|
13037
13149
|
);
|
|
13038
|
-
const
|
|
13039
|
-
const
|
|
13150
|
+
const labelList = Array.isArray(label) ? label : [label];
|
|
13151
|
+
const propLabel = pinLabelsFromProps?.[pinKey];
|
|
13152
|
+
const hasPropLabel = propLabel !== void 0;
|
|
13153
|
+
const primaryLabel = hasPropLabel ? labelList[0] : `pin${pinNumber}`;
|
|
13154
|
+
const otherLabels = hasPropLabel ? labelList.slice(1) : labelList;
|
|
13040
13155
|
if (!existingPort) {
|
|
13041
13156
|
existingPort = new Port(
|
|
13042
13157
|
{
|
|
13043
13158
|
pinNumber,
|
|
13044
13159
|
name: primaryLabel,
|
|
13045
13160
|
aliases: [
|
|
13161
|
+
...hasPropLabel ? [] : opts.additionalAliases?.[`pin${pinNumber}`] ?? [],
|
|
13046
13162
|
...otherLabels,
|
|
13047
|
-
...opts.additionalAliases?.[`pin${pinNumber}`] ?? []
|
|
13163
|
+
...hasPropLabel ? opts.additionalAliases?.[`pin${pinNumber}`] ?? [] : []
|
|
13048
13164
|
]
|
|
13049
13165
|
},
|
|
13050
13166
|
{
|
|
@@ -13054,7 +13170,6 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13054
13170
|
portsToCreate.push(existingPort);
|
|
13055
13171
|
} else {
|
|
13056
13172
|
existingPort.externallyAddedAliases.push(primaryLabel, ...otherLabels);
|
|
13057
|
-
existingPort.props.name = primaryLabel;
|
|
13058
13173
|
}
|
|
13059
13174
|
}
|
|
13060
13175
|
}
|
|
@@ -13093,6 +13208,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13093
13208
|
} else {
|
|
13094
13209
|
const portsFromFootprint = this.getPortsFromFootprint({
|
|
13095
13210
|
...opts,
|
|
13211
|
+
allowImplicitPinNumbers: !pinLabelsFromProps,
|
|
13096
13212
|
collectInferredInternallyConnectedPins: true
|
|
13097
13213
|
});
|
|
13098
13214
|
const existingPorts = this._getAllPortsFromChildren();
|
|
@@ -13126,7 +13242,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13126
13242
|
continue;
|
|
13127
13243
|
}
|
|
13128
13244
|
let explicitlyListedPinNumbersInSchPortArrangement = getPinsFromPortArrangement(schPortArrangement).map(
|
|
13129
|
-
(pn2) => parsePinNumberFromLabelsOrThrow(pn2,
|
|
13245
|
+
(pn2) => parsePinNumberFromLabelsOrThrow(pn2, pinLabels)
|
|
13130
13246
|
);
|
|
13131
13247
|
if ([
|
|
13132
13248
|
"leftSize",
|
|
@@ -13168,6 +13284,18 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13168
13284
|
this.addAll(portsToCreate);
|
|
13169
13285
|
}
|
|
13170
13286
|
}
|
|
13287
|
+
_resolvePinLabels() {
|
|
13288
|
+
const pinLabels = this._parsedProps.pinLabels;
|
|
13289
|
+
const parsedPinLabels = pinLabels && Array.isArray(pinLabels) ? Object.fromEntries(
|
|
13290
|
+
pinLabels.map((label, index) => [`pin${index + 1}`, label])
|
|
13291
|
+
) : pinLabels;
|
|
13292
|
+
const resolvedPinLabels = {
|
|
13293
|
+
...this._impliedFootprintPinLabels ?? {},
|
|
13294
|
+
...parsedPinLabels ?? {}
|
|
13295
|
+
};
|
|
13296
|
+
if (Object.keys(resolvedPinLabels).length === 0) return void 0;
|
|
13297
|
+
return resolvedPinLabels;
|
|
13298
|
+
}
|
|
13171
13299
|
_getImpliedFootprintString() {
|
|
13172
13300
|
return null;
|
|
13173
13301
|
}
|
|
@@ -13176,7 +13304,8 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13176
13304
|
return this._parsedProps.footprint ?? this.props.footprint ?? this._getImpliedFootprintString?.();
|
|
13177
13305
|
}
|
|
13178
13306
|
_addChildrenFromStringFootprint() {
|
|
13179
|
-
const { pcbRotation,
|
|
13307
|
+
const { pcbRotation, pcbPinLabels } = this.props;
|
|
13308
|
+
const pinLabels = this._resolvePinLabels();
|
|
13180
13309
|
const footprint = this.resolveFootprint();
|
|
13181
13310
|
if (!footprint) return;
|
|
13182
13311
|
if (typeof footprint === "string") {
|
|
@@ -13549,6 +13678,12 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13549
13678
|
updatePcbComponentAnchorAlignment() {
|
|
13550
13679
|
this.doInitialPcbComponentAnchorAlignment();
|
|
13551
13680
|
}
|
|
13681
|
+
doInitialResolveFootprintPinLabels() {
|
|
13682
|
+
NormalComponent_doInitialResolveFootprintPinLabels(this);
|
|
13683
|
+
}
|
|
13684
|
+
updateResolveFootprintPinLabels() {
|
|
13685
|
+
this.doInitialResolveFootprintPinLabels();
|
|
13686
|
+
}
|
|
13552
13687
|
_renderReactSubtree(element) {
|
|
13553
13688
|
const component = createInstanceFromReactElement(element);
|
|
13554
13689
|
return {
|
|
@@ -13725,9 +13860,25 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
13725
13860
|
if (opts?.collectInferredInternallyConnectedPins) {
|
|
13726
13861
|
inferredInternallyConnectedPinNames = this._inferredInternallyConnectedPinNames;
|
|
13727
13862
|
}
|
|
13863
|
+
const implicitPinNumberByHint = /* @__PURE__ */ new Map();
|
|
13864
|
+
const explicitPinLabels = this._parsedProps?.pinLabels ?? this.props.pinLabels;
|
|
13865
|
+
if (explicitPinLabels) {
|
|
13866
|
+
const pinLabelEntries = Array.isArray(explicitPinLabels) ? explicitPinLabels.map((label, index) => [`pin${index + 1}`, label]) : Object.entries(explicitPinLabels);
|
|
13867
|
+
for (const [pinKey, labelOrLabels] of pinLabelEntries) {
|
|
13868
|
+
const pinNumber = getPinNumberFromPinLabelsKey(pinKey);
|
|
13869
|
+
if (pinNumber === null) continue;
|
|
13870
|
+
const labels = Array.isArray(labelOrLabels) ? labelOrLabels : [labelOrLabels];
|
|
13871
|
+
for (const label of labels) {
|
|
13872
|
+
if (typeof label === "string" && label.length > 0) {
|
|
13873
|
+
implicitPinNumberByHint.set(label, pinNumber);
|
|
13874
|
+
}
|
|
13875
|
+
}
|
|
13876
|
+
}
|
|
13877
|
+
}
|
|
13728
13878
|
const primaryPortOpts = {
|
|
13729
13879
|
...opts,
|
|
13730
|
-
inferredInternallyConnectedPinNames
|
|
13880
|
+
inferredInternallyConnectedPinNames,
|
|
13881
|
+
implicitPinNumberByHint
|
|
13731
13882
|
};
|
|
13732
13883
|
let { footprint } = this.props;
|
|
13733
13884
|
if (typeof footprint === "string" && parseLibraryFootprintRef(footprint) && this.children.some((c) => c.componentName === "Footprint")) {
|
|
@@ -14110,7 +14261,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
14110
14261
|
);
|
|
14111
14262
|
}
|
|
14112
14263
|
if (result === "Not found") {
|
|
14113
|
-
|
|
14264
|
+
throw new Error(
|
|
14265
|
+
`Part not found for ${this.getString()}${footprinterString ? ` with footprint "${footprinterString}"` : ""}`
|
|
14266
|
+
);
|
|
14114
14267
|
}
|
|
14115
14268
|
throw new Error(
|
|
14116
14269
|
`Invalid supplier part numbers format: Expected object but got string: "${result}"`
|
|
@@ -14160,13 +14313,15 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
14160
14313
|
this._markDirty("PartsEngineRender");
|
|
14161
14314
|
}).catch((error) => {
|
|
14162
14315
|
this._asyncSupplierPartNumbers = {};
|
|
14163
|
-
const
|
|
14164
|
-
type: "
|
|
14316
|
+
const warning = source_part_not_found_warning2.parse({
|
|
14317
|
+
type: "source_part_not_found_warning",
|
|
14165
14318
|
message: `Failed to fetch supplier part numbers for ${this.getString()}: ${error.message}`,
|
|
14166
|
-
source_component_id: this.source_component_id,
|
|
14167
|
-
subcircuit_id: this.getSubcircuit()?.subcircuit_id
|
|
14319
|
+
source_component_id: this.source_component_id ?? void 0,
|
|
14320
|
+
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0,
|
|
14321
|
+
manufacturer_part_number: source_component.manufacturer_part_number ?? void 0,
|
|
14322
|
+
part_name: source_component.name ?? void 0
|
|
14168
14323
|
});
|
|
14169
|
-
db.
|
|
14324
|
+
db.source_part_not_found_warning.insert(warning);
|
|
14170
14325
|
this._markDirty("PartsEngineRender");
|
|
14171
14326
|
});
|
|
14172
14327
|
});
|
|
@@ -14898,6 +15053,11 @@ var inflateSourceChip = (sourceElm, inflatorContext) => {
|
|
|
14898
15053
|
|
|
14899
15054
|
// lib/components/normal-components/Diode.ts
|
|
14900
15055
|
import { diodeProps } from "@tscircuit/props";
|
|
15056
|
+
|
|
15057
|
+
// lib/components/base-components/NormalComponent/utils/isFootprinterString.ts
|
|
15058
|
+
var isFootprinterString = (footprint) => typeof footprint === "string" && !parseLibraryFootprintRef(footprint) && !isHttpUrl(footprint) && !isStaticAssetPath(footprint);
|
|
15059
|
+
|
|
15060
|
+
// lib/components/normal-components/Diode.ts
|
|
14901
15061
|
var Diode = class extends NormalComponent3 {
|
|
14902
15062
|
get config() {
|
|
14903
15063
|
const symbolMap = {
|
|
@@ -14915,10 +15075,18 @@ var Diode = class extends NormalComponent3 {
|
|
|
14915
15075
|
};
|
|
14916
15076
|
}
|
|
14917
15077
|
initPorts() {
|
|
15078
|
+
const hasFootprintChild = this.children.some(
|
|
15079
|
+
(child) => child.componentName === "Footprint"
|
|
15080
|
+
);
|
|
15081
|
+
const footprint = this.resolveFootprint();
|
|
15082
|
+
const hasPinLabels = Boolean(this._resolvePinLabels());
|
|
15083
|
+
const shouldAddDefaultAliases = !hasPinLabels && !hasFootprintChild && (!footprint || isFootprinterString(footprint));
|
|
14918
15084
|
super.initPorts({
|
|
15085
|
+
pinCount: 2,
|
|
15086
|
+
ignoreSymbolPorts: !hasPinLabels && !shouldAddDefaultAliases,
|
|
14919
15087
|
additionalAliases: {
|
|
14920
|
-
pin1: ["anode", "pos", "left"],
|
|
14921
|
-
pin2: ["cathode", "neg", "right"]
|
|
15088
|
+
pin1: shouldAddDefaultAliases ? ["anode", "pos", "left"] : [],
|
|
15089
|
+
pin2: shouldAddDefaultAliases ? ["cathode", "neg", "right"] : []
|
|
14922
15090
|
}
|
|
14923
15091
|
});
|
|
14924
15092
|
}
|
|
@@ -14935,35 +15103,70 @@ var Diode = class extends NormalComponent3 {
|
|
|
14935
15103
|
});
|
|
14936
15104
|
this.source_component_id = source_component.source_component_id;
|
|
14937
15105
|
}
|
|
14938
|
-
pos
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
15106
|
+
get pos() {
|
|
15107
|
+
return this.portMap.pos;
|
|
15108
|
+
}
|
|
15109
|
+
get anode() {
|
|
15110
|
+
return this.portMap.anode;
|
|
15111
|
+
}
|
|
15112
|
+
get neg() {
|
|
15113
|
+
return this.portMap.neg;
|
|
15114
|
+
}
|
|
15115
|
+
get cathode() {
|
|
15116
|
+
return this.portMap.cathode;
|
|
15117
|
+
}
|
|
14942
15118
|
};
|
|
14943
15119
|
|
|
14944
15120
|
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceDiode.ts
|
|
15121
|
+
var getLabels = (sourcePort) => Array.from(
|
|
15122
|
+
new Set(
|
|
15123
|
+
[sourcePort?.name, ...sourcePort?.port_hints ?? []].filter(
|
|
15124
|
+
(label) => typeof label === "string" && label.length > 0
|
|
15125
|
+
)
|
|
15126
|
+
)
|
|
15127
|
+
);
|
|
15128
|
+
var getImportedDiodePinLabels = (sourceElm, inflatorContext) => {
|
|
15129
|
+
const sourcePorts = inflatorContext.injectionDb.source_port.list().filter(
|
|
15130
|
+
(port) => port.source_component_id === sourceElm.source_component_id
|
|
15131
|
+
);
|
|
15132
|
+
const pinLabels = {};
|
|
15133
|
+
for (const sourcePort of sourcePorts) {
|
|
15134
|
+
if (sourcePort.pin_number === void 0 || sourcePort.pin_number === null) {
|
|
15135
|
+
continue;
|
|
15136
|
+
}
|
|
15137
|
+
const labels = getLabels(sourcePort);
|
|
15138
|
+
if (labels.length === 0) continue;
|
|
15139
|
+
pinLabels[`pin${sourcePort.pin_number}`] = labels;
|
|
15140
|
+
}
|
|
15141
|
+
return Object.keys(pinLabels).length > 0 ? pinLabels : void 0;
|
|
15142
|
+
};
|
|
14945
15143
|
function inflateSourceDiode(sourceElm, inflatorContext) {
|
|
14946
15144
|
const { injectionDb, subcircuit, groupsMap } = inflatorContext;
|
|
14947
15145
|
const pcbElm = injectionDb.pcb_component.getWhere({
|
|
14948
15146
|
source_component_id: sourceElm.source_component_id
|
|
14949
15147
|
});
|
|
14950
|
-
const cadElm = injectionDb.cad_component.getWhere({
|
|
14951
|
-
source_component_id: sourceElm.source_component_id
|
|
14952
|
-
});
|
|
14953
15148
|
const { pcbX, pcbY } = getInflatedPcbPlacement({
|
|
14954
15149
|
pcbComponent: pcbElm,
|
|
14955
15150
|
sourceGroupId: sourceElm.source_group_id,
|
|
14956
15151
|
inflatorContext
|
|
14957
15152
|
});
|
|
14958
|
-
const
|
|
15153
|
+
const importedPinLabels = getImportedDiodePinLabels(
|
|
15154
|
+
sourceElm,
|
|
15155
|
+
inflatorContext
|
|
15156
|
+
);
|
|
15157
|
+
const diodeProps2 = {
|
|
14959
15158
|
name: sourceElm.name,
|
|
15159
|
+
manufacturerPartNumber: sourceElm.manufacturer_part_number,
|
|
15160
|
+
supplierPartNumbers: sourceElm.supplier_part_numbers ?? void 0,
|
|
15161
|
+
pinLabels: importedPinLabels,
|
|
14960
15162
|
layer: pcbElm?.layer,
|
|
14961
15163
|
pcbX,
|
|
14962
15164
|
pcbY,
|
|
14963
15165
|
pcbRotation: pcbElm?.rotation,
|
|
14964
15166
|
doNotPlace: pcbElm?.do_not_place,
|
|
14965
15167
|
obstructsWithinBounds: pcbElm?.obstructs_within_bounds
|
|
14966
|
-
}
|
|
15168
|
+
};
|
|
15169
|
+
const diode = new Diode(diodeProps2);
|
|
14967
15170
|
if (pcbElm) {
|
|
14968
15171
|
const footprint = inflateFootprintComponent(pcbElm, {
|
|
14969
15172
|
...inflatorContext,
|
|
@@ -24872,7 +25075,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
24872
25075
|
var package_default = {
|
|
24873
25076
|
name: "@tscircuit/core",
|
|
24874
25077
|
type: "module",
|
|
24875
|
-
version: "0.0.
|
|
25078
|
+
version: "0.0.1385",
|
|
24876
25079
|
types: "dist/index.d.ts",
|
|
24877
25080
|
main: "dist/index.js",
|
|
24878
25081
|
module: "dist/index.js",
|
|
@@ -24921,7 +25124,7 @@ var package_default = {
|
|
|
24921
25124
|
"@tscircuit/math-utils": "^0.0.36",
|
|
24922
25125
|
"@tscircuit/miniflex": "^0.0.4",
|
|
24923
25126
|
"@tscircuit/ngspice-spice-engine": "^0.0.18",
|
|
24924
|
-
"@tscircuit/props": "^0.0.
|
|
25127
|
+
"@tscircuit/props": "^0.0.566",
|
|
24925
25128
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
24926
25129
|
"@tscircuit/schematic-trace-solver": "^0.0.75",
|
|
24927
25130
|
"@tscircuit/solver-utils": "^0.0.16",
|
|
@@ -24935,12 +25138,12 @@ var package_default = {
|
|
|
24935
25138
|
"bun-match-svg": "0.0.12",
|
|
24936
25139
|
"calculate-elbow": "^0.0.12",
|
|
24937
25140
|
"chokidar-cli": "^3.0.0",
|
|
24938
|
-
"circuit-json": "^0.0.
|
|
25141
|
+
"circuit-json": "^0.0.445",
|
|
24939
25142
|
"circuit-json-to-bpc": "^0.0.13",
|
|
24940
25143
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
24941
25144
|
"circuit-json-to-gltf": "^0.0.105",
|
|
24942
25145
|
"circuit-json-to-spice": "^0.0.40",
|
|
24943
|
-
"circuit-to-svg": "^0.0.
|
|
25146
|
+
"circuit-to-svg": "^0.0.371",
|
|
24944
25147
|
concurrently: "^9.1.2",
|
|
24945
25148
|
"connectivity-map": "^1.0.0",
|
|
24946
25149
|
debug: "^4.3.6",
|
|
@@ -30062,7 +30265,7 @@ import { guessCableInsertCenter } from "@tscircuit/infer-cable-insertion-point";
|
|
|
30062
30265
|
import {
|
|
30063
30266
|
connectorProps
|
|
30064
30267
|
} from "@tscircuit/props";
|
|
30065
|
-
import {
|
|
30268
|
+
import { source_part_not_found_warning as source_part_not_found_warning3 } from "circuit-json";
|
|
30066
30269
|
|
|
30067
30270
|
// lib/utils/connectors/convertCircuitJsonToUsbCStandardCircuitJson.ts
|
|
30068
30271
|
var STANDARD_USB_C_PIN_LABELS = [
|
|
@@ -30281,13 +30484,15 @@ var Connector = class extends Chip {
|
|
|
30281
30484
|
}
|
|
30282
30485
|
_insertStandardConnectorCircuitJsonError(standard, message) {
|
|
30283
30486
|
const { db } = this.root;
|
|
30284
|
-
const
|
|
30285
|
-
type: "
|
|
30487
|
+
const warning = source_part_not_found_warning3.parse({
|
|
30488
|
+
type: "source_part_not_found_warning",
|
|
30286
30489
|
message: `Failed to fetch circuit JSON for ${this.getString()} (standard="${standard}"): ${message}`,
|
|
30287
30490
|
source_component_id: this.source_component_id ?? void 0,
|
|
30288
|
-
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0
|
|
30491
|
+
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0,
|
|
30492
|
+
manufacturer_part_number: this._getConnectorProps().manufacturerPartNumber ?? this._getConnectorProps().mfn ?? void 0,
|
|
30493
|
+
part_name: this.name
|
|
30289
30494
|
});
|
|
30290
|
-
db.
|
|
30495
|
+
db.source_part_not_found_warning.insert(warning);
|
|
30291
30496
|
}
|
|
30292
30497
|
_getSupplierPartNumbersToTry(supplierPartNumbers) {
|
|
30293
30498
|
const partNumbers = [];
|
|
@@ -30507,9 +30712,20 @@ var Connector = class extends Chip {
|
|
|
30507
30712
|
supplierPartNumbers,
|
|
30508
30713
|
sourceComponentForQuery.manufacturer_part_number
|
|
30509
30714
|
);
|
|
30510
|
-
if (!circuitJson)
|
|
30715
|
+
if (!circuitJson) {
|
|
30716
|
+
this._insertStandardConnectorCircuitJsonError(
|
|
30717
|
+
standard,
|
|
30718
|
+
"part circuit JSON was not found"
|
|
30719
|
+
);
|
|
30720
|
+
return;
|
|
30721
|
+
}
|
|
30511
30722
|
this._addConnectorFootprintFromCircuitJson(standard, circuitJson);
|
|
30512
30723
|
} catch (error) {
|
|
30724
|
+
if (this.source_component_id) {
|
|
30725
|
+
db.source_component.update(this.source_component_id, {
|
|
30726
|
+
supplier_part_numbers: {}
|
|
30727
|
+
});
|
|
30728
|
+
}
|
|
30513
30729
|
this._insertStandardConnectorCircuitJsonError(standard, error.message);
|
|
30514
30730
|
}
|
|
30515
30731
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1386",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@tscircuit/math-utils": "^0.0.36",
|
|
51
51
|
"@tscircuit/miniflex": "^0.0.4",
|
|
52
52
|
"@tscircuit/ngspice-spice-engine": "^0.0.18",
|
|
53
|
-
"@tscircuit/props": "^0.0.
|
|
53
|
+
"@tscircuit/props": "^0.0.566",
|
|
54
54
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
55
55
|
"@tscircuit/schematic-trace-solver": "^0.0.75",
|
|
56
56
|
"@tscircuit/solver-utils": "^0.0.16",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"bun-match-svg": "0.0.12",
|
|
65
65
|
"calculate-elbow": "^0.0.12",
|
|
66
66
|
"chokidar-cli": "^3.0.0",
|
|
67
|
-
"circuit-json": "^0.0.
|
|
67
|
+
"circuit-json": "^0.0.445",
|
|
68
68
|
"circuit-json-to-bpc": "^0.0.13",
|
|
69
69
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
70
70
|
"circuit-json-to-gltf": "^0.0.105",
|
|
71
71
|
"circuit-json-to-spice": "^0.0.40",
|
|
72
|
-
"circuit-to-svg": "^0.0.
|
|
72
|
+
"circuit-to-svg": "^0.0.371",
|
|
73
73
|
"concurrently": "^9.1.2",
|
|
74
74
|
"connectivity-map": "^1.0.0",
|
|
75
75
|
"debug": "^4.3.6",
|