@tscircuit/core 0.0.678 → 0.0.679
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 +9 -1
- package/dist/index.js +83 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
|
|
|
12
12
|
import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
|
|
13
13
|
import { GraphicsObject } from 'graphics-debug';
|
|
14
14
|
|
|
15
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
|
|
15
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender"];
|
|
16
16
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
17
17
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
18
18
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
@@ -1016,6 +1016,10 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1016
1016
|
pcb_missing_footprint_error_id?: string;
|
|
1017
1017
|
_hasStartedFootprintUrlLoad: boolean;
|
|
1018
1018
|
private _invalidPinLabelMessages;
|
|
1019
|
+
/**
|
|
1020
|
+
* Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
|
|
1021
|
+
*/
|
|
1022
|
+
_adjustSilkscreenTextAutomatically: boolean;
|
|
1019
1023
|
/**
|
|
1020
1024
|
* Override this property for component defaults
|
|
1021
1025
|
*/
|
|
@@ -1121,6 +1125,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1121
1125
|
x: number;
|
|
1122
1126
|
y: number;
|
|
1123
1127
|
}): void;
|
|
1128
|
+
doInitialSilkscreenOverlapAdjustment(): void;
|
|
1124
1129
|
}
|
|
1125
1130
|
|
|
1126
1131
|
declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps> extends NormalComponent<Props> implements ISubcircuit {
|
|
@@ -2281,6 +2286,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
2281
2286
|
}
|
|
2282
2287
|
|
|
2283
2288
|
declare class Capacitor extends NormalComponent<typeof capacitorProps, PolarizedPassivePorts> {
|
|
2289
|
+
_adjustSilkscreenTextAutomatically: boolean;
|
|
2284
2290
|
get config(): {
|
|
2285
2291
|
componentName: string;
|
|
2286
2292
|
schematicSymbolName: string;
|
|
@@ -8516,6 +8522,7 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
|
|
|
8516
8522
|
}
|
|
8517
8523
|
|
|
8518
8524
|
declare class Resistor extends NormalComponent<typeof resistorProps, PassivePorts> {
|
|
8525
|
+
_adjustSilkscreenTextAutomatically: boolean;
|
|
8519
8526
|
get config(): {
|
|
8520
8527
|
componentName: string;
|
|
8521
8528
|
schematicSymbolName: string;
|
|
@@ -12902,6 +12909,7 @@ declare class Resonator extends NormalComponent<typeof resonatorProps> {
|
|
|
12902
12909
|
}
|
|
12903
12910
|
|
|
12904
12911
|
declare class Inductor extends NormalComponent<typeof inductorProps, PassivePorts> {
|
|
12912
|
+
_adjustSilkscreenTextAutomatically: boolean;
|
|
12905
12913
|
get config(): {
|
|
12906
12914
|
componentName: string;
|
|
12907
12915
|
schematicSymbolName: BaseSymbolName;
|
package/dist/index.js
CHANGED
|
@@ -120,6 +120,7 @@ var orderedRenderPhases = [
|
|
|
120
120
|
"PcbTraceRender",
|
|
121
121
|
"PcbRouteNetIslands",
|
|
122
122
|
"PcbDesignRuleChecks",
|
|
123
|
+
"SilkscreenOverlapAdjustment",
|
|
123
124
|
"CadModelRender",
|
|
124
125
|
"PartsEngineRender"
|
|
125
126
|
];
|
|
@@ -6306,6 +6307,77 @@ var shouldCheckPortForMissingTrace = (component, port) => {
|
|
|
6306
6307
|
return true;
|
|
6307
6308
|
};
|
|
6308
6309
|
|
|
6310
|
+
// lib/components/base-components/NormalComponent/NormalComponent_doInitialSilkscreenOverlapAdjustment.ts
|
|
6311
|
+
import { getBoundingBox } from "@tscircuit/math-utils";
|
|
6312
|
+
function doBoundsIntersect(bounds1, bounds2) {
|
|
6313
|
+
return !(bounds1.maxX <= bounds2.minX || bounds2.maxX <= bounds1.minX || bounds1.maxY <= bounds2.minY || bounds2.maxY <= bounds1.minY);
|
|
6314
|
+
}
|
|
6315
|
+
function NormalComponent_doInitialSilkscreenOverlapAdjustment(component) {
|
|
6316
|
+
if (!component._adjustSilkscreenTextAutomatically) {
|
|
6317
|
+
return;
|
|
6318
|
+
}
|
|
6319
|
+
if (component.root?.pcbDisabled || !component.pcb_component_id) {
|
|
6320
|
+
return;
|
|
6321
|
+
}
|
|
6322
|
+
const { db } = component.root;
|
|
6323
|
+
const componentBounds = component._getPcbCircuitJsonBounds();
|
|
6324
|
+
const componentCenter = componentBounds.center;
|
|
6325
|
+
let silkscreenTexts = db.pcb_silkscreen_text.list({
|
|
6326
|
+
pcb_component_id: component.pcb_component_id
|
|
6327
|
+
}).filter((text) => text.text === component.name);
|
|
6328
|
+
if (silkscreenTexts.length === 0) {
|
|
6329
|
+
return;
|
|
6330
|
+
}
|
|
6331
|
+
const subcircuit = component.getSubcircuit();
|
|
6332
|
+
const allNormalComponents = subcircuit.selectAll("[_isNormalComponent=true]").filter((comp) => comp !== component && comp.pcb_component_id);
|
|
6333
|
+
const obstacleBounds = allNormalComponents.map((comp) => {
|
|
6334
|
+
const bounds = comp._getPcbCircuitJsonBounds();
|
|
6335
|
+
const box = {
|
|
6336
|
+
center: bounds.center,
|
|
6337
|
+
width: bounds.width,
|
|
6338
|
+
height: bounds.height
|
|
6339
|
+
};
|
|
6340
|
+
return getBoundingBox(box);
|
|
6341
|
+
});
|
|
6342
|
+
for (const silkscreenText of silkscreenTexts) {
|
|
6343
|
+
const currentPosition = silkscreenText.anchor_position;
|
|
6344
|
+
const fontSize = silkscreenText.font_size;
|
|
6345
|
+
const textWidth = silkscreenText.text.length * fontSize * 0.6;
|
|
6346
|
+
const textHeight = fontSize;
|
|
6347
|
+
const textBox = {
|
|
6348
|
+
center: currentPosition,
|
|
6349
|
+
width: textWidth,
|
|
6350
|
+
height: textHeight
|
|
6351
|
+
};
|
|
6352
|
+
const textBounds = getBoundingBox(textBox);
|
|
6353
|
+
const hasIntersection = obstacleBounds.some(
|
|
6354
|
+
(obstacle) => doBoundsIntersect(textBounds, obstacle)
|
|
6355
|
+
);
|
|
6356
|
+
if (!hasIntersection) {
|
|
6357
|
+
continue;
|
|
6358
|
+
}
|
|
6359
|
+
const flippedX = 2 * componentCenter.x - currentPosition.x;
|
|
6360
|
+
const flippedY = 2 * componentCenter.y - currentPosition.y;
|
|
6361
|
+
const flippedTextBox = {
|
|
6362
|
+
center: { x: flippedX, y: flippedY },
|
|
6363
|
+
width: textWidth,
|
|
6364
|
+
height: textHeight
|
|
6365
|
+
};
|
|
6366
|
+
const flippedTextBounds = getBoundingBox(flippedTextBox);
|
|
6367
|
+
const flippedHasIntersection = obstacleBounds.some(
|
|
6368
|
+
(obstacle) => doBoundsIntersect(flippedTextBounds, obstacle)
|
|
6369
|
+
);
|
|
6370
|
+
if (!flippedHasIntersection) {
|
|
6371
|
+
db.pcb_silkscreen_text.update(silkscreenText.pcb_silkscreen_text_id, {
|
|
6372
|
+
anchor_position: {
|
|
6373
|
+
x: flippedX,
|
|
6374
|
+
y: flippedY
|
|
6375
|
+
}
|
|
6376
|
+
});
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
|
|
6309
6381
|
// lib/utils/filterPinLabels.ts
|
|
6310
6382
|
import { chipProps } from "@tscircuit/props";
|
|
6311
6383
|
function filterPinLabels(pinLabels) {
|
|
@@ -6373,6 +6445,10 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
6373
6445
|
pcb_missing_footprint_error_id;
|
|
6374
6446
|
_hasStartedFootprintUrlLoad = false;
|
|
6375
6447
|
_invalidPinLabelMessages = [];
|
|
6448
|
+
/**
|
|
6449
|
+
* Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
|
|
6450
|
+
*/
|
|
6451
|
+
_adjustSilkscreenTextAutomatically = false;
|
|
6376
6452
|
/**
|
|
6377
6453
|
* Override this property for component defaults
|
|
6378
6454
|
*/
|
|
@@ -7273,6 +7349,9 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
7273
7349
|
_repositionOnPcb(position) {
|
|
7274
7350
|
return NormalComponent__repositionOnPcb(this, position);
|
|
7275
7351
|
}
|
|
7352
|
+
doInitialSilkscreenOverlapAdjustment() {
|
|
7353
|
+
return NormalComponent_doInitialSilkscreenOverlapAdjustment(this);
|
|
7354
|
+
}
|
|
7276
7355
|
};
|
|
7277
7356
|
|
|
7278
7357
|
// lib/components/normal-components/Board.ts
|
|
@@ -11480,6 +11559,7 @@ var FTYPE = stringProxy;
|
|
|
11480
11559
|
// lib/components/normal-components/Capacitor.ts
|
|
11481
11560
|
import { formatSiUnit } from "format-si-unit";
|
|
11482
11561
|
var Capacitor = class extends NormalComponent {
|
|
11562
|
+
_adjustSilkscreenTextAutomatically = true;
|
|
11483
11563
|
// @ts-ignore (cause the symbolName is string and not fixed)
|
|
11484
11564
|
get config() {
|
|
11485
11565
|
return {
|
|
@@ -12206,6 +12286,7 @@ var VoltageSource = class extends NormalComponent {
|
|
|
12206
12286
|
import { resistorProps } from "@tscircuit/props";
|
|
12207
12287
|
import { formatSiUnit as formatSiUnit3 } from "format-si-unit";
|
|
12208
12288
|
var Resistor = class extends NormalComponent {
|
|
12289
|
+
_adjustSilkscreenTextAutomatically = true;
|
|
12209
12290
|
get config() {
|
|
12210
12291
|
return {
|
|
12211
12292
|
componentName: "Resistor",
|
|
@@ -13121,6 +13202,7 @@ var Resonator = class extends NormalComponent {
|
|
|
13121
13202
|
import { inductorProps } from "@tscircuit/props";
|
|
13122
13203
|
import { formatSiUnit as formatSiUnit5 } from "format-si-unit";
|
|
13123
13204
|
var Inductor = class extends NormalComponent {
|
|
13205
|
+
_adjustSilkscreenTextAutomatically = true;
|
|
13124
13206
|
get config() {
|
|
13125
13207
|
return {
|
|
13126
13208
|
componentName: "Inductor",
|
|
@@ -13913,7 +13995,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
13913
13995
|
var package_default = {
|
|
13914
13996
|
name: "@tscircuit/core",
|
|
13915
13997
|
type: "module",
|
|
13916
|
-
version: "0.0.
|
|
13998
|
+
version: "0.0.678",
|
|
13917
13999
|
types: "dist/index.d.ts",
|
|
13918
14000
|
main: "dist/index.js",
|
|
13919
14001
|
module: "dist/index.js",
|