@tscircuit/core 0.0.1476 → 0.0.1477

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
@@ -153330,6 +153330,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153330
153330
  }>;
153331
153331
  shouldRenderAsSchematicBox: boolean;
153332
153332
  };
153333
+ doInitialSchematicComponentRender(): void;
153333
153334
  doInitialSchematicPrimitiveRender(): void;
153334
153335
  }
153335
153336
 
package/dist/index.js CHANGED
@@ -5118,7 +5118,33 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5118
5118
  }
5119
5119
  const { netsWithSelectors } = trace._findConnectedNets();
5120
5120
  if (!allPortsFound) return;
5121
- const portIds = connectedPorts.map((p) => p.port.schematic_port_id).sort();
5121
+ const resolveSchematicPortForSheet = (port) => {
5122
+ if (schematicSheetId && port.source_port_id) {
5123
+ const sheetSchematicPort = db.schematic_port.getWhere({
5124
+ source_port_id: port.source_port_id,
5125
+ schematic_sheet_id: schematicSheetId
5126
+ });
5127
+ if (sheetSchematicPort) return sheetSchematicPort;
5128
+ }
5129
+ if (!port.schematic_port_id) return null;
5130
+ return db.schematic_port.get(port.schematic_port_id) ?? null;
5131
+ };
5132
+ const portsWithPosition = connectedPorts.flatMap(({ port }) => {
5133
+ const schematicPort = resolveSchematicPortForSheet(port);
5134
+ if (!schematicPort) return [];
5135
+ return [
5136
+ {
5137
+ port,
5138
+ position: schematicPort.center,
5139
+ schematic_port_id: schematicPort.schematic_port_id,
5140
+ facingDirection: schematicPort.facing_direction ?? null
5141
+ }
5142
+ ];
5143
+ });
5144
+ const portIds = portsWithPosition.map(({ schematic_port_id }) => schematic_port_id).sort();
5145
+ const hasSheetLocalSchematicPortRepresentation = portsWithPosition.some(
5146
+ ({ port, schematic_port_id }) => port.schematic_port_id !== schematic_port_id
5147
+ );
5122
5148
  const portPairKey = portIds.join(",");
5123
5149
  const board = trace.root?._getBoard();
5124
5150
  if (board?._connectedSchematicPortPairs) {
@@ -5131,12 +5157,6 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5131
5157
  pointsToConnect: []
5132
5158
  };
5133
5159
  const obstacles = getSchematicObstaclesForTrace(trace);
5134
- const portsWithPosition = connectedPorts.filter(({ port }) => port.schematic_port_id !== null).map(({ port }) => ({
5135
- port,
5136
- position: port._getGlobalSchematicPositionAfterLayout(),
5137
- schematic_port_id: port.schematic_port_id ?? void 0,
5138
- facingDirection: port.facingDirection
5139
- }));
5140
5160
  const isPortAndNetConnection = portsWithPosition.length === 1 && netsWithSelectors.length === 1;
5141
5161
  if (isPortAndNetConnection) {
5142
5162
  const net = netsWithSelectors[0].net;
@@ -5221,7 +5241,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5221
5241
  });
5222
5242
  return;
5223
5243
  }
5224
- if (schematicNetLabelText) {
5244
+ if (schematicNetLabelText && !hasSheetLocalSchematicPortRepresentation) {
5225
5245
  if ("from" in trace.props && "to" in trace.props || "path" in trace.props) {
5226
5246
  trace._doInitialSchematicTraceRenderWithDisplayLabel();
5227
5247
  return;
@@ -5355,7 +5375,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5355
5375
  });
5356
5376
  let results = autorouter.solveAndMapToTraces();
5357
5377
  if (results.length === 0) {
5358
- if (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection()) {
5378
+ if (!hasSheetLocalSchematicPortRepresentation && (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection())) {
5359
5379
  trace._doInitialSchematicTraceRenderWithDisplayLabel();
5360
5380
  return;
5361
5381
  }
@@ -5420,7 +5440,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5420
5440
  if (!trace.source_trace_id) {
5421
5441
  throw new Error("Missing source_trace_id for schematic trace insertion.");
5422
5442
  }
5423
- if (trace.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled && countComplexElements(junctions, edges) >= 5 && (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection())) {
5443
+ if (!hasSheetLocalSchematicPortRepresentation && trace.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled && countComplexElements(junctions, edges) >= 5 && (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection())) {
5424
5444
  trace._doInitialSchematicTraceRenderWithDisplayLabel();
5425
5445
  return;
5426
5446
  }
@@ -5432,10 +5452,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5432
5452
  schematic_sheet_id: schematicSheetId
5433
5453
  });
5434
5454
  trace.schematic_trace_id = dbTrace.schematic_trace_id;
5435
- for (const { port } of connectedPorts) {
5436
- if (port.schematic_port_id) {
5437
- db.schematic_port.update(port.schematic_port_id, { is_connected: true });
5438
- }
5455
+ for (const { schematic_port_id } of portsWithPosition) {
5456
+ db.schematic_port.update(schematic_port_id, { is_connected: true });
5439
5457
  }
5440
5458
  if (board?._connectedSchematicPortPairs)
5441
5459
  board._connectedSchematicPortPairs.add(portPairKey);
@@ -20244,9 +20262,9 @@ function applySchematicMatchPackLayoutToTree(group, tree, opts = {}) {
20244
20262
  import {
20245
20263
  getCircuitJsonTree as getCircuitJsonTree2
20246
20264
  } from "@tscircuit/circuit-json-util";
20247
- function getSchematicSheetIdBySourceGroupId({
20265
+ function getSchematicSheetIdsBySourceGroupId({
20248
20266
  circuitJson,
20249
- schematicSheetIdBySourceComponentId
20267
+ schematicSheetIdsBySourceComponentId
20250
20268
  }) {
20251
20269
  const parentBySourceGroupId = /* @__PURE__ */ new Map();
20252
20270
  for (const element of circuitJson) {
@@ -20257,36 +20275,45 @@ function getSchematicSheetIdBySourceGroupId({
20257
20275
  );
20258
20276
  }
20259
20277
  }
20260
- const schematicSheetIdBySourceGroupId = /* @__PURE__ */ new Map();
20278
+ const schematicSheetIdsBySourceGroupId = /* @__PURE__ */ new Map();
20261
20279
  for (const element of circuitJson) {
20262
20280
  if (element.type !== "source_component") continue;
20263
20281
  if (!element.source_group_id) continue;
20264
- const schematicSheetId = schematicSheetIdBySourceComponentId.get(
20282
+ const schematicSheetIds = schematicSheetIdsBySourceComponentId.get(
20265
20283
  element.source_component_id
20266
20284
  );
20267
- if (schematicSheetId === void 0) continue;
20268
- let sourceGroupId = element.source_group_id;
20269
- while (sourceGroupId && !schematicSheetIdBySourceGroupId.has(sourceGroupId)) {
20270
- schematicSheetIdBySourceGroupId.set(sourceGroupId, schematicSheetId);
20271
- sourceGroupId = parentBySourceGroupId.get(sourceGroupId);
20285
+ if (schematicSheetIds === void 0) continue;
20286
+ for (const schematicSheetId of schematicSheetIds) {
20287
+ let sourceGroupId = element.source_group_id;
20288
+ const visitedSourceGroupIds = /* @__PURE__ */ new Set();
20289
+ while (sourceGroupId && !visitedSourceGroupIds.has(sourceGroupId)) {
20290
+ visitedSourceGroupIds.add(sourceGroupId);
20291
+ const groupSchematicSheetIds = schematicSheetIdsBySourceGroupId.get(sourceGroupId) ?? /* @__PURE__ */ new Set();
20292
+ groupSchematicSheetIds.add(schematicSheetId);
20293
+ schematicSheetIdsBySourceGroupId.set(
20294
+ sourceGroupId,
20295
+ groupSchematicSheetIds
20296
+ );
20297
+ sourceGroupId = parentBySourceGroupId.get(sourceGroupId);
20298
+ }
20272
20299
  }
20273
20300
  }
20274
- return schematicSheetIdBySourceGroupId;
20301
+ return schematicSheetIdsBySourceGroupId;
20275
20302
  }
20276
20303
  function getCircuitJsonScopedToSchematicSheet({
20277
20304
  circuitJson,
20278
20305
  schematicSheetId,
20279
20306
  rootSourceGroupId,
20280
- schematicSheetIdBySourceComponentId,
20281
- schematicSheetIdBySourceGroupId
20307
+ schematicSheetIdsBySourceComponentId,
20308
+ schematicSheetIdsBySourceGroupId
20282
20309
  }) {
20283
- const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId || schematicSheetIdBySourceGroupId.get(sourceGroupId) === schematicSheetId;
20310
+ const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId || schematicSheetIdsBySourceGroupId.get(sourceGroupId)?.has(schematicSheetId) === true;
20284
20311
  return circuitJson.filter((element) => {
20285
20312
  if (element.type === "source_group") {
20286
20313
  return isGroupOnSheet(element.source_group_id);
20287
20314
  }
20288
20315
  if (element.type === "source_component") {
20289
- if (schematicSheetIdBySourceComponentId.get(element.source_component_id) !== schematicSheetId) {
20316
+ if (schematicSheetIdsBySourceComponentId.get(element.source_component_id)?.has(schematicSheetId) !== true) {
20290
20317
  return false;
20291
20318
  }
20292
20319
  return element.source_group_id ? isGroupOnSheet(element.source_group_id) : true;
@@ -20296,19 +20323,24 @@ function getCircuitJsonScopedToSchematicSheet({
20296
20323
  }
20297
20324
  function getSchematicCircuitJsonTrees(circuitJson, opts) {
20298
20325
  const { source_group_id } = opts;
20299
- const schematicSheetIdBySourceComponentId = /* @__PURE__ */ new Map();
20326
+ const schematicSheetIdsBySourceComponentId = /* @__PURE__ */ new Map();
20300
20327
  for (const element of circuitJson) {
20301
20328
  if (element.type !== "schematic_component") continue;
20302
20329
  if (!element.source_component_id) continue;
20303
20330
  if (!element.schematic_sheet_id) continue;
20304
- schematicSheetIdBySourceComponentId.set(
20331
+ const schematicSheetIds2 = schematicSheetIdsBySourceComponentId.get(element.source_component_id) ?? /* @__PURE__ */ new Set();
20332
+ schematicSheetIds2.add(element.schematic_sheet_id);
20333
+ schematicSheetIdsBySourceComponentId.set(
20305
20334
  element.source_component_id,
20306
- element.schematic_sheet_id
20335
+ schematicSheetIds2
20307
20336
  );
20308
20337
  }
20309
- const schematicSheetIds = new Set(
20310
- schematicSheetIdBySourceComponentId.values()
20311
- );
20338
+ const schematicSheetIds = /* @__PURE__ */ new Set();
20339
+ for (const componentSchematicSheetIds of schematicSheetIdsBySourceComponentId.values()) {
20340
+ for (const schematicSheetId of componentSchematicSheetIds) {
20341
+ schematicSheetIds.add(schematicSheetId);
20342
+ }
20343
+ }
20312
20344
  if (schematicSheetIds.size <= 1) {
20313
20345
  return [
20314
20346
  {
@@ -20317,9 +20349,9 @@ function getSchematicCircuitJsonTrees(circuitJson, opts) {
20317
20349
  }
20318
20350
  ];
20319
20351
  }
20320
- const schematicSheetIdBySourceGroupId = getSchematicSheetIdBySourceGroupId({
20352
+ const schematicSheetIdsBySourceGroupId = getSchematicSheetIdsBySourceGroupId({
20321
20353
  circuitJson,
20322
- schematicSheetIdBySourceComponentId
20354
+ schematicSheetIdsBySourceComponentId
20323
20355
  });
20324
20356
  return Array.from(schematicSheetIds).map((schematicSheetId) => ({
20325
20357
  tree: getCircuitJsonTree2(
@@ -20327,8 +20359,8 @@ function getSchematicCircuitJsonTrees(circuitJson, opts) {
20327
20359
  circuitJson,
20328
20360
  schematicSheetId,
20329
20361
  rootSourceGroupId: source_group_id,
20330
- schematicSheetIdBySourceComponentId,
20331
- schematicSheetIdBySourceGroupId
20362
+ schematicSheetIdsBySourceComponentId,
20363
+ schematicSheetIdsBySourceGroupId
20332
20364
  }),
20333
20365
  { source_group_id }
20334
20366
  ),
@@ -20649,7 +20681,7 @@ var getSchematicPortSelector = ({
20649
20681
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
20650
20682
  var DEFAULT_MAX_MSP_PAIR_DISTANCE = 2.4;
20651
20683
  var SCHEMATIC_RAIL_NET_LABEL_HEIGHT = 0.42;
20652
- function createSchematicTraceSolverInputProblem(group) {
20684
+ function createSchematicTraceSolverInputProblem(group, opts = {}) {
20653
20685
  const { db } = group.root;
20654
20686
  const connKeyToSourceNet = /* @__PURE__ */ new Map();
20655
20687
  const childGroups = [];
@@ -20669,7 +20701,9 @@ function createSchematicTraceSolverInputProblem(group) {
20669
20701
  group.schematic_group_id,
20670
20702
  ...childGroups.map((a) => a.schematic_group_id)
20671
20703
  ];
20672
- const schematicComponents = db.schematic_component.list().filter((a) => allSchematicGroupIds.includes(a.schematic_group_id));
20704
+ const schematicComponents = db.schematic_component.list().filter((a) => allSchematicGroupIds.includes(a.schematic_group_id)).filter(
20705
+ (schematicComponent) => opts.schematicSheetId === void 0 || schematicComponent.schematic_sheet_id === opts.schematicSheetId
20706
+ );
20673
20707
  const schematicComponentIds = new Set(
20674
20708
  schematicComponents.map((component) => component.schematic_component_id)
20675
20709
  );
@@ -20811,8 +20845,8 @@ function createSchematicTraceSolverInputProblem(group) {
20811
20845
  if (st.subcircuit_id && !allowedSubcircuitIds.has(st.subcircuit_id)) {
20812
20846
  continue;
20813
20847
  }
20814
- const connected = (st.connected_source_port_ids ?? []).map((srcId) => sourcePortIdToSchPortId.get(srcId)).filter(
20815
- (sourcePortId) => Boolean(sourcePortId) && allSourceAndSchematicPortIdsInScope.has(sourcePortId)
20848
+ const connected = (st.connected_source_port_ids ?? []).map((sourcePortId) => sourcePortIdToSchPortId.get(sourcePortId)).filter(
20849
+ (schematicPortId) => Boolean(schematicPortId) && allSourceAndSchematicPortIdsInScope.has(schematicPortId)
20816
20850
  );
20817
20851
  if (connected.length >= 2) {
20818
20852
  const [a, b] = connected.slice(0, 2);
@@ -22086,10 +22120,10 @@ var getSchematicPortIdsWithRoutedTraces = ({
22086
22120
 
22087
22121
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
22088
22122
  var debug10 = Debug12("Group_doInitialSchematicTraceRender");
22089
- var Group_doInitialSchematicTraceRender = (group) => {
22090
- if (!group.root?._featureMspSchematicTraceRouting) return;
22091
- if (!group.isSubcircuit) return;
22092
- if (group.root?.schematicDisabled) return;
22123
+ var renderSchematicTracesForSheet = ({
22124
+ group,
22125
+ schematicSheetId
22126
+ }) => {
22093
22127
  const {
22094
22128
  inputProblem,
22095
22129
  pinIdToSchematicPortId,
@@ -22098,7 +22132,7 @@ var Group_doInitialSchematicTraceRender = (group) => {
22098
22132
  schPortIdToSourcePortId,
22099
22133
  userNetIdToConnKey,
22100
22134
  connKeysWithExplicitPortNetTraces
22101
- } = createSchematicTraceSolverInputProblem(group);
22135
+ } = createSchematicTraceSolverInputProblem(group, { schematicSheetId });
22102
22136
  if (inputProblem.chips.length === 0) return;
22103
22137
  const schematicPortIdsWithPreExistingNetLabels = getSchematicPortIdsWithAssignedNetLabels(group);
22104
22138
  const hasRouteableSchematicConnections = inputProblem.directConnections.length > 0 || inputProblem.netConnections.length > 0;
@@ -22156,6 +22190,35 @@ var Group_doInitialSchematicTraceRender = (group) => {
22156
22190
  connKeyToSourceNet
22157
22191
  });
22158
22192
  };
22193
+ var Group_doInitialSchematicTraceRender = (group) => {
22194
+ if (!group.root?._featureMspSchematicTraceRouting) return;
22195
+ if (!group.isSubcircuit) return;
22196
+ if (group.root?.schematicDisabled) return;
22197
+ const schematicGroupIds = new Set(
22198
+ [
22199
+ group,
22200
+ ...group.getDescendants().filter(
22201
+ (component) => component instanceof Group
22202
+ )
22203
+ ].map((schematicGroup) => schematicGroup.schematic_group_id).filter(
22204
+ (schematicGroupId) => Boolean(schematicGroupId)
22205
+ )
22206
+ );
22207
+ const schematicSheetIds = new Set(
22208
+ group.root.db.schematic_component.list().filter(
22209
+ (schematicComponent) => schematicGroupIds.has(schematicComponent.schematic_group_id)
22210
+ ).map((schematicComponent) => schematicComponent.schematic_sheet_id).filter(
22211
+ (schematicSheetId) => Boolean(schematicSheetId)
22212
+ )
22213
+ );
22214
+ if (schematicSheetIds.size === 0) {
22215
+ renderSchematicTracesForSheet({ group });
22216
+ return;
22217
+ }
22218
+ for (const schematicSheetId of schematicSheetIds) {
22219
+ renderSchematicTracesForSheet({ group, schematicSheetId });
22220
+ }
22221
+ };
22159
22222
 
22160
22223
  // lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
22161
22224
  import { circuitJsonToSpice } from "circuit-json-to-spice";
@@ -22915,7 +22978,7 @@ function Group_getRoutingPhasePlans(group) {
22915
22978
  var package_default = {
22916
22979
  name: "@tscircuit/core",
22917
22980
  type: "module",
22918
- version: "0.0.1475",
22981
+ version: "0.0.1476",
22919
22982
  types: "dist/index.d.ts",
22920
22983
  main: "dist/index.js",
22921
22984
  module: "dist/index.js",
@@ -33067,6 +33130,133 @@ function getTitleAnchorAndPosition({
33067
33130
  }
33068
33131
  }
33069
33132
 
33133
+ // lib/components/primitive-components/SchematicBox/SchematicBox_doInitialSchematicComponentRender.ts
33134
+ var getSchematicBoxPinLabels = (pinLabels) => {
33135
+ if (!pinLabels) return [];
33136
+ return Object.entries(pinLabels).map(([pinKey, pinLabel]) => {
33137
+ const pinNumber = getPinNumberFromPinLabelsKey(pinKey);
33138
+ if (pinNumber === null) {
33139
+ throw new Error(
33140
+ `Invalid schematicbox pinLabels key "${pinKey}". Expected pin<number>.`
33141
+ );
33142
+ }
33143
+ const pinAliases = typeof pinLabel === "string" ? [pinLabel] : [...pinLabel];
33144
+ return {
33145
+ pinNumber,
33146
+ displayPinLabel: pinAliases[0] ?? pinKey,
33147
+ pinAliases
33148
+ };
33149
+ });
33150
+ };
33151
+ var SchematicBox_doInitialSchematicComponentRender = (schematicBox) => {
33152
+ if (schematicBox.root?.schematicDisabled) return;
33153
+ const { db } = schematicBox.root;
33154
+ const props = schematicBox._parsedProps;
33155
+ if (!props.chipRef) return;
33156
+ const referencedChip = schematicBox.getSubcircuit().selectOne(props.chipRef);
33157
+ if (!referencedChip?.source_component_id) {
33158
+ throw new Error(
33159
+ `Could not resolve chipRef "${props.chipRef}" for ${schematicBox.getString()}`
33160
+ );
33161
+ }
33162
+ const schematicBoxPinLabels = getSchematicBoxPinLabels(props.pinLabels);
33163
+ const pinLabelsByPinKey = Object.fromEntries(
33164
+ schematicBoxPinLabels.map(({ pinNumber, displayPinLabel }) => [
33165
+ `pin${pinNumber}`,
33166
+ displayPinLabel
33167
+ ])
33168
+ );
33169
+ const sourcePorts = db.source_port.list({
33170
+ source_component_id: referencedChip.source_component_id
33171
+ });
33172
+ const dimensions = getAllDimensionsForSchematicBox({
33173
+ schWidth: props.width,
33174
+ schHeight: props.height,
33175
+ schPinSpacing: 0.2,
33176
+ pinCount: schematicBoxPinLabels.length,
33177
+ schPortArrangement: props.schPinArrangement,
33178
+ pinLabels: pinLabelsByPinKey
33179
+ });
33180
+ const center = schematicBox._getGlobalSchematicPositionBeforeLayout();
33181
+ const size = dimensions.getSize();
33182
+ const schematicSheetId = schematicBox._resolveSchematicSheetId();
33183
+ const portLabels = Object.fromEntries(
33184
+ schematicBoxPinLabels.map(({ pinNumber, displayPinLabel }) => [
33185
+ String(pinNumber),
33186
+ displayPinLabel
33187
+ ])
33188
+ );
33189
+ const schematicComponent = db.schematic_component.insert({
33190
+ center,
33191
+ size,
33192
+ source_component_id: referencedChip.source_component_id,
33193
+ is_box_with_pins: true,
33194
+ port_arrangement: underscorifyPortArrangement(props.schPinArrangement),
33195
+ port_labels: portLabels,
33196
+ pin_spacing: 0.2,
33197
+ schematic_sheet_id: schematicSheetId
33198
+ });
33199
+ schematicBox.schematic_component_id = schematicComponent.schematic_component_id;
33200
+ for (const {
33201
+ pinNumber,
33202
+ displayPinLabel,
33203
+ pinAliases
33204
+ } of schematicBoxPinLabels) {
33205
+ const referencedSourcePort = sourcePorts.find(
33206
+ (sourcePort) => pinAliases.some(
33207
+ (pinAlias) => sourcePort.name === pinAlias || sourcePort.port_hints?.includes(pinAlias)
33208
+ )
33209
+ );
33210
+ if (!referencedSourcePort) {
33211
+ throw new Error(
33212
+ `Could not find pin "${displayPinLabel}" on chipRef "${props.chipRef}"`
33213
+ );
33214
+ }
33215
+ const portPosition = dimensions.getPortPositionByPinNumber(pinNumber);
33216
+ if (!portPosition) {
33217
+ throw new Error(
33218
+ `Could not determine schematic position for ${schematicBox.getString()} pin${pinNumber}`
33219
+ );
33220
+ }
33221
+ const facingDirection = {
33222
+ left: "left",
33223
+ right: "right",
33224
+ top: "up",
33225
+ bottom: "down"
33226
+ }[portPosition.side];
33227
+ db.schematic_port.insert({
33228
+ schematic_component_id: schematicComponent.schematic_component_id,
33229
+ center: {
33230
+ x: center.x + portPosition.x,
33231
+ y: center.y + portPosition.y
33232
+ },
33233
+ source_port_id: referencedSourcePort.source_port_id,
33234
+ facing_direction: facingDirection,
33235
+ distance_from_component_edge: 0.4,
33236
+ side_of_component: portPosition.side,
33237
+ pin_number: pinNumber,
33238
+ true_ccw_index: portPosition.trueIndex,
33239
+ display_pin_label: displayPinLabel,
33240
+ is_connected: false,
33241
+ schematic_sheet_id: schematicSheetId
33242
+ });
33243
+ }
33244
+ const sectionName = props.name ?? props.chipRef;
33245
+ db.schematic_text.insert({
33246
+ text: sectionName,
33247
+ schematic_component_id: schematicComponent.schematic_component_id,
33248
+ anchor: "left",
33249
+ rotation: 0,
33250
+ position: {
33251
+ x: center.x - size.width / 2,
33252
+ y: center.y + size.height / 2 + 0.13
33253
+ },
33254
+ color: "#006464",
33255
+ font_size: 0.18,
33256
+ schematic_sheet_id: schematicSheetId
33257
+ });
33258
+ };
33259
+
33070
33260
  // lib/components/primitive-components/SchematicBox/SchematicBox.ts
33071
33261
  var SchematicBox = class extends PrimitiveComponent2 {
33072
33262
  isSchematicPrimitive = true;
@@ -33077,11 +33267,15 @@ var SchematicBox = class extends PrimitiveComponent2 {
33077
33267
  shouldRenderAsSchematicBox: true
33078
33268
  };
33079
33269
  }
33270
+ doInitialSchematicComponentRender() {
33271
+ SchematicBox_doInitialSchematicComponentRender(this);
33272
+ }
33080
33273
  doInitialSchematicPrimitiveRender() {
33081
33274
  if (this.root?.schematicDisabled) return;
33082
33275
  if (this.getCollapsedSchematicBoxAncestor()) return;
33083
33276
  const { db } = this.root;
33084
33277
  const { _parsedProps: props } = this;
33278
+ if (props.chipRef) return;
33085
33279
  const basePadding = 0.6;
33086
33280
  const generalPadding = typeof props.padding === "number" ? props.padding : 0;
33087
33281
  const paddingTop = typeof props.paddingTop === "number" ? props.paddingTop : generalPadding;
@@ -33147,7 +33341,8 @@ var SchematicBox = class extends PrimitiveComponent2 {
33147
33341
  width,
33148
33342
  x,
33149
33343
  y,
33150
- is_dashed: props.strokeStyle === "dashed"
33344
+ is_dashed: props.strokeStyle === "dashed",
33345
+ schematic_sheet_id: this._resolveSchematicSheetId()
33151
33346
  });
33152
33347
  if (props.title) {
33153
33348
  const isInside = props.titleInside;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1476",
4
+ "version": "0.0.1477",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",