@tscircuit/core 0.0.1127 → 0.0.1129
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 +29 -4
- package/dist/index.js +188 -21
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -176,9 +176,9 @@ interface IIsolatedCircuit {
|
|
|
176
176
|
interface IRootCircuit extends IIsolatedCircuit {
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
|
|
179
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
|
|
180
180
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
181
|
-
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SimulationSpiceEngineRender", number>;
|
|
181
|
+
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SimulationSpiceEngineRender", number>;
|
|
182
182
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
183
183
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
184
184
|
initialized: boolean;
|
|
@@ -327,6 +327,7 @@ declare class IsolatedCircuit {
|
|
|
327
327
|
_hasRenderedAtleastOnce: boolean;
|
|
328
328
|
private _asyncEffectIdsByPhase;
|
|
329
329
|
private _asyncEffectPhaseById;
|
|
330
|
+
private _runningAsyncEffectsById;
|
|
330
331
|
constructor({ platform, projectUrl, cachedSubcircuits, pendingSubcircuitRenders, }?: {
|
|
331
332
|
platform?: PlatformConfig;
|
|
332
333
|
projectUrl?: string;
|
|
@@ -344,6 +345,13 @@ declare class IsolatedCircuit {
|
|
|
344
345
|
renderUntilSettled(): Promise<void>;
|
|
345
346
|
_hasIncompleteAsyncEffects(): boolean;
|
|
346
347
|
_hasIncompleteAsyncEffectsForPhase(phase: RenderPhase): boolean;
|
|
348
|
+
getRunningAsyncEffects(): Array<{
|
|
349
|
+
asyncEffectId: string;
|
|
350
|
+
effectName?: string;
|
|
351
|
+
componentDisplayName?: string;
|
|
352
|
+
phase?: RenderPhase;
|
|
353
|
+
error?: string;
|
|
354
|
+
}>;
|
|
347
355
|
getCircuitJson(): AnyCircuitElement[];
|
|
348
356
|
toJson(): AnyCircuitElement[];
|
|
349
357
|
getSvg(options: {
|
|
@@ -1643,6 +1651,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1643
1651
|
updatePcbComponentAnchorAlignment(): void;
|
|
1644
1652
|
_renderReactSubtree(element: ReactElement): ReactSubtree;
|
|
1645
1653
|
doInitialInitializePortsFromChildren(): void;
|
|
1654
|
+
updateInitializePortsFromChildren(): void;
|
|
1646
1655
|
doInitialReactSubtreesRender(): void;
|
|
1647
1656
|
doInitialPcbFootprintStringRender(): void;
|
|
1648
1657
|
/**
|
|
@@ -1696,7 +1705,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1696
1705
|
doInitialCadModelRender(): void;
|
|
1697
1706
|
private _addCachebustToModelUrl;
|
|
1698
1707
|
private _getPartsEngineCacheKey;
|
|
1699
|
-
|
|
1708
|
+
protected _getSupplierPartNumbers(partsEngine: any, source_component: any, footprinterString: string | undefined): Promise<any>;
|
|
1700
1709
|
doInitialPartsEngineRender(): void;
|
|
1701
1710
|
updatePartsEngineRender(): void;
|
|
1702
1711
|
doInitialAssignFallbackProps(): void;
|
|
@@ -88078,6 +88087,14 @@ declare class Battery extends NormalComponent<typeof batteryProps, PassivePorts>
|
|
|
88078
88087
|
}
|
|
88079
88088
|
|
|
88080
88089
|
declare class Connector<PinLabels extends string = never> extends Chip<PinLabels> {
|
|
88090
|
+
private _getConnectorProps;
|
|
88091
|
+
private _hasExplicitFootprint;
|
|
88092
|
+
private _shouldUseStandardPartsEngineCircuitJsonFlow;
|
|
88093
|
+
private _insertStandardConnectorCircuitJsonError;
|
|
88094
|
+
private _getSupplierPartNumbersToTry;
|
|
88095
|
+
private _tryFetchPartCircuitJson;
|
|
88096
|
+
private _fetchStandardConnectorCircuitJson;
|
|
88097
|
+
private _addConnectorFootprintFromCircuitJson;
|
|
88081
88098
|
get config(): {
|
|
88082
88099
|
componentName: string;
|
|
88083
88100
|
zodProps: zod.ZodObject<{
|
|
@@ -91732,6 +91749,8 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
|
|
|
91732
91749
|
schHeight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
91733
91750
|
noSchematicRepresentation: zod.ZodOptional<zod.ZodBoolean>;
|
|
91734
91751
|
connections: zod.ZodOptional<zod.ZodPipeline<zod.ZodType<Partial<Record<string, string | string[] | readonly string[]>>, zod.ZodTypeDef, Partial<Record<string, string | string[] | readonly string[]>>>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodReadonly<zod.ZodArray<zod.ZodString, "many">>]>, zod.ZodArray<zod.ZodString, "many">]>>>>;
|
|
91752
|
+
} & {
|
|
91753
|
+
standard: zod.ZodOptional<zod.ZodEnum<["usb_c", "m2"]>>;
|
|
91735
91754
|
}, "strip", zod.ZodTypeAny, {
|
|
91736
91755
|
name: string;
|
|
91737
91756
|
symbol?: _tscircuit_props.SymbolProp | undefined;
|
|
@@ -92384,6 +92403,7 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
|
|
|
92384
92403
|
supplierPartNumber?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
|
|
92385
92404
|
}[] | undefined;
|
|
92386
92405
|
noSchematicRepresentation?: boolean | undefined;
|
|
92406
|
+
standard?: "usb_c" | "m2" | undefined;
|
|
92387
92407
|
}, {
|
|
92388
92408
|
name: string;
|
|
92389
92409
|
symbol?: _tscircuit_props.SymbolProp | undefined;
|
|
@@ -93038,10 +93058,15 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
|
|
|
93038
93058
|
supplierPartNumber?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
|
|
93039
93059
|
}[] | undefined;
|
|
93040
93060
|
noSchematicRepresentation?: boolean | undefined;
|
|
93061
|
+
standard?: "usb_c" | "m2" | undefined;
|
|
93041
93062
|
}>;
|
|
93042
93063
|
shouldRenderAsSchematicBox: boolean;
|
|
93043
93064
|
};
|
|
93044
93065
|
doInitialSourceRender(): void;
|
|
93066
|
+
private _isUsingStandardPartsEngineCircuitJsonFlow;
|
|
93067
|
+
doInitialFetchPartFootprint(): void;
|
|
93068
|
+
doInitialPartsEngineRender(): void;
|
|
93069
|
+
updatePartsEngineRender(): void;
|
|
93045
93070
|
doInitialPcbComponentSizeCalculation(): void;
|
|
93046
93071
|
}
|
|
93047
93072
|
|
|
@@ -151973,7 +151998,7 @@ interface TscircuitElements {
|
|
|
151973
151998
|
constraint: _tscircuit_props.ConstraintProps;
|
|
151974
151999
|
constrainedlayout: _tscircuit_props.ConstrainedLayoutProps;
|
|
151975
152000
|
battery: _tscircuit_props.BatteryProps;
|
|
151976
|
-
connector: _tscircuit_props.
|
|
152001
|
+
connector: _tscircuit_props.ConnectorProps;
|
|
151977
152002
|
pinheader: _tscircuit_props.PinHeaderProps;
|
|
151978
152003
|
resonator: _tscircuit_props.ResonatorProps;
|
|
151979
152004
|
subcircuit: _tscircuit_props.SubcircuitGroupProps;
|
package/dist/index.js
CHANGED
|
@@ -301,6 +301,7 @@ var orderedRenderPhases = [
|
|
|
301
301
|
"InflateSubcircuitCircuitJson",
|
|
302
302
|
"SourceNameDuplicateComponentRemoval",
|
|
303
303
|
"PcbFootprintStringRender",
|
|
304
|
+
"FetchPartFootprint",
|
|
304
305
|
"InitializePortsFromChildren",
|
|
305
306
|
"CreateNetsFromProps",
|
|
306
307
|
"AssignFallbackProps",
|
|
@@ -355,27 +356,40 @@ var renderPhaseIndexMap = new Map(
|
|
|
355
356
|
);
|
|
356
357
|
var asyncPhaseDependencies = {
|
|
357
358
|
InflateSubcircuitCircuitJson: ["RenderIsolatedSubcircuits"],
|
|
358
|
-
PcbFootprintLayout: ["PcbFootprintStringRender"],
|
|
359
|
-
PcbComponentSizeCalculation: [
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
PcbFootprintLayout: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
360
|
+
PcbComponentSizeCalculation: [
|
|
361
|
+
"PcbFootprintStringRender",
|
|
362
|
+
"FetchPartFootprint"
|
|
363
|
+
],
|
|
364
|
+
PcbLayout: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
365
|
+
PcbBoardAutoSize: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
366
|
+
PcbTraceHintRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
367
|
+
PcbManualTraceRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
364
368
|
PcbCopperPourRender: [
|
|
365
369
|
"PcbFootprintStringRender",
|
|
370
|
+
"FetchPartFootprint",
|
|
366
371
|
"PcbTraceRender",
|
|
367
372
|
"PcbRouteNetIslands"
|
|
368
373
|
],
|
|
369
|
-
PcbTraceRender: ["PcbFootprintStringRender"],
|
|
370
|
-
PcbRouteNetIslands: ["PcbFootprintStringRender"],
|
|
371
|
-
PcbDesignRuleChecks: ["PcbFootprintStringRender"],
|
|
372
|
-
SilkscreenOverlapAdjustment: [
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
374
|
+
PcbTraceRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
375
|
+
PcbRouteNetIslands: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
376
|
+
PcbDesignRuleChecks: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
377
|
+
SilkscreenOverlapAdjustment: [
|
|
378
|
+
"PcbFootprintStringRender",
|
|
379
|
+
"FetchPartFootprint"
|
|
380
|
+
],
|
|
381
|
+
CadModelRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
382
|
+
PartsEngineRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
383
|
+
PcbComponentAnchorAlignment: [
|
|
384
|
+
"PcbFootprintStringRender",
|
|
385
|
+
"FetchPartFootprint"
|
|
386
|
+
],
|
|
387
|
+
PcbCalcPlacementResolution: [
|
|
388
|
+
"PcbFootprintStringRender",
|
|
389
|
+
"FetchPartFootprint"
|
|
390
|
+
],
|
|
391
|
+
ValidatePcbCoordinates: ["PcbFootprintStringRender", "FetchPartFootprint"],
|
|
392
|
+
SourceTraceRender: ["PcbFootprintStringRender", "FetchPartFootprint"]
|
|
379
393
|
};
|
|
380
394
|
var globalRenderCounter = 0;
|
|
381
395
|
var globalAsyncEffectCounter = 0;
|
|
@@ -647,6 +661,9 @@ var InvalidProps = class extends Error {
|
|
|
647
661
|
this.originalProps = originalProps;
|
|
648
662
|
this.formattedError = formattedError;
|
|
649
663
|
}
|
|
664
|
+
componentName;
|
|
665
|
+
originalProps;
|
|
666
|
+
formattedError;
|
|
650
667
|
};
|
|
651
668
|
|
|
652
669
|
// lib/utils/evaluateCalcString.ts
|
|
@@ -3465,6 +3482,7 @@ var TraceConnectionError = class extends Error {
|
|
|
3465
3482
|
this.errorData = errorData;
|
|
3466
3483
|
this.name = "TraceConnectionError";
|
|
3467
3484
|
}
|
|
3485
|
+
errorData;
|
|
3468
3486
|
};
|
|
3469
3487
|
|
|
3470
3488
|
// lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
|
|
@@ -10981,6 +10999,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
10981
10999
|
doInitialInitializePortsFromChildren() {
|
|
10982
11000
|
this.initPorts();
|
|
10983
11001
|
}
|
|
11002
|
+
updateInitializePortsFromChildren() {
|
|
11003
|
+
this.initPorts();
|
|
11004
|
+
}
|
|
10984
11005
|
doInitialReactSubtreesRender() {
|
|
10985
11006
|
const fpElm = this.props.footprint;
|
|
10986
11007
|
if (isValidElement(fpElm)) {
|
|
@@ -18726,7 +18747,7 @@ var package_default = {
|
|
|
18726
18747
|
"@tscircuit/math-utils": "^0.0.36",
|
|
18727
18748
|
"@tscircuit/miniflex": "^0.0.4",
|
|
18728
18749
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
18729
|
-
"@tscircuit/props": "^0.0.
|
|
18750
|
+
"@tscircuit/props": "^0.0.501",
|
|
18730
18751
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
18731
18752
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
|
18732
18753
|
"@tscircuit/solver-utils": "^0.0.3",
|
|
@@ -18849,6 +18870,7 @@ var IsolatedCircuit = class {
|
|
|
18849
18870
|
_hasRenderedAtleastOnce = false;
|
|
18850
18871
|
_asyncEffectIdsByPhase = /* @__PURE__ */ new Map();
|
|
18851
18872
|
_asyncEffectPhaseById = /* @__PURE__ */ new Map();
|
|
18873
|
+
_runningAsyncEffectsById = /* @__PURE__ */ new Map();
|
|
18852
18874
|
constructor({
|
|
18853
18875
|
platform,
|
|
18854
18876
|
projectUrl,
|
|
@@ -18958,6 +18980,9 @@ var IsolatedCircuit = class {
|
|
|
18958
18980
|
_hasIncompleteAsyncEffectsForPhase(phase) {
|
|
18959
18981
|
return (this._asyncEffectIdsByPhase.get(phase)?.size ?? 0) > 0;
|
|
18960
18982
|
}
|
|
18983
|
+
getRunningAsyncEffects() {
|
|
18984
|
+
return Array.from(this._runningAsyncEffectsById.values());
|
|
18985
|
+
}
|
|
18961
18986
|
getCircuitJson() {
|
|
18962
18987
|
if (!this._hasRenderedAtleastOnce) this.render();
|
|
18963
18988
|
return this.db.toArray();
|
|
@@ -19057,6 +19082,13 @@ var IsolatedCircuit = class {
|
|
|
19057
19082
|
}
|
|
19058
19083
|
this._asyncEffectIdsByPhase.get(phase).add(asyncEffectId);
|
|
19059
19084
|
this._asyncEffectPhaseById.set(asyncEffectId, phase);
|
|
19085
|
+
this._runningAsyncEffectsById.set(asyncEffectId, {
|
|
19086
|
+
asyncEffectId,
|
|
19087
|
+
effectName: payload.effectName,
|
|
19088
|
+
componentDisplayName: payload.componentDisplayName,
|
|
19089
|
+
phase,
|
|
19090
|
+
error: payload.error
|
|
19091
|
+
});
|
|
19060
19092
|
}
|
|
19061
19093
|
_registerAsyncEffectEnd(payload) {
|
|
19062
19094
|
if (!payload?.asyncEffectId) return;
|
|
@@ -19070,6 +19102,7 @@ var IsolatedCircuit = class {
|
|
|
19070
19102
|
}
|
|
19071
19103
|
}
|
|
19072
19104
|
this._asyncEffectPhaseById.delete(asyncEffectId);
|
|
19105
|
+
this._runningAsyncEffectsById.delete(asyncEffectId);
|
|
19073
19106
|
}
|
|
19074
19107
|
};
|
|
19075
19108
|
|
|
@@ -22460,28 +22493,162 @@ var Battery = class extends NormalComponent3 {
|
|
|
22460
22493
|
|
|
22461
22494
|
// lib/components/normal-components/Connector.ts
|
|
22462
22495
|
import { guessCableInsertCenter } from "@tscircuit/infer-cable-insertion-point";
|
|
22463
|
-
import {
|
|
22496
|
+
import {
|
|
22497
|
+
connectorProps
|
|
22498
|
+
} from "@tscircuit/props";
|
|
22499
|
+
import { unknown_error_finding_part as unknown_error_finding_part2 } from "circuit-json";
|
|
22464
22500
|
var Connector = class extends Chip {
|
|
22501
|
+
_getConnectorProps() {
|
|
22502
|
+
return this._parsedProps;
|
|
22503
|
+
}
|
|
22504
|
+
_hasExplicitFootprint() {
|
|
22505
|
+
const props = this._getConnectorProps();
|
|
22506
|
+
return props.footprint !== void 0 || this.children.some((child) => child.componentName === "Footprint");
|
|
22507
|
+
}
|
|
22508
|
+
_shouldUseStandardPartsEngineCircuitJsonFlow() {
|
|
22509
|
+
const props = this._getConnectorProps();
|
|
22510
|
+
if (!props.standard) return false;
|
|
22511
|
+
if (this._hasExplicitFootprint()) return false;
|
|
22512
|
+
if (this.getInheritedProperty("partsEngineDisabled")) return false;
|
|
22513
|
+
return true;
|
|
22514
|
+
}
|
|
22515
|
+
_insertStandardConnectorCircuitJsonError(standard, message) {
|
|
22516
|
+
const { db } = this.root;
|
|
22517
|
+
const errorObj = unknown_error_finding_part2.parse({
|
|
22518
|
+
type: "unknown_error_finding_part",
|
|
22519
|
+
message: `Failed to fetch circuit JSON for ${this.getString()} (standard="${standard}"): ${message}`,
|
|
22520
|
+
source_component_id: this.source_component_id ?? void 0,
|
|
22521
|
+
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0
|
|
22522
|
+
});
|
|
22523
|
+
db.unknown_error_finding_part.insert(errorObj);
|
|
22524
|
+
}
|
|
22525
|
+
_getSupplierPartNumbersToTry(supplierPartNumbers) {
|
|
22526
|
+
const partNumbers = [];
|
|
22527
|
+
for (const supplier of Object.keys(supplierPartNumbers ?? {})) {
|
|
22528
|
+
const nums = supplierPartNumbers?.[supplier];
|
|
22529
|
+
if (Array.isArray(nums) && nums.length > 0) {
|
|
22530
|
+
partNumbers.push(nums[0]);
|
|
22531
|
+
}
|
|
22532
|
+
}
|
|
22533
|
+
return partNumbers;
|
|
22534
|
+
}
|
|
22535
|
+
async _tryFetchPartCircuitJson(fetchPartCircuitJson, params) {
|
|
22536
|
+
const maybeCircuitJson = await Promise.resolve(fetchPartCircuitJson(params)) ?? null;
|
|
22537
|
+
if (Array.isArray(maybeCircuitJson) && maybeCircuitJson.length > 0) {
|
|
22538
|
+
return maybeCircuitJson;
|
|
22539
|
+
}
|
|
22540
|
+
return null;
|
|
22541
|
+
}
|
|
22542
|
+
async _fetchStandardConnectorCircuitJson(fetchPartCircuitJson, supplierPartNumbers, manufacturerPartNumber) {
|
|
22543
|
+
for (const supplierPartNumber of this._getSupplierPartNumbersToTry(
|
|
22544
|
+
supplierPartNumbers
|
|
22545
|
+
)) {
|
|
22546
|
+
const circuitJson = await this._tryFetchPartCircuitJson(
|
|
22547
|
+
fetchPartCircuitJson,
|
|
22548
|
+
{ supplierPartNumber }
|
|
22549
|
+
);
|
|
22550
|
+
if (circuitJson) return circuitJson;
|
|
22551
|
+
}
|
|
22552
|
+
if (!manufacturerPartNumber) return null;
|
|
22553
|
+
return this._tryFetchPartCircuitJson(fetchPartCircuitJson, {
|
|
22554
|
+
manufacturerPartNumber
|
|
22555
|
+
});
|
|
22556
|
+
}
|
|
22557
|
+
_addConnectorFootprintFromCircuitJson(standard, circuitJson) {
|
|
22558
|
+
const props = this._getConnectorProps();
|
|
22559
|
+
const fpComponents = createComponentsFromCircuitJson(
|
|
22560
|
+
{
|
|
22561
|
+
componentName: this.name,
|
|
22562
|
+
componentRotation: String(props.pcbRotation ?? 0),
|
|
22563
|
+
footprinterString: `standard:${standard}`,
|
|
22564
|
+
pinLabels: props.pinLabels,
|
|
22565
|
+
pcbPinLabels: props.pcbPinLabels
|
|
22566
|
+
},
|
|
22567
|
+
circuitJson
|
|
22568
|
+
);
|
|
22569
|
+
this.addAll(fpComponents);
|
|
22570
|
+
}
|
|
22465
22571
|
get config() {
|
|
22466
22572
|
return {
|
|
22467
22573
|
componentName: "Connector",
|
|
22468
|
-
zodProps:
|
|
22574
|
+
zodProps: connectorProps,
|
|
22469
22575
|
shouldRenderAsSchematicBox: true
|
|
22470
22576
|
};
|
|
22471
22577
|
}
|
|
22472
22578
|
doInitialSourceRender() {
|
|
22473
22579
|
const { db } = this.root;
|
|
22474
|
-
const
|
|
22580
|
+
const props = this._getConnectorProps();
|
|
22475
22581
|
const source_component = db.source_component.insert({
|
|
22476
22582
|
ftype: "simple_connector",
|
|
22477
22583
|
name: this.name,
|
|
22478
|
-
manufacturer_part_number: props.manufacturerPartNumber,
|
|
22584
|
+
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
22479
22585
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
22480
22586
|
display_name: props.displayName,
|
|
22481
22587
|
standard: props.standard
|
|
22482
22588
|
});
|
|
22483
22589
|
this.source_component_id = source_component.source_component_id;
|
|
22484
22590
|
}
|
|
22591
|
+
_isUsingStandardPartsEngineCircuitJsonFlow() {
|
|
22592
|
+
if (!this._shouldUseStandardPartsEngineCircuitJsonFlow()) return false;
|
|
22593
|
+
const partsEngine = this.getInheritedProperty("partsEngine");
|
|
22594
|
+
return Boolean(partsEngine?.fetchPartCircuitJson);
|
|
22595
|
+
}
|
|
22596
|
+
doInitialFetchPartFootprint() {
|
|
22597
|
+
const props = this._getConnectorProps();
|
|
22598
|
+
const standard = props.standard;
|
|
22599
|
+
if (!standard) return;
|
|
22600
|
+
if (!this._shouldUseStandardPartsEngineCircuitJsonFlow()) return;
|
|
22601
|
+
if (this._hasStartedFootprintUrlLoad) return;
|
|
22602
|
+
const partsEngine = this.getInheritedProperty("partsEngine");
|
|
22603
|
+
if (partsEngine && !partsEngine.fetchPartCircuitJson) {
|
|
22604
|
+
this._insertStandardConnectorCircuitJsonError(
|
|
22605
|
+
standard,
|
|
22606
|
+
"partsEngine.fetchPartCircuitJson is not configured"
|
|
22607
|
+
);
|
|
22608
|
+
return;
|
|
22609
|
+
}
|
|
22610
|
+
const fetchPartCircuitJson = partsEngine?.fetchPartCircuitJson;
|
|
22611
|
+
if (!fetchPartCircuitJson) return;
|
|
22612
|
+
this._hasStartedFootprintUrlLoad = true;
|
|
22613
|
+
const sourceComponentForQuery = {
|
|
22614
|
+
ftype: "simple_connector",
|
|
22615
|
+
name: this.name,
|
|
22616
|
+
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
22617
|
+
standard
|
|
22618
|
+
};
|
|
22619
|
+
this._queueAsyncEffect("load-standard-connector-circuit-json", async () => {
|
|
22620
|
+
const { db } = this.root;
|
|
22621
|
+
try {
|
|
22622
|
+
const supplierPartNumbers = await this._getSupplierPartNumbers(
|
|
22623
|
+
partsEngine,
|
|
22624
|
+
sourceComponentForQuery,
|
|
22625
|
+
`standard:${standard}`
|
|
22626
|
+
);
|
|
22627
|
+
if (this.source_component_id) {
|
|
22628
|
+
db.source_component.update(this.source_component_id, {
|
|
22629
|
+
supplier_part_numbers: supplierPartNumbers
|
|
22630
|
+
});
|
|
22631
|
+
}
|
|
22632
|
+
const circuitJson = await this._fetchStandardConnectorCircuitJson(
|
|
22633
|
+
fetchPartCircuitJson,
|
|
22634
|
+
supplierPartNumbers,
|
|
22635
|
+
sourceComponentForQuery.manufacturer_part_number
|
|
22636
|
+
);
|
|
22637
|
+
if (!circuitJson) return;
|
|
22638
|
+
this._addConnectorFootprintFromCircuitJson(standard, circuitJson);
|
|
22639
|
+
} catch (error) {
|
|
22640
|
+
this._insertStandardConnectorCircuitJsonError(standard, error.message);
|
|
22641
|
+
}
|
|
22642
|
+
});
|
|
22643
|
+
}
|
|
22644
|
+
doInitialPartsEngineRender() {
|
|
22645
|
+
if (this._isUsingStandardPartsEngineCircuitJsonFlow()) return;
|
|
22646
|
+
super.doInitialPartsEngineRender();
|
|
22647
|
+
}
|
|
22648
|
+
updatePartsEngineRender() {
|
|
22649
|
+
if (this._isUsingStandardPartsEngineCircuitJsonFlow()) return;
|
|
22650
|
+
super.updatePartsEngineRender();
|
|
22651
|
+
}
|
|
22485
22652
|
doInitialPcbComponentSizeCalculation() {
|
|
22486
22653
|
super.doInitialPcbComponentSizeCalculation();
|
|
22487
22654
|
if (this.root?.pcbDisabled) return;
|
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.1129",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@tscircuit/math-utils": "^0.0.36",
|
|
47
47
|
"@tscircuit/miniflex": "^0.0.4",
|
|
48
48
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
49
|
-
"@tscircuit/props": "^0.0.
|
|
49
|
+
"@tscircuit/props": "^0.0.501",
|
|
50
50
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
51
51
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
|
52
52
|
"@tscircuit/solver-utils": "^0.0.3",
|