@tscircuit/core 0.0.740 → 0.0.741

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, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, 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, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, 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';
@@ -32389,6 +32389,107 @@ declare class SchematicRect extends PrimitiveComponent<typeof schematicRectProps
32389
32389
  doInitialSchematicPrimitiveRender(): void;
32390
32390
  }
32391
32391
 
32392
+ declare class SchematicArc extends PrimitiveComponent<typeof schematicArcProps> {
32393
+ isSchematicPrimitive: boolean;
32394
+ get config(): {
32395
+ componentName: string;
32396
+ zodProps: zod.ZodObject<{
32397
+ center: zod.ZodObject<{
32398
+ x: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32399
+ y: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32400
+ }, "strip", zod.ZodTypeAny, {
32401
+ x: number;
32402
+ y: number;
32403
+ }, {
32404
+ x: string | number;
32405
+ y: string | number;
32406
+ }>;
32407
+ radius: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32408
+ startAngleDegrees: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32409
+ endAngleDegrees: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32410
+ direction: zod.ZodDefault<zod.ZodEnum<["clockwise", "counterclockwise"]>>;
32411
+ strokeWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
32412
+ color: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
32413
+ isDashed: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
32414
+ }, "strip", zod.ZodTypeAny, {
32415
+ direction: "clockwise" | "counterclockwise";
32416
+ center: {
32417
+ x: number;
32418
+ y: number;
32419
+ };
32420
+ color: string;
32421
+ radius: number;
32422
+ startAngleDegrees: number;
32423
+ endAngleDegrees: number;
32424
+ isDashed: boolean;
32425
+ strokeWidth?: number | undefined;
32426
+ }, {
32427
+ center: {
32428
+ x: string | number;
32429
+ y: string | number;
32430
+ };
32431
+ radius: string | number;
32432
+ startAngleDegrees: string | number;
32433
+ endAngleDegrees: string | number;
32434
+ direction?: "clockwise" | "counterclockwise" | undefined;
32435
+ strokeWidth?: string | number | undefined;
32436
+ color?: string | undefined;
32437
+ isDashed?: boolean | undefined;
32438
+ }>;
32439
+ };
32440
+ schematic_arc_id?: string;
32441
+ doInitialSchematicPrimitiveRender(): void;
32442
+ }
32443
+
32444
+ declare class SchematicCircle extends PrimitiveComponent<typeof schematicCircleProps> {
32445
+ isSchematicPrimitive: boolean;
32446
+ get config(): {
32447
+ componentName: string;
32448
+ zodProps: zod.ZodObject<{
32449
+ center: zod.ZodObject<{
32450
+ x: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32451
+ y: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32452
+ }, "strip", zod.ZodTypeAny, {
32453
+ x: number;
32454
+ y: number;
32455
+ }, {
32456
+ x: string | number;
32457
+ y: string | number;
32458
+ }>;
32459
+ radius: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
32460
+ strokeWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
32461
+ color: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
32462
+ isFilled: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
32463
+ fillColor: zod.ZodOptional<zod.ZodString>;
32464
+ isDashed: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
32465
+ }, "strip", zod.ZodTypeAny, {
32466
+ center: {
32467
+ x: number;
32468
+ y: number;
32469
+ };
32470
+ color: string;
32471
+ radius: number;
32472
+ isDashed: boolean;
32473
+ isFilled: boolean;
32474
+ strokeWidth?: number | undefined;
32475
+ fillColor?: string | undefined;
32476
+ }, {
32477
+ center: {
32478
+ x: string | number;
32479
+ y: string | number;
32480
+ };
32481
+ radius: string | number;
32482
+ strokeWidth?: string | number | undefined;
32483
+ color?: string | undefined;
32484
+ isDashed?: boolean | undefined;
32485
+ isFilled?: boolean | undefined;
32486
+ fillColor?: string | undefined;
32487
+ }>;
32488
+ };
32489
+ schematic_circle_id?: string;
32490
+ doInitialSchematicPrimitiveRender(): void;
32491
+ }
32492
+
32392
32493
  declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps> {
32393
32494
  isSchematicPrimitive: boolean;
32394
32495
  get config(): {
@@ -33194,6 +33295,8 @@ interface TscircuitElements {
33194
33295
  schematicbox: _tscircuit_props.SchematicBoxProps;
33195
33296
  schematicline: _tscircuit_props.SchematicLineProps;
33196
33297
  schematicrect: _tscircuit_props.SchematicRectProps;
33298
+ schematicarc: _tscircuit_props.SchematicArcProps;
33299
+ schematiccircle: _tscircuit_props.SchematicCircleProps;
33197
33300
  schematicpath: _tscircuit_props.SchematicPathProps;
33198
33301
  schematictext: _tscircuit_props.SchematicTextProps;
33199
33302
  schematictable: _tscircuit_props.SchematicTableProps;
@@ -33254,4 +33357,4 @@ declare module "react/jsx-runtime" {
33254
33357
  }
33255
33358
  }
33256
33359
 
33257
- export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, CopperPour, Crystal, Cutout, type DebugLogOutputEvent, Diode, FabricationNotePath, FabricationNoteText, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, Net, NetLabel, NormalComponent, type Obstacle, PcbTrace, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SchematicBox, SchematicCell, SchematicLine, SchematicRect, SchematicRow, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, Subcircuit, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
33360
+ export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, CopperPour, Crystal, Cutout, type DebugLogOutputEvent, Diode, FabricationNotePath, FabricationNoteText, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, Net, NetLabel, NormalComponent, type Obstacle, PcbTrace, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SchematicArc, SchematicBox, SchematicCell, SchematicCircle, SchematicLine, SchematicRect, SchematicRow, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, Subcircuit, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -46,8 +46,10 @@ __export(components_exports, {
46
46
  Renderable: () => Renderable,
47
47
  Resistor: () => Resistor,
48
48
  Resonator: () => Resonator,
49
+ SchematicArc: () => SchematicArc,
49
50
  SchematicBox: () => SchematicBox,
50
51
  SchematicCell: () => SchematicCell,
52
+ SchematicCircle: () => SchematicCircle,
51
53
  SchematicLine: () => SchematicLine,
52
54
  SchematicRect: () => SchematicRect,
53
55
  SchematicRow: () => SchematicRow,
@@ -3085,6 +3087,58 @@ function getBoundsOfPcbComponents(components) {
3085
3087
  }
3086
3088
 
3087
3089
  // lib/utils/autorouting/getBoundsForSchematic.ts
3090
+ function normalizeAngle(angle) {
3091
+ const normalized = angle % 360;
3092
+ return normalized < 0 ? normalized + 360 : normalized;
3093
+ }
3094
+ function isAngleBetween(angle, start, end, direction) {
3095
+ if (direction === "counterclockwise") {
3096
+ if (end >= start) {
3097
+ return angle >= start && angle <= end;
3098
+ }
3099
+ return angle >= start || angle <= end;
3100
+ }
3101
+ if (end <= start) {
3102
+ return angle <= start && angle >= end;
3103
+ }
3104
+ return angle <= start || angle >= end;
3105
+ }
3106
+ function getArcBounds(elm) {
3107
+ const center = elm.center;
3108
+ const radius = elm.radius;
3109
+ const startAngle = elm.start_angle_degrees;
3110
+ const endAngle = elm.end_angle_degrees;
3111
+ const direction = elm.direction ?? "counterclockwise";
3112
+ if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof radius !== "number" || typeof startAngle !== "number" || typeof endAngle !== "number") {
3113
+ return null;
3114
+ }
3115
+ const start = normalizeAngle(startAngle);
3116
+ const end = normalizeAngle(endAngle);
3117
+ const consideredAngles = /* @__PURE__ */ new Set([start, end]);
3118
+ const cardinalAngles = [0, 90, 180, 270];
3119
+ for (const cardinal of cardinalAngles) {
3120
+ if (isAngleBetween(cardinal, start, end, direction)) {
3121
+ consideredAngles.add(cardinal);
3122
+ }
3123
+ }
3124
+ let minX = Infinity;
3125
+ let minY = Infinity;
3126
+ let maxX = -Infinity;
3127
+ let maxY = -Infinity;
3128
+ for (const angle of consideredAngles) {
3129
+ const radians = angle * Math.PI / 180;
3130
+ const x = center.x + radius * Math.cos(radians);
3131
+ const y = center.y + radius * Math.sin(radians);
3132
+ minX = Math.min(minX, x);
3133
+ maxX = Math.max(maxX, x);
3134
+ minY = Math.min(minY, y);
3135
+ maxY = Math.max(maxY, y);
3136
+ }
3137
+ if (!Number.isFinite(minX) || !Number.isFinite(minY)) {
3138
+ return null;
3139
+ }
3140
+ return { minX, maxX, minY, maxY };
3141
+ }
3088
3142
  function getBoundsForSchematic(db) {
3089
3143
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
3090
3144
  for (const elm of db) {
@@ -3123,6 +3177,23 @@ function getBoundsForSchematic(db) {
3123
3177
  cy = elm.center?.y;
3124
3178
  w = elm.width;
3125
3179
  h = elm.height;
3180
+ } else if (elm.type === "schematic_circle") {
3181
+ cx = elm.center?.x;
3182
+ cy = elm.center?.y;
3183
+ const radius = elm.radius;
3184
+ if (typeof radius === "number") {
3185
+ w = radius * 2;
3186
+ h = radius * 2;
3187
+ }
3188
+ } else if (elm.type === "schematic_arc") {
3189
+ const bounds = getArcBounds(elm);
3190
+ if (bounds) {
3191
+ minX = Math.min(minX, bounds.minX);
3192
+ maxX = Math.max(maxX, bounds.maxX);
3193
+ minY = Math.min(minY, bounds.minY);
3194
+ maxY = Math.max(maxY, bounds.maxY);
3195
+ }
3196
+ continue;
3126
3197
  }
3127
3198
  if (typeof cx === "number" && typeof cy === "number" && typeof w === "number" && typeof h === "number") {
3128
3199
  minX = Math.min(minX, cx - w / 2);
@@ -7643,6 +7714,16 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
7643
7714
  const rect = db.schematic_rect.get(child.schematic_rect_id);
7644
7715
  if (rect) schematicElements.push(rect);
7645
7716
  }
7717
+ if (child.isSchematicPrimitive && child.componentName === "SchematicCircle") {
7718
+ const circle = db.schematic_circle.get(
7719
+ child.schematic_circle_id
7720
+ );
7721
+ if (circle) schematicElements.push(circle);
7722
+ }
7723
+ if (child.isSchematicPrimitive && child.componentName === "SchematicArc") {
7724
+ const arc = db.schematic_arc.get(child.schematic_arc_id);
7725
+ if (arc) schematicElements.push(arc);
7726
+ }
7646
7727
  if (child.isSchematicPrimitive && child.componentName === "SchematicText") {
7647
7728
  const text = db.schematic_text.get(child.schematic_text_id);
7648
7729
  if (text) schematicElements.push(text);
@@ -15168,6 +15249,77 @@ var SchematicRect = class extends PrimitiveComponent2 {
15168
15249
  }
15169
15250
  };
15170
15251
 
15252
+ // lib/components/primitive-components/SchematicArc.ts
15253
+ import { schematicArcProps } from "@tscircuit/props";
15254
+ var SchematicArc = class extends PrimitiveComponent2 {
15255
+ isSchematicPrimitive = true;
15256
+ get config() {
15257
+ return {
15258
+ componentName: "SchematicArc",
15259
+ zodProps: schematicArcProps
15260
+ };
15261
+ }
15262
+ schematic_arc_id;
15263
+ doInitialSchematicPrimitiveRender() {
15264
+ if (this.root?.schematicDisabled) return;
15265
+ const { db } = this.root;
15266
+ const { _parsedProps: props } = this;
15267
+ const globalPos = this._getGlobalSchematicPositionBeforeLayout();
15268
+ const schematic_component_id = this.getPrimitiveContainer()?.parent?.schematic_component_id;
15269
+ const schematic_arc = db.schematic_arc.insert({
15270
+ schematic_component_id,
15271
+ center: {
15272
+ x: props.center.x + globalPos.x,
15273
+ y: props.center.y + globalPos.y
15274
+ },
15275
+ radius: props.radius,
15276
+ start_angle_degrees: props.startAngleDegrees,
15277
+ end_angle_degrees: props.endAngleDegrees,
15278
+ direction: props.direction,
15279
+ stroke_width: SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,
15280
+ color: SCHEMATIC_COMPONENT_OUTLINE_COLOR,
15281
+ is_dashed: props.isDashed,
15282
+ subcircuit_id: this.getSubcircuit().subcircuit_id ?? void 0
15283
+ });
15284
+ this.schematic_arc_id = schematic_arc.schematic_arc_id;
15285
+ }
15286
+ };
15287
+
15288
+ // lib/components/primitive-components/SchematicCircle.ts
15289
+ import { schematicCircleProps } from "@tscircuit/props";
15290
+ var SchematicCircle = class extends PrimitiveComponent2 {
15291
+ isSchematicPrimitive = true;
15292
+ get config() {
15293
+ return {
15294
+ componentName: "SchematicCircle",
15295
+ zodProps: schematicCircleProps
15296
+ };
15297
+ }
15298
+ schematic_circle_id;
15299
+ doInitialSchematicPrimitiveRender() {
15300
+ if (this.root?.schematicDisabled) return;
15301
+ const { db } = this.root;
15302
+ const { _parsedProps: props } = this;
15303
+ const globalPos = this._getGlobalSchematicPositionBeforeLayout();
15304
+ const schematic_component_id = this.getPrimitiveContainer()?.parent?.schematic_component_id;
15305
+ const schematic_circle = db.schematic_circle.insert({
15306
+ schematic_component_id,
15307
+ center: {
15308
+ x: props.center.x + globalPos.x,
15309
+ y: props.center.y + globalPos.y
15310
+ },
15311
+ radius: props.radius,
15312
+ stroke_width: SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH,
15313
+ color: SCHEMATIC_COMPONENT_OUTLINE_COLOR,
15314
+ is_filled: props.isFilled,
15315
+ fill_color: props.fillColor,
15316
+ is_dashed: props.isDashed,
15317
+ subcircuit_id: this.getSubcircuit().subcircuit_id ?? void 0
15318
+ });
15319
+ this.schematic_circle_id = schematic_circle.schematic_circle_id;
15320
+ }
15321
+ };
15322
+
15171
15323
  // lib/components/primitive-components/SchematicBox.ts
15172
15324
  import { schematicBoxProps } from "@tscircuit/props";
15173
15325
 
@@ -15539,7 +15691,7 @@ import { identity as identity6 } from "transformation-matrix";
15539
15691
  var package_default = {
15540
15692
  name: "@tscircuit/core",
15541
15693
  type: "module",
15542
- version: "0.0.739",
15694
+ version: "0.0.740",
15543
15695
  types: "dist/index.d.ts",
15544
15696
  main: "dist/index.js",
15545
15697
  module: "dist/index.js",
@@ -16084,8 +16236,10 @@ export {
16084
16236
  Resistor,
16085
16237
  Resonator,
16086
16238
  RootCircuit,
16239
+ SchematicArc,
16087
16240
  SchematicBox,
16088
16241
  SchematicCell,
16242
+ SchematicCircle,
16089
16243
  SchematicLine,
16090
16244
  SchematicRect,
16091
16245
  SchematicRow,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.740",
4
+ "version": "0.0.741",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",