@tscircuit/core 0.0.761 → 0.0.762

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> {
package/dist/index.js CHANGED
@@ -15227,36 +15227,55 @@ var Mosfet = class extends NormalComponent3 {
15227
15227
  };
15228
15228
 
15229
15229
  // lib/components/normal-components/Switch.ts
15230
- import { switchProps } from "@tscircuit/props";
15230
+ import {
15231
+ switchProps
15232
+ } from "@tscircuit/props";
15233
+ var hasSimulationValues = (values) => {
15234
+ if (!values) return false;
15235
+ return values.closesAt !== void 0 || values.opensAt !== void 0 || values.startsClosed !== void 0 || values.switchingFrequency !== void 0;
15236
+ };
15237
+ var isSpiceContainer = (simulation) => {
15238
+ if (!simulation || typeof simulation !== "object") {
15239
+ return false;
15240
+ }
15241
+ return Object.prototype.hasOwnProperty.call(simulation, "spice");
15242
+ };
15243
+ var getSimulationValues = (simulation) => {
15244
+ if (!simulation || typeof simulation !== "object") {
15245
+ return null;
15246
+ }
15247
+ const maybeValues = isSpiceContainer(simulation) ? simulation.spice ?? null : simulation;
15248
+ return hasSimulationValues(maybeValues) ? { ...maybeValues } : null;
15249
+ };
15231
15250
  var Switch = class extends NormalComponent3 {
15232
15251
  _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";
15252
+ const props = this._parsedProps;
15253
+ if (!props) return "spst";
15254
+ if (props.dpdt) return "dpdt";
15255
+ if (props.spst) return "spst";
15256
+ if (props.spdt) return "spdt";
15257
+ if (props.dpst) return "dpst";
15258
+ return props.type ?? "spst";
15239
15259
  }
15240
15260
  get config() {
15241
15261
  const switchType = this._getSwitchType();
15242
- const { isNormallyClosed } = this._parsedProps ?? {};
15243
- const baseSymbolNameMap = {
15262
+ const isNormallyClosed = this._parsedProps?.isNormallyClosed ?? false;
15263
+ const symbolMap = {
15244
15264
  spst: isNormallyClosed ? "spst_normally_closed_switch" : "spst_switch",
15245
15265
  spdt: isNormallyClosed ? "spdt_normally_closed_switch" : "spdt_switch",
15246
15266
  dpst: isNormallyClosed ? "dpst_normally_closed_switch" : "dpst_switch",
15247
15267
  dpdt: isNormallyClosed ? "dpdt_normally_closed_switch" : "dpdt_switch"
15248
15268
  };
15249
- const symbolName = baseSymbolNameMap[switchType] ?? "spst_switch";
15250
15269
  return {
15251
15270
  componentName: "Switch",
15252
- schematicSymbolName: this.props.symbolName ?? symbolName,
15271
+ schematicSymbolName: this.props.symbolName ?? symbolMap[switchType],
15253
15272
  zodProps: switchProps,
15254
15273
  shouldRenderAsSchematicBox: false
15255
15274
  };
15256
15275
  }
15257
15276
  doInitialSourceRender() {
15258
15277
  const { db } = this.root;
15259
- const { _parsedProps: props } = this;
15278
+ const props = this._parsedProps ?? {};
15260
15279
  const source_component = db.source_component.insert({
15261
15280
  ftype: "simple_switch",
15262
15281
  name: this.name,
@@ -15266,6 +15285,31 @@ var Switch = class extends NormalComponent3 {
15266
15285
  });
15267
15286
  this.source_component_id = source_component.source_component_id;
15268
15287
  }
15288
+ doInitialSimulationRender() {
15289
+ const props = this.props;
15290
+ const simulationValues = getSimulationValues(props.simulation);
15291
+ if (!simulationValues) {
15292
+ return;
15293
+ }
15294
+ const { db } = this.root;
15295
+ const simulationSwitch = {
15296
+ type: "simulation_switch"
15297
+ };
15298
+ if (simulationValues.closesAt !== void 0) {
15299
+ simulationSwitch.closes_at = simulationValues.closesAt;
15300
+ }
15301
+ if (simulationValues.opensAt !== void 0) {
15302
+ simulationSwitch.opens_at = simulationValues.opensAt;
15303
+ }
15304
+ if (simulationValues.startsClosed !== void 0) {
15305
+ simulationSwitch.starts_closed = simulationValues.startsClosed;
15306
+ }
15307
+ if (simulationValues.switchingFrequency !== void 0) {
15308
+ simulationSwitch.switching_frequency = simulationValues.switchingFrequency;
15309
+ }
15310
+ ;
15311
+ db.simulation_switch.insert(simulationSwitch);
15312
+ }
15269
15313
  };
15270
15314
 
15271
15315
  // lib/components/normal-components/TestPoint.ts
@@ -15920,7 +15964,7 @@ import { identity as identity6 } from "transformation-matrix";
15920
15964
  var package_default = {
15921
15965
  name: "@tscircuit/core",
15922
15966
  type: "module",
15923
- version: "0.0.760",
15967
+ version: "0.0.761",
15924
15968
  types: "dist/index.d.ts",
15925
15969
  main: "dist/index.js",
15926
15970
  module: "dist/index.js",
@@ -15959,7 +16003,7 @@ var package_default = {
15959
16003
  "@tscircuit/matchpack": "^0.0.16",
15960
16004
  "@tscircuit/math-utils": "^0.0.21",
15961
16005
  "@tscircuit/miniflex": "^0.0.4",
15962
- "@tscircuit/props": "0.0.343",
16006
+ "@tscircuit/props": "0.0.346",
15963
16007
  "@tscircuit/schematic-autolayout": "^0.0.6",
15964
16008
  "@tscircuit/schematic-match-adapt": "^0.0.16",
15965
16009
  "@tscircuit/schematic-trace-solver": "^0.0.40",
@@ -15972,7 +16016,7 @@ var package_default = {
15972
16016
  "bun-match-svg": "0.0.12",
15973
16017
  "calculate-elbow": "^0.0.12",
15974
16018
  "chokidar-cli": "^3.0.0",
15975
- "circuit-json": "^0.0.267",
16019
+ "circuit-json": "^0.0.268",
15976
16020
  "circuit-json-to-bpc": "^0.0.13",
15977
16021
  "circuit-json-to-connectivity-map": "^0.0.22",
15978
16022
  "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.762",
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.346",
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",