@tscircuit/core 0.0.690 → 0.0.691

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
@@ -1047,7 +1047,6 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1047
1047
  ignoreSymbolPorts?: boolean;
1048
1048
  }): void;
1049
1049
  _getImpliedFootprintString(): string | null;
1050
- _isFootprintUrl(s: string): boolean;
1051
1050
  _addChildrenFromStringFootprint(): void;
1052
1051
  get portMap(): PortMap<PortNames>;
1053
1052
  getInstanceForReactElement(element: ReactElement): NormalComponent | null;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ __export(components_exports, {
30
30
  Mosfet: () => Mosfet,
31
31
  Net: () => Net,
32
32
  NetLabel: () => NetLabel,
33
- NormalComponent: () => NormalComponent,
33
+ NormalComponent: () => NormalComponent2,
34
34
  PcbTrace: () => PcbTrace,
35
35
  PinHeader: () => PinHeader,
36
36
  Pinout: () => Pinout,
@@ -3697,7 +3697,7 @@ var getAllDimensionsForSchematicBox = (params) => {
3697
3697
 
3698
3698
  // lib/components/base-components/NormalComponent/NormalComponent.ts
3699
3699
  import {
3700
- isValidElement as isReactElement,
3700
+ isValidElement as isReactElement2,
3701
3701
  isValidElement
3702
3702
  } from "react";
3703
3703
  import { symbols as symbols2 } from "schematic-symbols";
@@ -6455,6 +6455,94 @@ function isValidPinLabel(pin, label) {
6455
6455
  }
6456
6456
  }
6457
6457
 
6458
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
6459
+ import { isValidElement as isReactElement } from "react";
6460
+
6461
+ // lib/components/base-components/NormalComponent/utils/isFoorprintUrl.ts
6462
+ var isFootprintUrl = (s) => s.startsWith("http://") || s.startsWith("https://");
6463
+
6464
+ // lib/components/base-components/NormalComponent/utils/parseLibraryFootprintRef.ts
6465
+ var parseLibraryFootprintRef = (s) => {
6466
+ if (isFootprintUrl(s)) return null;
6467
+ const idx = s.indexOf(":");
6468
+ if (idx <= 0) return null;
6469
+ const footprintLib = s.slice(0, idx);
6470
+ const footprintName = s.slice(idx + 1);
6471
+ if (!footprintLib || !footprintName) return null;
6472
+ return { footprintLib, footprintName };
6473
+ };
6474
+
6475
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
6476
+ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
6477
+ let { footprint } = component.props;
6478
+ footprint ??= component._getImpliedFootprintString?.();
6479
+ if (!footprint) return;
6480
+ const { pcbRotation, pinLabels, pcbPinLabels } = component.props;
6481
+ if (typeof footprint === "string" && isFootprintUrl(footprint)) {
6482
+ if (component._hasStartedFootprintUrlLoad) return;
6483
+ component._hasStartedFootprintUrlLoad = true;
6484
+ const url = footprint;
6485
+ queueAsyncEffect("load-footprint-url", async () => {
6486
+ const res = await fetch(url);
6487
+ const soup = await res.json();
6488
+ const fpComponents = createComponentsFromCircuitJson(
6489
+ {
6490
+ componentName: component.name,
6491
+ componentRotation: pcbRotation,
6492
+ footprint: url,
6493
+ pinLabels,
6494
+ pcbPinLabels
6495
+ },
6496
+ soup
6497
+ );
6498
+ component.addAll(fpComponents);
6499
+ component._markDirty("InitializePortsFromChildren");
6500
+ });
6501
+ return;
6502
+ }
6503
+ if (typeof footprint === "string") {
6504
+ const libRef = parseLibraryFootprintRef(footprint);
6505
+ if (!libRef) return;
6506
+ if (component._hasStartedFootprintUrlLoad) return;
6507
+ component._hasStartedFootprintUrlLoad = true;
6508
+ const platform = component.root?.platform;
6509
+ const libMap = platform?.footprintLibraryMap?.[libRef.footprintLib];
6510
+ let resolverFn;
6511
+ if (typeof libMap === "function") {
6512
+ resolverFn = libMap;
6513
+ }
6514
+ if (!resolverFn) return;
6515
+ queueAsyncEffect("load-lib-footprint", async () => {
6516
+ const result = await resolverFn(libRef.footprintName);
6517
+ const circuitJson = Array.isArray(result) ? result : Array.isArray(result?.footprintCircuitJson) ? result.footprintCircuitJson : null;
6518
+ if (!circuitJson) return;
6519
+ const fpComponents = createComponentsFromCircuitJson(
6520
+ {
6521
+ componentName: component.name,
6522
+ componentRotation: pcbRotation,
6523
+ footprint,
6524
+ pinLabels,
6525
+ pcbPinLabels
6526
+ },
6527
+ circuitJson
6528
+ );
6529
+ component.addAll(fpComponents);
6530
+ component._markDirty("InitializePortsFromChildren");
6531
+ });
6532
+ return;
6533
+ }
6534
+ if (isReactElement(footprint)) {
6535
+ if (component.reactSubtrees.some((rs) => rs.element === footprint)) return;
6536
+ const subtree = component._renderReactSubtree(footprint);
6537
+ component.reactSubtrees.push(subtree);
6538
+ component.add(subtree.component);
6539
+ return;
6540
+ }
6541
+ if (!isReactElement(footprint) && footprint.componentName === "Footprint") {
6542
+ component.add(footprint);
6543
+ }
6544
+ }
6545
+
6458
6546
  // lib/components/base-components/NormalComponent/NormalComponent.ts
6459
6547
  var debug3 = Debug4("tscircuit:core");
6460
6548
  var rotation3 = z8.object({
@@ -6462,7 +6550,7 @@ var rotation3 = z8.object({
6462
6550
  y: rotation,
6463
6551
  z: rotation
6464
6552
  });
6465
- var NormalComponent = class extends PrimitiveComponent2 {
6553
+ var NormalComponent2 = class extends PrimitiveComponent2 {
6466
6554
  reactSubtrees = [];
6467
6555
  _impliedFootprint;
6468
6556
  isPrimitiveContainer = true;
@@ -6718,16 +6806,14 @@ var NormalComponent = class extends PrimitiveComponent2 {
6718
6806
  _getImpliedFootprintString() {
6719
6807
  return null;
6720
6808
  }
6721
- _isFootprintUrl(s) {
6722
- return s.startsWith("http://") || s.startsWith("https://");
6723
- }
6724
6809
  _addChildrenFromStringFootprint() {
6725
6810
  const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
6726
6811
  let { footprint } = this.props;
6727
6812
  footprint ??= this._getImpliedFootprintString?.();
6728
6813
  if (!footprint) return;
6729
6814
  if (typeof footprint === "string") {
6730
- if (this._isFootprintUrl(footprint)) return;
6815
+ if (isFootprintUrl(footprint)) return;
6816
+ if (parseLibraryFootprintRef(footprint)) return;
6731
6817
  const fpSoup = fp.string(footprint).soup();
6732
6818
  const fpComponents = createComponentsFromCircuitJson(
6733
6819
  {
@@ -6997,42 +7083,10 @@ var NormalComponent = class extends PrimitiveComponent2 {
6997
7083
  doInitialReactSubtreesRender() {
6998
7084
  }
6999
7085
  doInitialPcbFootprintStringRender() {
7000
- let { footprint } = this.props;
7001
- footprint ??= this._getImpliedFootprintString?.();
7002
- if (!footprint) return;
7003
- const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
7004
- if (typeof footprint === "string" && this._isFootprintUrl(footprint)) {
7005
- if (this._hasStartedFootprintUrlLoad) return;
7006
- this._hasStartedFootprintUrlLoad = true;
7007
- const url = footprint;
7008
- this._queueAsyncEffect("load-footprint-url", async () => {
7009
- const res = await fetch(url);
7010
- const soup = await res.json();
7011
- const fpComponents = createComponentsFromCircuitJson(
7012
- {
7013
- componentName: this.name,
7014
- componentRotation: pcbRotation,
7015
- footprint: url,
7016
- pinLabels,
7017
- pcbPinLabels
7018
- },
7019
- soup
7020
- );
7021
- this.addAll(fpComponents);
7022
- this._markDirty("InitializePortsFromChildren");
7023
- });
7024
- return;
7025
- }
7026
- if (isReactElement(footprint)) {
7027
- if (this.reactSubtrees.some((rs) => rs.element === footprint)) return;
7028
- const subtree = this._renderReactSubtree(footprint);
7029
- this.reactSubtrees.push(subtree);
7030
- this.add(subtree.component);
7031
- return;
7032
- }
7033
- if (!isValidElement(footprint) && footprint.componentName === "Footprint") {
7034
- this.add(footprint);
7035
- }
7086
+ NormalComponent_doInitialPcbFootprintStringRender(
7087
+ this,
7088
+ (name, effect) => this._queueAsyncEffect(name, effect)
7089
+ );
7036
7090
  }
7037
7091
  _hasExistingPortExactly(port1) {
7038
7092
  const existingPorts = this.children.filter(
@@ -7046,7 +7100,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
7046
7100
  }
7047
7101
  add(componentOrElm) {
7048
7102
  let component;
7049
- if (isReactElement(componentOrElm)) {
7103
+ if (isReactElement2(componentOrElm)) {
7050
7104
  const subtree = this._renderReactSubtree(componentOrElm);
7051
7105
  this.reactSubtrees.push(subtree);
7052
7106
  component = subtree.component;
@@ -7075,7 +7129,8 @@ var NormalComponent = class extends PrimitiveComponent2 {
7075
7129
  footprint = this.children.find((c) => c.componentName === "Footprint");
7076
7130
  }
7077
7131
  if (typeof footprint === "string") {
7078
- if (this._isFootprintUrl(footprint)) return [];
7132
+ if (isFootprintUrl(footprint)) return [];
7133
+ if (parseLibraryFootprintRef(footprint)) return [];
7079
7134
  const fpSoup = fp.string(footprint).soup();
7080
7135
  const newPorts2 = [];
7081
7136
  for (const elm of fpSoup) {
@@ -10678,7 +10733,7 @@ var Group_doInitialSchematicTraceRender = (group) => {
10678
10733
  };
10679
10734
 
10680
10735
  // lib/components/primitive-components/Group/Group.ts
10681
- var Group6 = class extends NormalComponent {
10736
+ var Group6 = class extends NormalComponent2 {
10682
10737
  pcb_group_id = null;
10683
10738
  schematic_group_id = null;
10684
10739
  subcircuit_id = null;
@@ -11651,7 +11706,7 @@ var FTYPE = stringProxy;
11651
11706
 
11652
11707
  // lib/components/normal-components/Capacitor.ts
11653
11708
  import { formatSiUnit } from "format-si-unit";
11654
- var Capacitor = class extends NormalComponent {
11709
+ var Capacitor = class extends NormalComponent2 {
11655
11710
  _adjustSilkscreenTextAutomatically = true;
11656
11711
  // @ts-ignore (cause the symbolName is string and not fixed)
11657
11712
  get config() {
@@ -11727,7 +11782,7 @@ var Capacitor = class extends NormalComponent {
11727
11782
 
11728
11783
  // lib/components/normal-components/Chip.ts
11729
11784
  import { chipProps as chipProps2 } from "@tscircuit/props";
11730
- var Chip = class extends NormalComponent {
11785
+ var Chip = class extends NormalComponent2 {
11731
11786
  schematicBoxDimensions = null;
11732
11787
  constructor(props) {
11733
11788
  super(props);
@@ -11899,7 +11954,7 @@ var Pinout = class extends Chip {
11899
11954
 
11900
11955
  // lib/components/normal-components/Diode.ts
11901
11956
  import { diodeProps } from "@tscircuit/props";
11902
- var Diode = class extends NormalComponent {
11957
+ var Diode = class extends NormalComponent2 {
11903
11958
  // @ts-ignore
11904
11959
  get config() {
11905
11960
  const symbolMap = {
@@ -11946,7 +12001,7 @@ var Diode = class extends NormalComponent {
11946
12001
  // lib/components/normal-components/Fuse.ts
11947
12002
  import { fuseProps } from "@tscircuit/props";
11948
12003
  import { formatSiUnit as formatSiUnit2 } from "format-si-unit";
11949
- var Fuse = class extends NormalComponent {
12004
+ var Fuse = class extends NormalComponent2 {
11950
12005
  get config() {
11951
12006
  return {
11952
12007
  componentName: "fuse",
@@ -11981,7 +12036,7 @@ var Fuse = class extends NormalComponent {
11981
12036
 
11982
12037
  // lib/components/normal-components/Jumper.ts
11983
12038
  import { jumperProps } from "@tscircuit/props";
11984
- var Jumper = class extends NormalComponent {
12039
+ var Jumper = class extends NormalComponent2 {
11985
12040
  schematicDimensions = null;
11986
12041
  get config() {
11987
12042
  return {
@@ -12080,7 +12135,7 @@ var Jumper = class extends NormalComponent {
12080
12135
 
12081
12136
  // lib/components/normal-components/SolderJumper.ts
12082
12137
  import { solderjumperProps } from "@tscircuit/props";
12083
- var SolderJumper = class extends NormalComponent {
12138
+ var SolderJumper = class extends NormalComponent2 {
12084
12139
  schematicDimensions = null;
12085
12140
  _getPinNumberFromBridgedPinName(pinName) {
12086
12141
  const port = this.selectOne(`port.${pinName}`, {
@@ -12234,7 +12289,7 @@ var SolderJumper = class extends NormalComponent {
12234
12289
 
12235
12290
  // lib/components/normal-components/Led.ts
12236
12291
  import { ledProps } from "@tscircuit/props";
12237
- var Led = class extends NormalComponent {
12292
+ var Led = class extends NormalComponent2 {
12238
12293
  get config() {
12239
12294
  const symbolMap = {
12240
12295
  laser: "laser_diode"
@@ -12282,7 +12337,7 @@ var Led = class extends NormalComponent {
12282
12337
 
12283
12338
  // lib/components/normal-components/PowerSource.ts
12284
12339
  import { powerSourceProps } from "@tscircuit/props";
12285
- var PowerSource = class extends NormalComponent {
12340
+ var PowerSource = class extends NormalComponent2 {
12286
12341
  // @ts-ignore
12287
12342
  get config() {
12288
12343
  return {
@@ -12333,7 +12388,7 @@ var voltageSourceProps = commonComponentProps.extend({
12333
12388
  phase: rotation2.optional(),
12334
12389
  dutyCycle: z12.number().optional()
12335
12390
  });
12336
- var VoltageSource = class extends NormalComponent {
12391
+ var VoltageSource = class extends NormalComponent2 {
12337
12392
  get config() {
12338
12393
  const isSquare = this.props.waveShape === "square";
12339
12394
  return {
@@ -12404,7 +12459,7 @@ var VoltageSource = class extends NormalComponent {
12404
12459
  // lib/components/normal-components/Resistor.ts
12405
12460
  import { resistorProps } from "@tscircuit/props";
12406
12461
  import { formatSiUnit as formatSiUnit3 } from "format-si-unit";
12407
- var Resistor = class extends NormalComponent {
12462
+ var Resistor = class extends NormalComponent2 {
12408
12463
  _adjustSilkscreenTextAutomatically = true;
12409
12464
  get config() {
12410
12465
  return {
@@ -13145,7 +13200,7 @@ var Via = class extends PrimitiveComponent2 {
13145
13200
 
13146
13201
  // lib/components/normal-components/Battery.ts
13147
13202
  import { batteryProps } from "@tscircuit/props";
13148
- var Battery = class extends NormalComponent {
13203
+ var Battery = class extends NormalComponent2 {
13149
13204
  get config() {
13150
13205
  return {
13151
13206
  componentName: "Battery",
@@ -13178,7 +13233,7 @@ var Battery = class extends NormalComponent {
13178
13233
 
13179
13234
  // lib/components/normal-components/PinHeader.ts
13180
13235
  import { pinHeaderProps } from "@tscircuit/props";
13181
- var PinHeader = class extends NormalComponent {
13236
+ var PinHeader = class extends NormalComponent2 {
13182
13237
  get config() {
13183
13238
  return {
13184
13239
  componentName: "PinHeader",
@@ -13287,7 +13342,7 @@ function getResonatorSymbolName(variant) {
13287
13342
  return "crystal";
13288
13343
  }
13289
13344
  }
13290
- var Resonator = class extends NormalComponent {
13345
+ var Resonator = class extends NormalComponent2 {
13291
13346
  get config() {
13292
13347
  return {
13293
13348
  componentName: "Resonator",
@@ -13323,7 +13378,7 @@ var Resonator = class extends NormalComponent {
13323
13378
  // lib/components/normal-components/Inductor.ts
13324
13379
  import { inductorProps } from "@tscircuit/props";
13325
13380
  import { formatSiUnit as formatSiUnit5 } from "format-si-unit";
13326
- var Inductor = class extends NormalComponent {
13381
+ var Inductor = class extends NormalComponent2 {
13327
13382
  _adjustSilkscreenTextAutomatically = true;
13328
13383
  get config() {
13329
13384
  return {
@@ -13371,7 +13426,7 @@ function getPotentiometerSymbolName(variant) {
13371
13426
  return "potentiometer2";
13372
13427
  }
13373
13428
  }
13374
- var Potentiometer = class extends NormalComponent {
13429
+ var Potentiometer = class extends NormalComponent2 {
13375
13430
  get config() {
13376
13431
  return {
13377
13432
  componentName: "Potentiometer",
@@ -13401,7 +13456,7 @@ var Potentiometer = class extends NormalComponent {
13401
13456
  // lib/components/normal-components/PushButton.ts
13402
13457
  import { pushButtonProps } from "@tscircuit/props";
13403
13458
  import { symbols as symbols3 } from "schematic-symbols";
13404
- var PushButton = class extends NormalComponent {
13459
+ var PushButton = class extends NormalComponent2 {
13405
13460
  get config() {
13406
13461
  return {
13407
13462
  componentName: "PushButton",
@@ -13466,7 +13521,7 @@ var PushButton = class extends NormalComponent {
13466
13521
  // lib/components/normal-components/Crystal.ts
13467
13522
  import { crystalProps } from "@tscircuit/props";
13468
13523
  import { formatSiUnit as formatSiUnit7 } from "format-si-unit";
13469
- var Crystal = class extends NormalComponent {
13524
+ var Crystal = class extends NormalComponent2 {
13470
13525
  // @ts-ignore
13471
13526
  get config() {
13472
13527
  const symbolName = this.props.symbolName ?? (this.props.pinVariant === "four_pin" ? "crystal_4pin" : "crystal");
@@ -13517,7 +13572,7 @@ var Crystal = class extends NormalComponent {
13517
13572
 
13518
13573
  // lib/components/normal-components/Transistor.ts
13519
13574
  import { transistorProps } from "@tscircuit/props";
13520
- var Transistor = class extends NormalComponent {
13575
+ var Transistor = class extends NormalComponent2 {
13521
13576
  get config() {
13522
13577
  const baseSymbolName = this.props.type === "npn" ? "npn_bipolar_transistor" : "pnp_bipolar_transistor";
13523
13578
  return {
@@ -13562,7 +13617,7 @@ var Transistor = class extends NormalComponent {
13562
13617
 
13563
13618
  // lib/components/normal-components/Mosfet.ts
13564
13619
  import { mosfetProps } from "@tscircuit/props";
13565
- var Mosfet = class extends NormalComponent {
13620
+ var Mosfet = class extends NormalComponent2 {
13566
13621
  get config() {
13567
13622
  const mosfetMode = this.props.mosfetMode === "depletion" ? "d" : "e";
13568
13623
  const channelType = this.props.channelType;
@@ -13589,7 +13644,7 @@ var Mosfet = class extends NormalComponent {
13589
13644
 
13590
13645
  // lib/components/normal-components/Switch.ts
13591
13646
  import { switchProps } from "@tscircuit/props";
13592
- var Switch = class extends NormalComponent {
13647
+ var Switch = class extends NormalComponent2 {
13593
13648
  _getSwitchType() {
13594
13649
  const { spst, spdt, dpst, dpdt, type } = this._parsedProps ?? {};
13595
13650
  if (dpdt) return "dpdt";
@@ -13636,7 +13691,7 @@ var TESTPOINT_DEFAULTS = {
13636
13691
  SMT_CIRCLE_DIAMETER: 1.2,
13637
13692
  SMT_RECT_SIZE: 2
13638
13693
  };
13639
- var TestPoint = class extends NormalComponent {
13694
+ var TestPoint = class extends NormalComponent2 {
13640
13695
  get config() {
13641
13696
  return {
13642
13697
  componentName: "TestPoint",
@@ -14117,7 +14172,7 @@ import { identity as identity6 } from "transformation-matrix";
14117
14172
  var package_default = {
14118
14173
  name: "@tscircuit/core",
14119
14174
  type: "module",
14120
- version: "0.0.689",
14175
+ version: "0.0.690",
14121
14176
  types: "dist/index.d.ts",
14122
14177
  main: "dist/index.js",
14123
14178
  module: "dist/index.js",
@@ -14156,7 +14211,7 @@ var package_default = {
14156
14211
  "@tscircuit/matchpack": "^0.0.16",
14157
14212
  "@tscircuit/math-utils": "^0.0.18",
14158
14213
  "@tscircuit/miniflex": "^0.0.4",
14159
- "@tscircuit/props": "0.0.297",
14214
+ "@tscircuit/props": "0.0.298",
14160
14215
  "@tscircuit/schematic-autolayout": "^0.0.6",
14161
14216
  "@tscircuit/schematic-match-adapt": "^0.0.16",
14162
14217
  "@tscircuit/schematic-trace-solver": "^0.0.25",
@@ -14635,7 +14690,7 @@ export {
14635
14690
  Mosfet,
14636
14691
  Net,
14637
14692
  NetLabel,
14638
- NormalComponent,
14693
+ NormalComponent2 as NormalComponent,
14639
14694
  PcbTrace,
14640
14695
  PinHeader,
14641
14696
  Pinout,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.690",
4
+ "version": "0.0.691",
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.18",
42
42
  "@tscircuit/miniflex": "^0.0.4",
43
- "@tscircuit/props": "0.0.297",
43
+ "@tscircuit/props": "0.0.298",
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.25",