@tscircuit/core 0.0.1085 → 0.0.1087
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.js +102 -79
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5498,6 +5498,81 @@ function normalizeTextForCircuitJson(text) {
|
|
|
5498
5498
|
return text.replace(/\\n/g, "\n");
|
|
5499
5499
|
}
|
|
5500
5500
|
|
|
5501
|
+
// lib/utils/pcbSx/resolve-pcb-property.ts
|
|
5502
|
+
function parseSegment(seg) {
|
|
5503
|
+
const bracketIdx = seg.indexOf("[");
|
|
5504
|
+
if (bracketIdx === -1) return { tag: seg };
|
|
5505
|
+
const tag = seg.slice(0, bracketIdx);
|
|
5506
|
+
const attrPart = seg.slice(bracketIdx + 1, seg.lastIndexOf("]"));
|
|
5507
|
+
const m = attrPart.match(/^(\w+)(\^=|\$=|=)['"]?(.*?)['"]?$/);
|
|
5508
|
+
if (!m) return { tag };
|
|
5509
|
+
return { tag, attrName: m[1], attrOp: m[2], attrValue: m[3] };
|
|
5510
|
+
}
|
|
5511
|
+
function componentMatchesSegment(component, seg) {
|
|
5512
|
+
if (component.lowercaseComponentName !== seg.tag) return false;
|
|
5513
|
+
if (!seg.attrName) return true;
|
|
5514
|
+
const attrVal = component.props?.[seg.attrName];
|
|
5515
|
+
if (attrVal === void 0) return false;
|
|
5516
|
+
const valStr = String(attrVal);
|
|
5517
|
+
switch (seg.attrOp) {
|
|
5518
|
+
case "^=":
|
|
5519
|
+
return valStr.startsWith(seg.attrValue);
|
|
5520
|
+
case "$=":
|
|
5521
|
+
return valStr.endsWith(seg.attrValue);
|
|
5522
|
+
case "=":
|
|
5523
|
+
return valStr === seg.attrValue;
|
|
5524
|
+
default:
|
|
5525
|
+
return false;
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
function matchesCompoundSelector(component, segments) {
|
|
5529
|
+
if (!componentMatchesSegment(component, segments[segments.length - 1])) {
|
|
5530
|
+
return false;
|
|
5531
|
+
}
|
|
5532
|
+
let segIdx = segments.length - 2;
|
|
5533
|
+
let current = component.parent;
|
|
5534
|
+
while (segIdx >= 0 && current) {
|
|
5535
|
+
if (componentMatchesSegment(current, segments[segIdx])) {
|
|
5536
|
+
segIdx--;
|
|
5537
|
+
}
|
|
5538
|
+
current = current.parent;
|
|
5539
|
+
}
|
|
5540
|
+
return segIdx < 0;
|
|
5541
|
+
}
|
|
5542
|
+
function resolvePcbProperty({
|
|
5543
|
+
propertyName,
|
|
5544
|
+
resolvedPcbSx,
|
|
5545
|
+
pathFromAmpersand,
|
|
5546
|
+
component
|
|
5547
|
+
}) {
|
|
5548
|
+
if (!resolvedPcbSx) return void 0;
|
|
5549
|
+
let result;
|
|
5550
|
+
let bestSpecificity = 0;
|
|
5551
|
+
for (const [key, entry] of Object.entries(resolvedPcbSx)) {
|
|
5552
|
+
if (!entry || !(propertyName in entry)) continue;
|
|
5553
|
+
const selectorBody = key.startsWith("& ") ? key.slice(2) : key;
|
|
5554
|
+
if (selectorBody === pathFromAmpersand) {
|
|
5555
|
+
const specificity = 1;
|
|
5556
|
+
if (specificity > bestSpecificity) {
|
|
5557
|
+
bestSpecificity = specificity;
|
|
5558
|
+
result = entry[propertyName];
|
|
5559
|
+
}
|
|
5560
|
+
continue;
|
|
5561
|
+
}
|
|
5562
|
+
if (!component) continue;
|
|
5563
|
+
const segments = selectorBody.split(/\s+/).map(parseSegment);
|
|
5564
|
+
if (segments.length < 2) continue;
|
|
5565
|
+
if (matchesCompoundSelector(component, segments)) {
|
|
5566
|
+
const specificity = segments.length;
|
|
5567
|
+
if (specificity > bestSpecificity) {
|
|
5568
|
+
bestSpecificity = specificity;
|
|
5569
|
+
result = entry[propertyName];
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
return result;
|
|
5574
|
+
}
|
|
5575
|
+
|
|
5501
5576
|
// lib/components/primitive-components/FabricationNoteText.ts
|
|
5502
5577
|
var FabricationNoteText = class extends PrimitiveComponent2 {
|
|
5503
5578
|
pcb_fabrication_note_text_id = null;
|
|
@@ -5515,6 +5590,13 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
|
|
|
5515
5590
|
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
5516
5591
|
const container = this.getPrimitiveContainer();
|
|
5517
5592
|
const subcircuit = this.getSubcircuit();
|
|
5593
|
+
const resolvedPcbSxVisibility = resolvePcbProperty({
|
|
5594
|
+
propertyName: "visibility",
|
|
5595
|
+
resolvedPcbSx: this.getResolvedPcbSx(),
|
|
5596
|
+
pathFromAmpersand: "fabricationnotetext",
|
|
5597
|
+
component: this
|
|
5598
|
+
});
|
|
5599
|
+
if (resolvedPcbSxVisibility === "hidden") return;
|
|
5518
5600
|
const pcb_fabrication_note_text = db.pcb_fabrication_note_text.insert({
|
|
5519
5601
|
anchor_alignment: props.anchorAlignment,
|
|
5520
5602
|
anchor_position: {
|
|
@@ -6749,83 +6831,6 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
|
|
|
6749
6831
|
|
|
6750
6832
|
// lib/components/primitive-components/SilkscreenText.ts
|
|
6751
6833
|
import { silkscreenTextProps } from "@tscircuit/props";
|
|
6752
|
-
|
|
6753
|
-
// lib/utils/pcbSx/resolve-pcb-property.ts
|
|
6754
|
-
function parseSegment(seg) {
|
|
6755
|
-
const bracketIdx = seg.indexOf("[");
|
|
6756
|
-
if (bracketIdx === -1) return { tag: seg };
|
|
6757
|
-
const tag = seg.slice(0, bracketIdx);
|
|
6758
|
-
const attrPart = seg.slice(bracketIdx + 1, seg.lastIndexOf("]"));
|
|
6759
|
-
const m = attrPart.match(/^(\w+)(\^=|\$=|=)['"]?(.*?)['"]?$/);
|
|
6760
|
-
if (!m) return { tag };
|
|
6761
|
-
return { tag, attrName: m[1], attrOp: m[2], attrValue: m[3] };
|
|
6762
|
-
}
|
|
6763
|
-
function componentMatchesSegment(component, seg) {
|
|
6764
|
-
if (component.lowercaseComponentName !== seg.tag) return false;
|
|
6765
|
-
if (!seg.attrName) return true;
|
|
6766
|
-
const attrVal = component.props?.[seg.attrName];
|
|
6767
|
-
if (attrVal === void 0) return false;
|
|
6768
|
-
const valStr = String(attrVal);
|
|
6769
|
-
switch (seg.attrOp) {
|
|
6770
|
-
case "^=":
|
|
6771
|
-
return valStr.startsWith(seg.attrValue);
|
|
6772
|
-
case "$=":
|
|
6773
|
-
return valStr.endsWith(seg.attrValue);
|
|
6774
|
-
case "=":
|
|
6775
|
-
return valStr === seg.attrValue;
|
|
6776
|
-
default:
|
|
6777
|
-
return false;
|
|
6778
|
-
}
|
|
6779
|
-
}
|
|
6780
|
-
function matchesCompoundSelector(component, segments) {
|
|
6781
|
-
if (!componentMatchesSegment(component, segments[segments.length - 1])) {
|
|
6782
|
-
return false;
|
|
6783
|
-
}
|
|
6784
|
-
let segIdx = segments.length - 2;
|
|
6785
|
-
let current = component.parent;
|
|
6786
|
-
while (segIdx >= 0 && current) {
|
|
6787
|
-
if (componentMatchesSegment(current, segments[segIdx])) {
|
|
6788
|
-
segIdx--;
|
|
6789
|
-
}
|
|
6790
|
-
current = current.parent;
|
|
6791
|
-
}
|
|
6792
|
-
return segIdx < 0;
|
|
6793
|
-
}
|
|
6794
|
-
function resolvePcbProperty({
|
|
6795
|
-
propertyName,
|
|
6796
|
-
resolvedPcbSx,
|
|
6797
|
-
pathFromAmpersand,
|
|
6798
|
-
component
|
|
6799
|
-
}) {
|
|
6800
|
-
if (!resolvedPcbSx) return void 0;
|
|
6801
|
-
let result;
|
|
6802
|
-
let bestSpecificity = 0;
|
|
6803
|
-
for (const [key, entry] of Object.entries(resolvedPcbSx)) {
|
|
6804
|
-
if (!entry || !(propertyName in entry)) continue;
|
|
6805
|
-
const selectorBody = key.startsWith("& ") ? key.slice(2) : key;
|
|
6806
|
-
if (selectorBody === pathFromAmpersand) {
|
|
6807
|
-
const specificity = 1;
|
|
6808
|
-
if (specificity > bestSpecificity) {
|
|
6809
|
-
bestSpecificity = specificity;
|
|
6810
|
-
result = entry[propertyName];
|
|
6811
|
-
}
|
|
6812
|
-
continue;
|
|
6813
|
-
}
|
|
6814
|
-
if (!component) continue;
|
|
6815
|
-
const segments = selectorBody.split(/\s+/).map(parseSegment);
|
|
6816
|
-
if (segments.length < 2) continue;
|
|
6817
|
-
if (matchesCompoundSelector(component, segments)) {
|
|
6818
|
-
const specificity = segments.length;
|
|
6819
|
-
if (specificity > bestSpecificity) {
|
|
6820
|
-
bestSpecificity = specificity;
|
|
6821
|
-
result = entry[propertyName];
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6824
|
-
}
|
|
6825
|
-
return result;
|
|
6826
|
-
}
|
|
6827
|
-
|
|
6828
|
-
// lib/components/primitive-components/SilkscreenText.ts
|
|
6829
6834
|
import {
|
|
6830
6835
|
applyToPoint as applyToPoint13,
|
|
6831
6836
|
compose as compose3,
|
|
@@ -10506,6 +10511,15 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
10506
10511
|
const text = db.schematic_text.get(child.schematic_text_id);
|
|
10507
10512
|
if (text) schematicElements.push(text);
|
|
10508
10513
|
}
|
|
10514
|
+
if (child.isSchematicPrimitive && child.componentName === "SchematicPath") {
|
|
10515
|
+
const pathIds = child.schematic_path_ids;
|
|
10516
|
+
if (pathIds) {
|
|
10517
|
+
for (const pathId of pathIds) {
|
|
10518
|
+
const path = db.schematic_path.get(pathId);
|
|
10519
|
+
if (path) schematicElements.push(path);
|
|
10520
|
+
}
|
|
10521
|
+
}
|
|
10522
|
+
}
|
|
10509
10523
|
if (child.children && child.children.length > 0) {
|
|
10510
10524
|
collectSchematicPrimitives(child.children);
|
|
10511
10525
|
}
|
|
@@ -14360,6 +14374,15 @@ function updateSchematicPrimitivesForLayoutShift({
|
|
|
14360
14374
|
arc.center.x += deltaX;
|
|
14361
14375
|
arc.center.y += deltaY;
|
|
14362
14376
|
}
|
|
14377
|
+
const paths = db.schematic_path.list({
|
|
14378
|
+
schematic_component_id: schematicComponentId
|
|
14379
|
+
});
|
|
14380
|
+
for (const path of paths) {
|
|
14381
|
+
for (const point6 of path.points) {
|
|
14382
|
+
point6.x += deltaX;
|
|
14383
|
+
point6.y += deltaY;
|
|
14384
|
+
}
|
|
14385
|
+
}
|
|
14363
14386
|
}
|
|
14364
14387
|
|
|
14365
14388
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutGrid.ts
|
|
@@ -18176,7 +18199,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
18176
18199
|
var package_default = {
|
|
18177
18200
|
name: "@tscircuit/core",
|
|
18178
18201
|
type: "module",
|
|
18179
|
-
version: "0.0.
|
|
18202
|
+
version: "0.0.1086",
|
|
18180
18203
|
types: "dist/index.d.ts",
|
|
18181
18204
|
main: "dist/index.js",
|
|
18182
18205
|
module: "dist/index.js",
|
|
@@ -18221,7 +18244,7 @@ var package_default = {
|
|
|
18221
18244
|
"@tscircuit/math-utils": "^0.0.29",
|
|
18222
18245
|
"@tscircuit/miniflex": "^0.0.4",
|
|
18223
18246
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
18224
|
-
"@tscircuit/props": "^0.0.
|
|
18247
|
+
"@tscircuit/props": "^0.0.489",
|
|
18225
18248
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
18226
18249
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
|
18227
18250
|
"@tscircuit/solver-utils": "^0.0.3",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1087",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@tscircuit/math-utils": "^0.0.29",
|
|
47
47
|
"@tscircuit/miniflex": "^0.0.4",
|
|
48
48
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
49
|
-
"@tscircuit/props": "^0.0.
|
|
49
|
+
"@tscircuit/props": "^0.0.489",
|
|
50
50
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
51
51
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
|
52
52
|
"@tscircuit/solver-utils": "^0.0.3",
|