@tscircuit/core 0.0.26 → 0.0.27
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
|
@@ -133,6 +133,14 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
133
133
|
*/
|
|
134
134
|
computeSchematicGlobalTransform(): Matrix;
|
|
135
135
|
getSchematicSymbol(variant?: "horz" | "vert" | null): SchSymbol | null;
|
|
136
|
+
/**
|
|
137
|
+
* Subcircuit groups have a prop called "layout" that can include manual
|
|
138
|
+
* placements for pcb components. These are typically added from an IDE
|
|
139
|
+
*/
|
|
140
|
+
_getManualPlacementForComponent(component: PrimitiveComponent): {
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
} | null;
|
|
136
144
|
getGlobalPcbPosition(): {
|
|
137
145
|
x: number;
|
|
138
146
|
y: number;
|
package/dist/index.js
CHANGED
|
@@ -274,7 +274,32 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
274
274
|
if (!config.schematicSymbolName) return null;
|
|
275
275
|
return symbols[`${config.schematicSymbolName}_${variant}`] ?? null;
|
|
276
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Subcircuit groups have a prop called "layout" that can include manual
|
|
279
|
+
* placements for pcb components. These are typically added from an IDE
|
|
280
|
+
*/
|
|
281
|
+
_getManualPlacementForComponent(component) {
|
|
282
|
+
if (!this.isSubcircuit) return null;
|
|
283
|
+
const layout = this.props.layout;
|
|
284
|
+
if (!layout) return null;
|
|
285
|
+
const placementConfig = layout.manual_pcb_placement_config;
|
|
286
|
+
if (!placementConfig) return null;
|
|
287
|
+
for (const position of placementConfig.positions) {
|
|
288
|
+
if (isMatchingSelector(component, position.selector)) {
|
|
289
|
+
const center = applyToPoint(
|
|
290
|
+
this.computePcbGlobalTransform(),
|
|
291
|
+
position.center
|
|
292
|
+
);
|
|
293
|
+
return center;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
277
298
|
getGlobalPcbPosition() {
|
|
299
|
+
const manualPlacement = this.getSubcircuit()._getManualPlacementForComponent(this);
|
|
300
|
+
if (manualPlacement) {
|
|
301
|
+
return manualPlacement;
|
|
302
|
+
}
|
|
278
303
|
return applyToPoint(this.computePcbGlobalTransform(), { x: 0, y: 0 });
|
|
279
304
|
}
|
|
280
305
|
getGlobalSchematicPosition() {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type Matrix,
|
|
16
16
|
} from "transformation-matrix"
|
|
17
17
|
import { isMatchingSelector } from "lib/utils/selector-matching"
|
|
18
|
+
import type { LayoutBuilder } from "@tscircuit/layout"
|
|
18
19
|
|
|
19
20
|
export interface BaseComponentConfig {
|
|
20
21
|
schematicSymbolName?: BaseSymbolName | null
|
|
@@ -168,7 +169,40 @@ export abstract class PrimitiveComponent<
|
|
|
168
169
|
)
|
|
169
170
|
}
|
|
170
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Subcircuit groups have a prop called "layout" that can include manual
|
|
174
|
+
* placements for pcb components. These are typically added from an IDE
|
|
175
|
+
*/
|
|
176
|
+
_getManualPlacementForComponent(
|
|
177
|
+
component: PrimitiveComponent,
|
|
178
|
+
): { x: number; y: number } | null {
|
|
179
|
+
if (!this.isSubcircuit) return null
|
|
180
|
+
|
|
181
|
+
const layout: LayoutBuilder = this.props.layout
|
|
182
|
+
if (!layout) return null
|
|
183
|
+
|
|
184
|
+
const placementConfig = layout.manual_pcb_placement_config
|
|
185
|
+
if (!placementConfig) return null
|
|
186
|
+
|
|
187
|
+
for (const position of placementConfig.positions) {
|
|
188
|
+
if (isMatchingSelector(component, position.selector)) {
|
|
189
|
+
const center = applyToPoint(
|
|
190
|
+
this.computePcbGlobalTransform(),
|
|
191
|
+
position.center,
|
|
192
|
+
)
|
|
193
|
+
return center
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return null
|
|
198
|
+
}
|
|
199
|
+
|
|
171
200
|
getGlobalPcbPosition(): { x: number; y: number } {
|
|
201
|
+
const manualPlacement =
|
|
202
|
+
this.getSubcircuit()._getManualPlacementForComponent(this)
|
|
203
|
+
if (manualPlacement) {
|
|
204
|
+
return manualPlacement
|
|
205
|
+
}
|
|
172
206
|
return applyToPoint(this.computePcbGlobalTransform(), { x: 0, y: 0 })
|
|
173
207
|
}
|
|
174
208
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.27",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@biomejs/biome": "^1.8.3",
|
|
19
|
-
"@tscircuit/layout": "^0.0.
|
|
19
|
+
"@tscircuit/layout": "^0.0.28",
|
|
20
20
|
"@tscircuit/log-soup": "^1.0.2",
|
|
21
21
|
"@types/bun": "latest",
|
|
22
22
|
"@types/react": "^18.3.3",
|