@tscircuit/core 0.0.833 → 0.0.835

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
@@ -13,7 +13,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
13
13
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
14
14
  import { GraphicsObject } from 'graphics-debug';
15
15
 
16
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
16
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
17
17
  type RenderPhase = (typeof orderedRenderPhases)[number];
18
18
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
19
19
  type RenderPhaseStates = Record<RenderPhase, {
@@ -19938,8 +19938,22 @@ declare class Footprint extends PrimitiveComponent<typeof footprintProps> {
19938
19938
  doInitialPcbFootprintLayout(): void;
19939
19939
  }
19940
19940
 
19941
- declare class Subcircuit extends Group {
19941
+ declare class Subcircuit extends Group<typeof subcircuitProps> {
19942
19942
  constructor(props: z.input<typeof subcircuitProps>);
19943
+ /**
19944
+ * During this phase, we inflate the subcircuit circuit json into class
19945
+ * instances
19946
+ *
19947
+ * When subcircuit's define circuitJson, it's basically the same as having
19948
+ * a tree of components. All the data from circuit json has to be converted
19949
+ * into props for the tree of components
19950
+ *
19951
+ * We do this in two phases:
19952
+ * - Create the components
19953
+ * - Create the groups
19954
+ * - Add components to groups in the appropriate hierarchy
19955
+ */
19956
+ doInitialInflateSubcircuitCircuitJson(): void;
19943
19957
  }
19944
19958
 
19945
19959
  declare class Breakout extends Group<typeof breakoutProps> {
package/dist/index.js CHANGED
@@ -107,6 +107,7 @@ import Debug from "debug";
107
107
  var debug = Debug("tscircuit:renderable");
108
108
  var orderedRenderPhases = [
109
109
  "ReactSubtreesRender",
110
+ "InflateSubcircuitCircuitJson",
110
111
  "SourceNameDuplicateComponentRemoval",
111
112
  "PcbFootprintStringRender",
112
113
  "InitializePortsFromChildren",
@@ -15464,15 +15465,73 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15464
15465
  }
15465
15466
  };
15466
15467
 
15467
- // lib/components/primitive-components/Group/Subcircuit.ts
15468
+ // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
15468
15469
  import "@tscircuit/props";
15470
+ import { cju } from "@tscircuit/circuit-json-util";
15471
+
15472
+ // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceResistor.ts
15473
+ function inflateSourceResistor(sourceElm, context) {
15474
+ const { injectionDb, subcircuit } = context;
15475
+ const pcbElm = injectionDb.pcb_component.getWhere({
15476
+ name: sourceElm.name
15477
+ });
15478
+ const cadElm = injectionDb.cad_component.getWhere({
15479
+ name: sourceElm.name
15480
+ });
15481
+ const resistor = new Resistor({
15482
+ name: sourceElm.name,
15483
+ resistance: sourceElm.resistance,
15484
+ footprint: cadElm?.footprinter_string
15485
+ });
15486
+ subcircuit.add(resistor);
15487
+ }
15488
+
15489
+ // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
15469
15490
  var Subcircuit = class extends Group6 {
15470
15491
  constructor(props) {
15471
15492
  super({
15472
15493
  ...props,
15494
+ // @ts-ignore
15473
15495
  subcircuit: true
15474
15496
  });
15475
15497
  }
15498
+ /**
15499
+ * During this phase, we inflate the subcircuit circuit json into class
15500
+ * instances
15501
+ *
15502
+ * When subcircuit's define circuitJson, it's basically the same as having
15503
+ * a tree of components. All the data from circuit json has to be converted
15504
+ * into props for the tree of components
15505
+ *
15506
+ * We do this in two phases:
15507
+ * - Create the components
15508
+ * - Create the groups
15509
+ * - Add components to groups in the appropriate hierarchy
15510
+ */
15511
+ doInitialInflateSubcircuitCircuitJson() {
15512
+ const { circuitJson, children } = this._parsedProps;
15513
+ if (!circuitJson) return;
15514
+ const { db } = this.root;
15515
+ if (circuitJson && children?.length > 0) {
15516
+ throw new Error("Subcircuit cannot have both circuitJson and children");
15517
+ }
15518
+ const sourceComponents = cju(circuitJson).source_component.list();
15519
+ const inflationCtx = {
15520
+ injectionDb: db,
15521
+ subcircuit: this
15522
+ };
15523
+ for (const sourceComponent of sourceComponents) {
15524
+ switch (sourceComponent.ftype) {
15525
+ case "simple_resistor":
15526
+ inflateSourceResistor(sourceComponent, inflationCtx);
15527
+ break;
15528
+ default:
15529
+ throw new Error(
15530
+ `No inflator implemented for source component ftype: "${sourceComponent.ftype}"`
15531
+ );
15532
+ }
15533
+ }
15534
+ }
15476
15535
  };
15477
15536
 
15478
15537
  // lib/components/primitive-components/Breakout/Breakout.ts
@@ -17485,7 +17544,7 @@ import { identity as identity6 } from "transformation-matrix";
17485
17544
  var package_default = {
17486
17545
  name: "@tscircuit/core",
17487
17546
  type: "module",
17488
- version: "0.0.832",
17547
+ version: "0.0.834",
17489
17548
  types: "dist/index.d.ts",
17490
17549
  main: "dist/index.js",
17491
17550
  module: "dist/index.js",
@@ -17510,7 +17569,8 @@ var package_default = {
17510
17569
  "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
17511
17570
  "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
17512
17571
  "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
17513
- "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"'
17572
+ "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',
17573
+ "generate-test-plan": "bun run scripts/generate-test-plan.ts"
17514
17574
  },
17515
17575
  devDependencies: {
17516
17576
  "@biomejs/biome": "^1.8.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.833",
4
+ "version": "0.0.835",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -26,7 +26,8 @@
26
26
  "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
27
27
  "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
28
28
  "build:benchmarking:watch": "chokidar \"./{benchmarking,lib}/**/*.{ts,tsx}\" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'",
29
- "start:benchmarking": "concurrently \"bun run build:benchmarking:watch\" \"live-server ./benchmarking-dist\""
29
+ "start:benchmarking": "concurrently \"bun run build:benchmarking:watch\" \"live-server ./benchmarking-dist\"",
30
+ "generate-test-plan": "bun run scripts/generate-test-plan.ts"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@biomejs/biome": "^1.8.3",