@tscircuit/core 0.0.661 → 0.0.663

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 CHANGED
@@ -12,7 +12,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
12
12
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
13
13
  import { GraphicsObject } from 'graphics-debug';
14
14
 
15
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
15
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
16
16
  type RenderPhase = (typeof orderedRenderPhases)[number];
17
17
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
18
18
  type RenderPhaseStates = Record<RenderPhase, {
@@ -1104,6 +1104,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1104
1104
  doInitialAssignFallbackProps(): void;
1105
1105
  doInitialCreateTracesFromProps(): void;
1106
1106
  _createTracesFromConnectionsProp(): void;
1107
+ doInitialSourceDesignRuleChecks(): void;
1107
1108
  /**
1108
1109
  * Get the minimum flex container size for this component on PCB
1109
1110
  */
@@ -12019,7 +12020,7 @@ declare class PinHeader extends NormalComponent<typeof pinHeaderProps> {
12019
12020
  rightAngle: zod.ZodOptional<zod.ZodBoolean>;
12020
12021
  holeDiameter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
12021
12022
  platedDiameter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
12022
- pinLabels: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
12023
+ pinLabels: zod.ZodOptional<zod.ZodUnion<[zod.ZodRecord<zod.ZodString, zod.ZodString>, zod.ZodArray<zod.ZodString, "many">]>>;
12023
12024
  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">]>>>>;
12024
12025
  facingDirection: zod.ZodOptional<zod.ZodEnum<["left", "right"]>>;
12025
12026
  schPinArrangement: zod.ZodOptional<zod.ZodObject<{
@@ -12236,7 +12237,7 @@ declare class PinHeader extends NormalComponent<typeof pinHeaderProps> {
12236
12237
  doNotPlace?: boolean | undefined;
12237
12238
  schWidth?: number | undefined;
12238
12239
  schHeight?: number | undefined;
12239
- pinLabels?: string[] | undefined;
12240
+ pinLabels?: string[] | Record<string, string> | undefined;
12240
12241
  pcbPinLabels?: Record<string, string> | undefined;
12241
12242
  schPinArrangement?: {
12242
12243
  leftSize?: number | undefined;
@@ -12369,7 +12370,7 @@ declare class PinHeader extends NormalComponent<typeof pinHeaderProps> {
12369
12370
  schWidth?: string | number | undefined;
12370
12371
  schHeight?: string | number | undefined;
12371
12372
  gender?: "male" | "female" | "unpopulated" | undefined;
12372
- pinLabels?: string[] | undefined;
12373
+ pinLabels?: string[] | Record<string, string> | undefined;
12373
12374
  pcbPinLabels?: Record<string, string> | undefined;
12374
12375
  schPinArrangement?: {
12375
12376
  leftSize?: number | undefined;
package/dist/index.js CHANGED
@@ -99,6 +99,7 @@ var orderedRenderPhases = [
99
99
  "OptimizeSelectorCache",
100
100
  "SourceTraceRender",
101
101
  "SourceAddConnectivityMapKey",
102
+ "SourceDesignRuleChecks",
102
103
  "SimulationRender",
103
104
  "SchematicComponentRender",
104
105
  "SchematicPortRender",
@@ -6229,6 +6230,54 @@ var NormalComponent__repositionOnPcb = (component, position) => {
6229
6230
  );
6230
6231
  };
6231
6232
 
6233
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialSourceDesignRuleChecks.ts
6234
+ var NormalComponent_doInitialSourceDesignRuleChecks = (component) => {
6235
+ const { db } = component.root;
6236
+ if (!component.source_component_id) return;
6237
+ const ports = component.selectAll("port");
6238
+ const traces = db.source_trace.list();
6239
+ const connected = /* @__PURE__ */ new Set();
6240
+ for (const trace of traces) {
6241
+ for (const id of trace.connected_source_port_ids) {
6242
+ connected.add(id);
6243
+ }
6244
+ }
6245
+ const internalGroups = component._getInternallyConnectedPins();
6246
+ for (const group of internalGroups) {
6247
+ if (group.some((p) => p.source_port_id && connected.has(p.source_port_id))) {
6248
+ for (const p of group) {
6249
+ if (p.source_port_id) connected.add(p.source_port_id);
6250
+ }
6251
+ }
6252
+ }
6253
+ for (const port of ports) {
6254
+ if (!port.source_port_id) continue;
6255
+ if (!shouldCheckPortForMissingTrace(component, port)) continue;
6256
+ if (connected.has(port.source_port_id)) continue;
6257
+ db.source_pin_missing_trace_warning.insert({
6258
+ message: `Port ${port.getNameAndAliases()[0]} on ${component.props.name} is missing a trace`,
6259
+ source_component_id: component.source_component_id,
6260
+ source_port_id: port.source_port_id,
6261
+ subcircuit_id: component.getSubcircuit().subcircuit_id ?? void 0,
6262
+ warning_type: "source_pin_missing_trace_warning"
6263
+ });
6264
+ }
6265
+ };
6266
+ var shouldCheckPortForMissingTrace = (component, port) => {
6267
+ if (component.config.componentName === "Chip") {
6268
+ const pinAttributes = component.props.pinAttributes;
6269
+ if (!pinAttributes) return false;
6270
+ for (const alias of port.getNameAndAliases()) {
6271
+ const attrs = pinAttributes[alias];
6272
+ if (attrs?.requiresPower || attrs?.requiresGround || attrs?.requiresVoltage !== void 0) {
6273
+ return true;
6274
+ }
6275
+ }
6276
+ return false;
6277
+ }
6278
+ return true;
6279
+ };
6280
+
6232
6281
  // lib/components/base-components/NormalComponent/NormalComponent.ts
6233
6282
  var debug3 = Debug4("tscircuit:core");
6234
6283
  var rotation3 = z8.object({
@@ -7101,6 +7150,9 @@ var NormalComponent = class extends PrimitiveComponent2 {
7101
7150
  }
7102
7151
  }
7103
7152
  }
7153
+ doInitialSourceDesignRuleChecks() {
7154
+ NormalComponent_doInitialSourceDesignRuleChecks(this);
7155
+ }
7104
7156
  /**
7105
7157
  * Get the minimum flex container size for this component on PCB
7106
7158
  */
@@ -12856,7 +12908,7 @@ var PinHeader = class extends NormalComponent {
12856
12908
  };
12857
12909
  }
12858
12910
  _getImpliedFootprintString() {
12859
- const pinCount = this._parsedProps.pinCount ?? this._parsedProps.pinLabels?.length ?? 0;
12911
+ const pinCount = this._parsedProps.pinCount ?? (Array.isArray(this._parsedProps.pinLabels) ? this._parsedProps.pinLabels.length : this._parsedProps.pinLabels ? Object.keys(this._parsedProps.pinLabels).length : 0);
12860
12912
  const holeDiameter = this._parsedProps.holeDiameter;
12861
12913
  const platedDiameter = this._parsedProps.platedDiameter;
12862
12914
  const pitch = this._parsedProps.pitch;
@@ -12884,15 +12936,14 @@ var PinHeader = class extends NormalComponent {
12884
12936
  return null;
12885
12937
  }
12886
12938
  initPorts() {
12887
- const pinCount = this._parsedProps.pinCount ?? this._parsedProps.pinLabels?.length ?? 1;
12939
+ const pinCount = this._parsedProps.pinCount ?? (Array.isArray(this._parsedProps.pinLabels) ? this._parsedProps.pinLabels.length : this._parsedProps.pinLabels ? Object.keys(this._parsedProps.pinLabels).length : 1);
12888
12940
  for (let i = 1; i <= pinCount; i++) {
12941
+ const label = Array.isArray(this._parsedProps.pinLabels) ? this._parsedProps.pinLabels[i - 1] : this._parsedProps.pinLabels?.[i];
12889
12942
  this.add(
12890
12943
  new Port({
12891
12944
  name: `pin${i}`,
12892
12945
  pinNumber: i,
12893
- aliases: [this._parsedProps.pinLabels?.[i - 1]].filter(
12894
- Boolean
12895
- )
12946
+ aliases: [label].filter(Boolean)
12896
12947
  })
12897
12948
  );
12898
12949
  }
@@ -13775,7 +13826,7 @@ import { identity as identity5 } from "transformation-matrix";
13775
13826
  var package_default = {
13776
13827
  name: "@tscircuit/core",
13777
13828
  type: "module",
13778
- version: "0.0.660",
13829
+ version: "0.0.662",
13779
13830
  types: "dist/index.d.ts",
13780
13831
  main: "dist/index.js",
13781
13832
  module: "dist/index.js",
@@ -13814,7 +13865,7 @@ var package_default = {
13814
13865
  "@tscircuit/matchpack": "^0.0.9",
13815
13866
  "@tscircuit/math-utils": "^0.0.18",
13816
13867
  "@tscircuit/miniflex": "^0.0.4",
13817
- "@tscircuit/props": "0.0.288",
13868
+ "@tscircuit/props": "0.0.289",
13818
13869
  "@tscircuit/schematic-autolayout": "^0.0.6",
13819
13870
  "@tscircuit/schematic-match-adapt": "^0.0.16",
13820
13871
  "@tscircuit/schematic-trace-solver": "^0.0.23",
@@ -13828,7 +13879,7 @@ var package_default = {
13828
13879
  "bun-match-svg": "0.0.12",
13829
13880
  "calculate-elbow": "^0.0.9",
13830
13881
  "chokidar-cli": "^3.0.0",
13831
- "circuit-json": "^0.0.233",
13882
+ "circuit-json": "^0.0.235",
13832
13883
  "circuit-json-to-bpc": "^0.0.13",
13833
13884
  "circuit-json-to-connectivity-map": "^0.0.22",
13834
13885
  "circuit-json-to-simple-3d": "^0.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.661",
4
+ "version": "0.0.663",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "@tscircuit/matchpack": "^0.0.9",
41
41
  "@tscircuit/math-utils": "^0.0.18",
42
42
  "@tscircuit/miniflex": "^0.0.4",
43
- "@tscircuit/props": "0.0.288",
43
+ "@tscircuit/props": "0.0.289",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.6",
45
45
  "@tscircuit/schematic-match-adapt": "^0.0.16",
46
46
  "@tscircuit/schematic-trace-solver": "^0.0.23",
@@ -54,7 +54,7 @@
54
54
  "bun-match-svg": "0.0.12",
55
55
  "calculate-elbow": "^0.0.9",
56
56
  "chokidar-cli": "^3.0.0",
57
- "circuit-json": "^0.0.233",
57
+ "circuit-json": "^0.0.235",
58
58
  "circuit-json-to-bpc": "^0.0.13",
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-simple-3d": "^0.0.6",