@tscircuit/core 0.0.761 → 0.0.763

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
@@ -1,7 +1,7 @@
1
1
  import * as circuit_json from 'circuit-json';
2
2
  import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, LayerRef, AnyCircuitElement, Size, AnySourceComponent, PcbTraceRoutePoint, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, solderjumperProps, ledProps, powerSourceProps, CommonComponentProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, copperPourProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, solderjumperProps, ledProps, powerSourceProps, CommonComponentProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, copperPourProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  import * as react from 'react';
6
6
  import react__default, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
7
7
  export { createElement } from 'react';
@@ -30507,6 +30507,7 @@ declare class Switch extends NormalComponent<typeof switchProps> {
30507
30507
  spdt: zod.ZodOptional<zod.ZodBoolean>;
30508
30508
  dpst: zod.ZodOptional<zod.ZodBoolean>;
30509
30509
  dpdt: zod.ZodOptional<zod.ZodBoolean>;
30510
+ 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">]>>>>;
30510
30511
  }, "strip", zod.ZodTypeAny, {
30511
30512
  name: string;
30512
30513
  isNormallyClosed: boolean;
@@ -30681,6 +30682,7 @@ declare class Switch extends NormalComponent<typeof switchProps> {
30681
30682
  symbolName?: string | undefined;
30682
30683
  doNotPlace?: boolean | undefined;
30683
30684
  obstructsWithinBounds?: boolean | undefined;
30685
+ connections?: Record<string, string | readonly string[] | string[]> | undefined;
30684
30686
  spst?: boolean | undefined;
30685
30687
  spdt?: boolean | undefined;
30686
30688
  dpst?: boolean | undefined;
@@ -30860,12 +30862,13 @@ declare class Switch extends NormalComponent<typeof switchProps> {
30860
30862
  symbolName?: string | undefined;
30861
30863
  doNotPlace?: boolean | undefined;
30862
30864
  obstructsWithinBounds?: boolean | undefined;
30865
+ connections?: Partial<Record<string, string | string[] | readonly string[]>> | undefined;
30863
30866
  spst?: boolean | undefined;
30864
30867
  spdt?: boolean | undefined;
30865
30868
  dpst?: boolean | undefined;
30866
30869
  dpdt?: boolean | undefined;
30867
30870
  isNormallyClosed?: boolean | undefined;
30868
- }>, _tscircuit_props.SwitchProps, {
30871
+ }>, SwitchProps, {
30869
30872
  name: string;
30870
30873
  symbol?: _tscircuit_props.SymbolProp | undefined;
30871
30874
  type?: "spst" | "spdt" | "dpst" | "dpdt" | undefined;
@@ -31040,6 +31043,7 @@ declare class Switch extends NormalComponent<typeof switchProps> {
31040
31043
  symbolName?: string | undefined;
31041
31044
  doNotPlace?: boolean | undefined;
31042
31045
  obstructsWithinBounds?: boolean | undefined;
31046
+ connections?: Partial<Record<string, string | string[] | readonly string[]>> | undefined;
31043
31047
  spst?: boolean | undefined;
31044
31048
  spdt?: boolean | undefined;
31045
31049
  dpst?: boolean | undefined;
@@ -31049,6 +31053,7 @@ declare class Switch extends NormalComponent<typeof switchProps> {
31049
31053
  shouldRenderAsSchematicBox: boolean;
31050
31054
  };
31051
31055
  doInitialSourceRender(): void;
31056
+ doInitialSimulationRender(): void;
31052
31057
  }
31053
31058
 
31054
31059
  declare class TestPoint extends NormalComponent<typeof testpointProps> {
@@ -32489,16 +32494,8 @@ declare class SchematicRect extends PrimitiveComponent<typeof schematicRectProps
32489
32494
  get config(): {
32490
32495
  componentName: string;
32491
32496
  zodProps: zod.ZodObject<{
32492
- center: zod.ZodObject<{
32493
- x: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32494
- y: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32495
- }, "strip", zod.ZodTypeAny, {
32496
- x: number;
32497
- y: number;
32498
- }, {
32499
- x: string | number;
32500
- y: string | number;
32501
- }>;
32497
+ schX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
32498
+ schY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
32502
32499
  width: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32503
32500
  height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32504
32501
  rotation: zod.ZodDefault<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -32508,25 +32505,21 @@ declare class SchematicRect extends PrimitiveComponent<typeof schematicRectProps
32508
32505
  fillColor: zod.ZodOptional<zod.ZodString>;
32509
32506
  isDashed: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
32510
32507
  }, "strip", zod.ZodTypeAny, {
32511
- center: {
32512
- x: number;
32513
- y: number;
32514
- };
32515
32508
  width: number;
32516
32509
  height: number;
32517
32510
  color: string;
32518
32511
  isDashed: boolean;
32519
32512
  isFilled: boolean;
32520
32513
  rotation: number;
32514
+ schX?: number | undefined;
32515
+ schY?: number | undefined;
32521
32516
  strokeWidth?: number | undefined;
32522
32517
  fillColor?: string | undefined;
32523
32518
  }, {
32524
- center: {
32525
- x: string | number;
32526
- y: string | number;
32527
- };
32528
32519
  width: string | number;
32529
32520
  height: string | number;
32521
+ schX?: string | number | undefined;
32522
+ schY?: string | number | undefined;
32530
32523
  strokeWidth?: string | number | undefined;
32531
32524
  color?: string | undefined;
32532
32525
  isDashed?: boolean | undefined;
package/dist/index.js CHANGED
@@ -7845,7 +7845,13 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
7845
7845
  const width = Math.abs(bounds.maxX - bounds.minX);
7846
7846
  const height = Math.abs(bounds.maxY - bounds.minY);
7847
7847
  if (width === 0 && height === 0) return;
7848
+ const centerX = (bounds.minX + bounds.maxX) / 2;
7849
+ const centerY = (bounds.minY + bounds.maxY) / 2;
7848
7850
  db.schematic_component.update(this.schematic_component_id, {
7851
+ center: {
7852
+ x: centerX,
7853
+ y: centerY
7854
+ },
7849
7855
  size: {
7850
7856
  width,
7851
7857
  height
@@ -15227,36 +15233,55 @@ var Mosfet = class extends NormalComponent3 {
15227
15233
  };
15228
15234
 
15229
15235
  // lib/components/normal-components/Switch.ts
15230
- import { switchProps } from "@tscircuit/props";
15236
+ import {
15237
+ switchProps
15238
+ } from "@tscircuit/props";
15239
+ var hasSimulationValues = (values) => {
15240
+ if (!values) return false;
15241
+ return values.closesAt !== void 0 || values.opensAt !== void 0 || values.startsClosed !== void 0 || values.switchingFrequency !== void 0;
15242
+ };
15243
+ var isSpiceContainer = (simulation) => {
15244
+ if (!simulation || typeof simulation !== "object") {
15245
+ return false;
15246
+ }
15247
+ return Object.prototype.hasOwnProperty.call(simulation, "spice");
15248
+ };
15249
+ var getSimulationValues = (simulation) => {
15250
+ if (!simulation || typeof simulation !== "object") {
15251
+ return null;
15252
+ }
15253
+ const maybeValues = isSpiceContainer(simulation) ? simulation.spice ?? null : simulation;
15254
+ return hasSimulationValues(maybeValues) ? { ...maybeValues } : null;
15255
+ };
15231
15256
  var Switch = class extends NormalComponent3 {
15232
15257
  _getSwitchType() {
15233
- const { spst, spdt, dpst, dpdt, type } = this._parsedProps ?? {};
15234
- if (dpdt) return "dpdt";
15235
- if (spst) return "spst";
15236
- if (spdt) return "spdt";
15237
- if (dpst) return "dpst";
15238
- return type ?? "spst";
15258
+ const props = this._parsedProps;
15259
+ if (!props) return "spst";
15260
+ if (props.dpdt) return "dpdt";
15261
+ if (props.spst) return "spst";
15262
+ if (props.spdt) return "spdt";
15263
+ if (props.dpst) return "dpst";
15264
+ return props.type ?? "spst";
15239
15265
  }
15240
15266
  get config() {
15241
15267
  const switchType = this._getSwitchType();
15242
- const { isNormallyClosed } = this._parsedProps ?? {};
15243
- const baseSymbolNameMap = {
15268
+ const isNormallyClosed = this._parsedProps?.isNormallyClosed ?? false;
15269
+ const symbolMap = {
15244
15270
  spst: isNormallyClosed ? "spst_normally_closed_switch" : "spst_switch",
15245
15271
  spdt: isNormallyClosed ? "spdt_normally_closed_switch" : "spdt_switch",
15246
15272
  dpst: isNormallyClosed ? "dpst_normally_closed_switch" : "dpst_switch",
15247
15273
  dpdt: isNormallyClosed ? "dpdt_normally_closed_switch" : "dpdt_switch"
15248
15274
  };
15249
- const symbolName = baseSymbolNameMap[switchType] ?? "spst_switch";
15250
15275
  return {
15251
15276
  componentName: "Switch",
15252
- schematicSymbolName: this.props.symbolName ?? symbolName,
15277
+ schematicSymbolName: this.props.symbolName ?? symbolMap[switchType],
15253
15278
  zodProps: switchProps,
15254
15279
  shouldRenderAsSchematicBox: false
15255
15280
  };
15256
15281
  }
15257
15282
  doInitialSourceRender() {
15258
15283
  const { db } = this.root;
15259
- const { _parsedProps: props } = this;
15284
+ const props = this._parsedProps ?? {};
15260
15285
  const source_component = db.source_component.insert({
15261
15286
  ftype: "simple_switch",
15262
15287
  name: this.name,
@@ -15266,6 +15291,31 @@ var Switch = class extends NormalComponent3 {
15266
15291
  });
15267
15292
  this.source_component_id = source_component.source_component_id;
15268
15293
  }
15294
+ doInitialSimulationRender() {
15295
+ const props = this.props;
15296
+ const simulationValues = getSimulationValues(props.simulation);
15297
+ if (!simulationValues) {
15298
+ return;
15299
+ }
15300
+ const { db } = this.root;
15301
+ const simulationSwitch = {
15302
+ type: "simulation_switch"
15303
+ };
15304
+ if (simulationValues.closesAt !== void 0) {
15305
+ simulationSwitch.closes_at = simulationValues.closesAt;
15306
+ }
15307
+ if (simulationValues.opensAt !== void 0) {
15308
+ simulationSwitch.opens_at = simulationValues.opensAt;
15309
+ }
15310
+ if (simulationValues.startsClosed !== void 0) {
15311
+ simulationSwitch.starts_closed = simulationValues.startsClosed;
15312
+ }
15313
+ if (simulationValues.switchingFrequency !== void 0) {
15314
+ simulationSwitch.switching_frequency = simulationValues.switchingFrequency;
15315
+ }
15316
+ ;
15317
+ db.simulation_switch.insert(simulationSwitch);
15318
+ }
15269
15319
  };
15270
15320
 
15271
15321
  // lib/components/normal-components/TestPoint.ts
@@ -15448,8 +15498,8 @@ var SchematicRect = class extends PrimitiveComponent2 {
15448
15498
  const schematic_component_id = this.getPrimitiveContainer()?.parent?.schematic_component_id;
15449
15499
  const schematic_rect = db.schematic_rect.insert({
15450
15500
  center: {
15451
- x: props.center.x + globalPos.x,
15452
- y: props.center.y + globalPos.y
15501
+ x: globalPos.x,
15502
+ y: globalPos.y
15453
15503
  },
15454
15504
  width: props.width,
15455
15505
  height: props.height,
@@ -15920,7 +15970,7 @@ import { identity as identity6 } from "transformation-matrix";
15920
15970
  var package_default = {
15921
15971
  name: "@tscircuit/core",
15922
15972
  type: "module",
15923
- version: "0.0.760",
15973
+ version: "0.0.762",
15924
15974
  types: "dist/index.d.ts",
15925
15975
  main: "dist/index.js",
15926
15976
  module: "dist/index.js",
@@ -15959,7 +16009,7 @@ var package_default = {
15959
16009
  "@tscircuit/matchpack": "^0.0.16",
15960
16010
  "@tscircuit/math-utils": "^0.0.21",
15961
16011
  "@tscircuit/miniflex": "^0.0.4",
15962
- "@tscircuit/props": "0.0.343",
16012
+ "@tscircuit/props": "0.0.349",
15963
16013
  "@tscircuit/schematic-autolayout": "^0.0.6",
15964
16014
  "@tscircuit/schematic-match-adapt": "^0.0.16",
15965
16015
  "@tscircuit/schematic-trace-solver": "^0.0.40",
@@ -15972,7 +16022,7 @@ var package_default = {
15972
16022
  "bun-match-svg": "0.0.12",
15973
16023
  "calculate-elbow": "^0.0.12",
15974
16024
  "chokidar-cli": "^3.0.0",
15975
- "circuit-json": "^0.0.267",
16025
+ "circuit-json": "^0.0.268",
15976
16026
  "circuit-json-to-bpc": "^0.0.13",
15977
16027
  "circuit-json-to-connectivity-map": "^0.0.22",
15978
16028
  "circuit-json-to-gltf": "^0.0.7",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.761",
4
+ "version": "0.0.763",
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.16",
41
41
  "@tscircuit/math-utils": "^0.0.21",
42
42
  "@tscircuit/miniflex": "^0.0.4",
43
- "@tscircuit/props": "0.0.343",
43
+ "@tscircuit/props": "0.0.349",
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.40",
@@ -53,7 +53,7 @@
53
53
  "bun-match-svg": "0.0.12",
54
54
  "calculate-elbow": "^0.0.12",
55
55
  "chokidar-cli": "^3.0.0",
56
- "circuit-json": "^0.0.267",
56
+ "circuit-json": "^0.0.268",
57
57
  "circuit-json-to-bpc": "^0.0.13",
58
58
  "circuit-json-to-connectivity-map": "^0.0.22",
59
59
  "circuit-json-to-gltf": "^0.0.7",