@tscircuit/cli 0.1.2052 → 0.1.2053
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/cli/main.js +293 -98
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -147646,77 +147646,6 @@ var init_create_pcb_documentation_records = __esm(() => {
|
|
|
147646
147646
|
init_create_pcb_text_record();
|
|
147647
147647
|
});
|
|
147648
147648
|
|
|
147649
|
-
// node_modules/circuit-json-to-altium/lib/create-pcb-keepout-records.ts
|
|
147650
|
-
import { pcb_keepout } from "circuit-json";
|
|
147651
|
-
function createPcbKeepoutRecords({
|
|
147652
|
-
circuitJson,
|
|
147653
|
-
circuitToAltiumPcbPoint
|
|
147654
|
-
}) {
|
|
147655
|
-
const records = [];
|
|
147656
|
-
for (const element of circuitJson) {
|
|
147657
|
-
if (element.type !== "pcb_keepout")
|
|
147658
|
-
continue;
|
|
147659
|
-
const keepout = pcb_keepout.parse(element);
|
|
147660
|
-
if (keepout.excluded_pcb_component_ids?.length) {
|
|
147661
|
-
throw new Error(`PCB keepout ${keepout.pcb_keepout_id} excludes components, which Altium primitive keepouts cannot preserve`);
|
|
147662
|
-
}
|
|
147663
|
-
if (keepout.shape === "outline" && keepout.stroke_width <= 0) {
|
|
147664
|
-
throw new Error(`PCB keepout outline ${keepout.pcb_keepout_id} requires a stroke width`);
|
|
147665
|
-
}
|
|
147666
|
-
for (const layer of keepout.layers.map(getAltiumKeepoutLayer)) {
|
|
147667
|
-
if (keepout.shape === "rect") {
|
|
147668
|
-
records.push(createAltiumFillRecord({
|
|
147669
|
-
center: keepout.center,
|
|
147670
|
-
circuitToAltiumPcbPoint,
|
|
147671
|
-
heightMm: keepout.height,
|
|
147672
|
-
isKeepout: true,
|
|
147673
|
-
layer,
|
|
147674
|
-
widthMm: keepout.width
|
|
147675
|
-
}));
|
|
147676
|
-
continue;
|
|
147677
|
-
}
|
|
147678
|
-
if (keepout.shape === "circle") {
|
|
147679
|
-
records.push(createAltiumRegionRecord({
|
|
147680
|
-
circuitPoints: createCirclePoints({
|
|
147681
|
-
center: keepout.center,
|
|
147682
|
-
radiusMm: keepout.radius
|
|
147683
|
-
}),
|
|
147684
|
-
circuitToAltiumPcbPoint,
|
|
147685
|
-
isKeepout: true,
|
|
147686
|
-
layer
|
|
147687
|
-
}));
|
|
147688
|
-
continue;
|
|
147689
|
-
}
|
|
147690
|
-
records.push(...createAltiumTrackRecords({
|
|
147691
|
-
circuitPoints: keepout.outline,
|
|
147692
|
-
circuitToAltiumPcbPoint,
|
|
147693
|
-
isKeepout: true,
|
|
147694
|
-
layer,
|
|
147695
|
-
strokeWidthMm: keepout.stroke_width
|
|
147696
|
-
}));
|
|
147697
|
-
}
|
|
147698
|
-
}
|
|
147699
|
-
return records;
|
|
147700
|
-
}
|
|
147701
|
-
function getAltiumKeepoutLayer(circuitLayer) {
|
|
147702
|
-
const normalizedLayer = circuitLayer.toLowerCase();
|
|
147703
|
-
if (normalizedLayer === "top")
|
|
147704
|
-
return "TOP";
|
|
147705
|
-
if (normalizedLayer === "bottom")
|
|
147706
|
-
return "BOTTOM";
|
|
147707
|
-
if (normalizedLayer === "all" || normalizedLayer === "multilayer") {
|
|
147708
|
-
return "KEEPOUT";
|
|
147709
|
-
}
|
|
147710
|
-
const innerLayerMatch = /^inner(\d+)$/u.exec(normalizedLayer);
|
|
147711
|
-
if (innerLayerMatch?.[1]) {
|
|
147712
|
-
return `MID-LAYER${Number(innerLayerMatch[1])}`;
|
|
147713
|
-
}
|
|
147714
|
-
throw new Error(`Unsupported PCB keepout layer: ${circuitLayer}`);
|
|
147715
|
-
}
|
|
147716
|
-
var init_create_pcb_keepout_records = __esm(() => {
|
|
147717
|
-
init_create_pcb_annotation_primitives();
|
|
147718
|
-
});
|
|
147719
|
-
|
|
147720
147649
|
// node_modules/circuit-json-to-altium/lib/trace-connectivity.ts
|
|
147721
147650
|
class TraceConnectivity {
|
|
147722
147651
|
parentByTraceIndex;
|
|
@@ -147880,6 +147809,140 @@ var init_create_pcb_net_entries = __esm(() => {
|
|
|
147880
147809
|
init_format();
|
|
147881
147810
|
});
|
|
147882
147811
|
|
|
147812
|
+
// node_modules/circuit-json-to-altium/lib/create-pcb-keepout-exclusion-rule.ts
|
|
147813
|
+
function queryString(value) {
|
|
147814
|
+
if (/[\r\n|*?]/u.test(value)) {
|
|
147815
|
+
throw new Error(`Cannot represent keepout exclusion query name: ${JSON.stringify(value)}`);
|
|
147816
|
+
}
|
|
147817
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
147818
|
+
}
|
|
147819
|
+
function createPcbKeepoutExclusionRule({
|
|
147820
|
+
circuitJson,
|
|
147821
|
+
excludedComponentIds,
|
|
147822
|
+
unionIndex
|
|
147823
|
+
}) {
|
|
147824
|
+
const components = byType(circuitJson, "pcb_component");
|
|
147825
|
+
const sources = byType(circuitJson, "source_component");
|
|
147826
|
+
const names = components.map((component, index) => {
|
|
147827
|
+
const source = sources.find((item) => item.source_component_id === component.source_component_id);
|
|
147828
|
+
return sanitizeField(source?.name) || `Component-${index + 1}`;
|
|
147829
|
+
});
|
|
147830
|
+
const sourceIds = new Set;
|
|
147831
|
+
const excludedNames = [...new Set(excludedComponentIds)].map((id) => {
|
|
147832
|
+
const index = components.findIndex((component) => component.pcb_component_id === id);
|
|
147833
|
+
if (index === -1)
|
|
147834
|
+
throw new Error(`Keepout exclusion references missing PCB component ${id}`);
|
|
147835
|
+
const name = names[index];
|
|
147836
|
+
if (names.filter((candidate) => candidate.toLowerCase() === name.toLowerCase()).length !== 1) {
|
|
147837
|
+
throw new Error(`Keepout exclusion has ambiguous Altium component name ${name}`);
|
|
147838
|
+
}
|
|
147839
|
+
sourceIds.add(asString(components[index].source_component_id));
|
|
147840
|
+
return queryString(name);
|
|
147841
|
+
});
|
|
147842
|
+
const portIds = new Set(byType(circuitJson, "source_port").filter((port) => sourceIds.has(asString(port.source_component_id))).map((port) => asString(port.source_port_id)));
|
|
147843
|
+
const nets = createPcbNetEntries(circuitJson).filter((net) => net.sourcePortIds.some((id) => portIds.has(id))).map((net) => queryString(net.name));
|
|
147844
|
+
const scope = [`InComponent(${excludedNames.join(", ")})`];
|
|
147845
|
+
if (nets.length)
|
|
147846
|
+
scope.push(`((IsTrack Or IsArc) And InNet(${nets.join(", ")}))`);
|
|
147847
|
+
return [
|
|
147848
|
+
"|RECORD=Rule",
|
|
147849
|
+
"BINARYRECORDTYPE=0",
|
|
147850
|
+
"RULEKIND=Clearance",
|
|
147851
|
+
"NETSCOPE=AnyNet",
|
|
147852
|
+
"LAYERKIND=SameLayer",
|
|
147853
|
+
`SCOPE1EXPRESSION=IsKeepOut And InUnion(${unionIndex})`,
|
|
147854
|
+
`SCOPE2EXPRESSION=${scope.join(" Or ")}`,
|
|
147855
|
+
`NAME=TscircuitKeepoutExclusion${unionIndex}`,
|
|
147856
|
+
"ENABLED=TRUE",
|
|
147857
|
+
`PRIORITY=${unionIndex}`,
|
|
147858
|
+
"GAP=0mil",
|
|
147859
|
+
"DEFINEDBYLOGICALDOCUMENT=FALSE"
|
|
147860
|
+
].join("|");
|
|
147861
|
+
}
|
|
147862
|
+
var init_create_pcb_keepout_exclusion_rule = __esm(() => {
|
|
147863
|
+
init_create_pcb_net_entries();
|
|
147864
|
+
init_format();
|
|
147865
|
+
});
|
|
147866
|
+
|
|
147867
|
+
// node_modules/circuit-json-to-altium/lib/create-pcb-keepout-records.ts
|
|
147868
|
+
import { pcb_keepout } from "circuit-json";
|
|
147869
|
+
function createPcbKeepoutRecords({
|
|
147870
|
+
circuitJson,
|
|
147871
|
+
circuitToAltiumPcbPoint
|
|
147872
|
+
}) {
|
|
147873
|
+
const records = [];
|
|
147874
|
+
let exclusionIndex = 0;
|
|
147875
|
+
for (const element of circuitJson) {
|
|
147876
|
+
if (element.type !== "pcb_keepout")
|
|
147877
|
+
continue;
|
|
147878
|
+
const keepout = pcb_keepout.parse(element);
|
|
147879
|
+
const unionIndex = keepout.excluded_pcb_component_ids?.length ? ++exclusionIndex : undefined;
|
|
147880
|
+
if (unionIndex !== undefined) {
|
|
147881
|
+
records.push(createPcbKeepoutExclusionRule({
|
|
147882
|
+
circuitJson,
|
|
147883
|
+
excludedComponentIds: keepout.excluded_pcb_component_ids,
|
|
147884
|
+
unionIndex
|
|
147885
|
+
}));
|
|
147886
|
+
}
|
|
147887
|
+
const markUnion = (record) => unionIndex === undefined ? record : `${record}|UNIONINDEX=${unionIndex}`;
|
|
147888
|
+
if (keepout.shape === "outline" && keepout.stroke_width <= 0) {
|
|
147889
|
+
throw new Error(`PCB keepout outline ${keepout.pcb_keepout_id} requires a stroke width`);
|
|
147890
|
+
}
|
|
147891
|
+
for (const layer of keepout.layers.map(getAltiumKeepoutLayer)) {
|
|
147892
|
+
if (keepout.shape === "rect") {
|
|
147893
|
+
records.push(markUnion(createAltiumFillRecord({
|
|
147894
|
+
center: keepout.center,
|
|
147895
|
+
circuitToAltiumPcbPoint,
|
|
147896
|
+
heightMm: keepout.height,
|
|
147897
|
+
isKeepout: true,
|
|
147898
|
+
layer,
|
|
147899
|
+
widthMm: keepout.width
|
|
147900
|
+
})));
|
|
147901
|
+
continue;
|
|
147902
|
+
}
|
|
147903
|
+
if (keepout.shape === "circle") {
|
|
147904
|
+
records.push(markUnion(createAltiumRegionRecord({
|
|
147905
|
+
circuitPoints: createCirclePoints({
|
|
147906
|
+
center: keepout.center,
|
|
147907
|
+
radiusMm: keepout.radius
|
|
147908
|
+
}),
|
|
147909
|
+
circuitToAltiumPcbPoint,
|
|
147910
|
+
isKeepout: true,
|
|
147911
|
+
layer
|
|
147912
|
+
})));
|
|
147913
|
+
continue;
|
|
147914
|
+
}
|
|
147915
|
+
records.push(...createAltiumTrackRecords({
|
|
147916
|
+
circuitPoints: keepout.outline,
|
|
147917
|
+
circuitToAltiumPcbPoint,
|
|
147918
|
+
isKeepout: true,
|
|
147919
|
+
layer,
|
|
147920
|
+
strokeWidthMm: keepout.stroke_width
|
|
147921
|
+
}).map(markUnion));
|
|
147922
|
+
}
|
|
147923
|
+
}
|
|
147924
|
+
return records;
|
|
147925
|
+
}
|
|
147926
|
+
function getAltiumKeepoutLayer(circuitLayer) {
|
|
147927
|
+
const normalizedLayer = circuitLayer.toLowerCase();
|
|
147928
|
+
if (normalizedLayer === "top")
|
|
147929
|
+
return "TOP";
|
|
147930
|
+
if (normalizedLayer === "bottom")
|
|
147931
|
+
return "BOTTOM";
|
|
147932
|
+
if (normalizedLayer === "all" || normalizedLayer === "multilayer") {
|
|
147933
|
+
return "KEEPOUT";
|
|
147934
|
+
}
|
|
147935
|
+
const innerLayerMatch = /^inner(\d+)$/u.exec(normalizedLayer);
|
|
147936
|
+
if (innerLayerMatch?.[1]) {
|
|
147937
|
+
return `MID-LAYER${Number(innerLayerMatch[1])}`;
|
|
147938
|
+
}
|
|
147939
|
+
throw new Error(`Unsupported PCB keepout layer: ${circuitLayer}`);
|
|
147940
|
+
}
|
|
147941
|
+
var init_create_pcb_keepout_records = __esm(() => {
|
|
147942
|
+
init_create_pcb_annotation_primitives();
|
|
147943
|
+
init_create_pcb_keepout_exclusion_rule();
|
|
147944
|
+
});
|
|
147945
|
+
|
|
147883
147946
|
// node_modules/circuit-json-to-altium/lib/create-pcb-silkscreen-graphic-records.ts
|
|
147884
147947
|
function createPcbSilkscreenGraphicRecords({
|
|
147885
147948
|
circuitJson,
|
|
@@ -148392,17 +148455,131 @@ var init_serialize_altium_pcb_doc_with_board_cutouts = __esm(() => {
|
|
|
148392
148455
|
BOARD_CUTOUT_PROPERTY = new TextEncoder().encode("|ISBOARDCUTOUT=TRUE");
|
|
148393
148456
|
});
|
|
148394
148457
|
|
|
148458
|
+
// node_modules/circuit-json-to-altium/lib/serialize-altium-pcb-doc-with-keepout-rules.ts
|
|
148459
|
+
function serializeAltiumPcbDocWithKeepoutRules(source) {
|
|
148460
|
+
const parsed = parseAltiumPcbDoc(source, { mode: "strict" });
|
|
148461
|
+
const rules = parsed.getRecordsByKind("Rule");
|
|
148462
|
+
if (!rules.length)
|
|
148463
|
+
return serializeAltiumPcbDocWithBoardCutouts(source);
|
|
148464
|
+
const stripped = source.split(/\r?\n/u).filter((line) => !/^\|RECORD=Rule\|/u.test(line)).map((line) => line.replace(/\|UNIONINDEX=\d+/gu, "")).join(`\r
|
|
148465
|
+
`);
|
|
148466
|
+
const compound = import_cfb3.default.read(serializeAltiumPcbDocWithBoardCutouts(stripped), {
|
|
148467
|
+
type: "buffer"
|
|
148468
|
+
});
|
|
148469
|
+
const rulePayloads = rules.map((rule) => {
|
|
148470
|
+
if (rule.get("RULEKIND") !== "Clearance" || rule.getNumber("BINARYRECORDTYPE") !== 0) {
|
|
148471
|
+
throw new Error("Keepout rule serializer only supports native Clearance rules");
|
|
148472
|
+
}
|
|
148473
|
+
const text = rule.getString().trim().replace(/\|(?:RECORD|BINARYRECORDTYPE)=[^|]*/gu, "");
|
|
148474
|
+
if (/[^\x20-\x7e]/u.test(text))
|
|
148475
|
+
throw new Error("Keepout rule serialization requires ASCII query names");
|
|
148476
|
+
const payload = new TextEncoder().encode(`${text}\x00`);
|
|
148477
|
+
const record = new Uint8Array(payload.length + 6);
|
|
148478
|
+
new DataView(record.buffer).setUint32(2, payload.length, true);
|
|
148479
|
+
record.set(payload, 6);
|
|
148480
|
+
return record;
|
|
148481
|
+
});
|
|
148482
|
+
const header = new Uint8Array(4);
|
|
148483
|
+
new DataView(header.buffer).setUint32(0, rules.length, true);
|
|
148484
|
+
import_cfb3.default.utils.cfb_add(compound, "Rules6/Header", header);
|
|
148485
|
+
import_cfb3.default.utils.cfb_add(compound, "Rules6/Data", concatenate(rulePayloads));
|
|
148486
|
+
for (const [kind, family] of Object.entries(streams)) {
|
|
148487
|
+
const records = parsed.getRecordsByKind(kind);
|
|
148488
|
+
if (!records.some((record) => record.getNumber("UNIONINDEX") !== undefined))
|
|
148489
|
+
continue;
|
|
148490
|
+
const stream = import_cfb3.default.find(compound, `/${family}/Data`);
|
|
148491
|
+
if (!stream)
|
|
148492
|
+
throw new Error(`Missing Altium ${family} stream`);
|
|
148493
|
+
const bytes = Uint8Array.from(stream.content);
|
|
148494
|
+
const view = new DataView(bytes.buffer);
|
|
148495
|
+
const output = [];
|
|
148496
|
+
let offset = 0;
|
|
148497
|
+
for (const record of records) {
|
|
148498
|
+
if (offset + 5 > bytes.length)
|
|
148499
|
+
throw new Error(`Truncated ${family} header`);
|
|
148500
|
+
const length = view.getUint32(offset + 1, true);
|
|
148501
|
+
const end = offset + 5 + length;
|
|
148502
|
+
if (end > bytes.length)
|
|
148503
|
+
throw new Error(`Truncated ${family} record`);
|
|
148504
|
+
const union = record.getNumber("UNIONINDEX");
|
|
148505
|
+
const payload = bytes.slice(offset + 5, end);
|
|
148506
|
+
const updated = union === undefined ? payload : addUnion(payload, kind, union);
|
|
148507
|
+
const frame = new Uint8Array(5 + updated.length);
|
|
148508
|
+
frame[0] = bytes[offset];
|
|
148509
|
+
new DataView(frame.buffer).setUint32(1, updated.length, true);
|
|
148510
|
+
frame.set(updated, 5);
|
|
148511
|
+
output.push(frame);
|
|
148512
|
+
offset = end;
|
|
148513
|
+
}
|
|
148514
|
+
if (offset !== bytes.length)
|
|
148515
|
+
throw new Error(`Unexpected trailing ${family} records`);
|
|
148516
|
+
stream.content = concatenate(output);
|
|
148517
|
+
stream.size = stream.content.length;
|
|
148518
|
+
}
|
|
148519
|
+
return new Uint8Array(import_cfb3.default.write(compound, { fileType: "cfb", type: "buffer" }));
|
|
148520
|
+
}
|
|
148521
|
+
function addUnion(payload, kind, union) {
|
|
148522
|
+
if (!Number.isInteger(union) || union <= 0 || union > 4294967295)
|
|
148523
|
+
throw new Error("Invalid keepout union index");
|
|
148524
|
+
if (kind === "Region") {
|
|
148525
|
+
if (payload.length < 22)
|
|
148526
|
+
throw new Error("Truncated region properties");
|
|
148527
|
+
const length = new DataView(payload.buffer).getUint32(18, true);
|
|
148528
|
+
if (22 + length > payload.length)
|
|
148529
|
+
throw new Error("Truncated region property block");
|
|
148530
|
+
const properties = new TextDecoder().decode(payload.subarray(22, 22 + length));
|
|
148531
|
+
if (!properties.includes("UNIONINDEX=0"))
|
|
148532
|
+
throw new Error("Missing region union field");
|
|
148533
|
+
const updated = new TextEncoder().encode(properties.replace("UNIONINDEX=0", `UNIONINDEX=${union}`));
|
|
148534
|
+
const result = concatenate([
|
|
148535
|
+
payload.subarray(0, 22),
|
|
148536
|
+
updated,
|
|
148537
|
+
payload.subarray(22 + length)
|
|
148538
|
+
]);
|
|
148539
|
+
new DataView(result.buffer).setUint32(18, updated.length, true);
|
|
148540
|
+
return result;
|
|
148541
|
+
}
|
|
148542
|
+
const expectedLength = kind === "Track" ? 35 : 37;
|
|
148543
|
+
const unionOffset = kind === "Track" ? 36 : 37;
|
|
148544
|
+
if (payload.length !== expectedLength)
|
|
148545
|
+
throw new Error(`Unexpected ${kind} binary layout`);
|
|
148546
|
+
const result = new Uint8Array(unionOffset + 9);
|
|
148547
|
+
result.set(payload);
|
|
148548
|
+
new DataView(result.buffer).setUint32(unionOffset, union, true);
|
|
148549
|
+
return result;
|
|
148550
|
+
}
|
|
148551
|
+
function concatenate(parts) {
|
|
148552
|
+
const result = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
|
|
148553
|
+
let offset = 0;
|
|
148554
|
+
for (const part of parts) {
|
|
148555
|
+
result.set(part, offset);
|
|
148556
|
+
offset += part.length;
|
|
148557
|
+
}
|
|
148558
|
+
return result;
|
|
148559
|
+
}
|
|
148560
|
+
var import_cfb3, streams;
|
|
148561
|
+
var init_serialize_altium_pcb_doc_with_keepout_rules = __esm(() => {
|
|
148562
|
+
init_dist4();
|
|
148563
|
+
init_serialize_altium_pcb_doc_with_board_cutouts();
|
|
148564
|
+
import_cfb3 = __toESM3(require_cfb(), 1);
|
|
148565
|
+
streams = {
|
|
148566
|
+
Fill: "Fills6",
|
|
148567
|
+
Track: "Tracks6",
|
|
148568
|
+
Region: "ShapeBasedRegions6"
|
|
148569
|
+
};
|
|
148570
|
+
});
|
|
148571
|
+
|
|
148395
148572
|
// node_modules/circuit-json-to-altium/lib/stages/build-pcb-document-stage.ts
|
|
148396
148573
|
var BuildPcbDocumentStage;
|
|
148397
148574
|
var init_build_pcb_document_stage = __esm(() => {
|
|
148398
148575
|
init_create_pcb_document();
|
|
148399
|
-
|
|
148576
|
+
init_serialize_altium_pcb_doc_with_keepout_rules();
|
|
148400
148577
|
BuildPcbDocumentStage = class BuildPcbDocumentStage extends ConverterStage2 {
|
|
148401
148578
|
_step() {
|
|
148402
148579
|
const asciiContent = createPcbDocument(this.input);
|
|
148403
148580
|
this.context.pcb = {
|
|
148404
148581
|
asciiContent,
|
|
148405
|
-
content:
|
|
148582
|
+
content: serializeAltiumPcbDocWithKeepoutRules(asciiContent),
|
|
148406
148583
|
filename: `${this.context.safeProjectName}.PcbDoc`
|
|
148407
148584
|
};
|
|
148408
148585
|
this.finished = true;
|
|
@@ -148805,6 +148982,22 @@ var init_altium_color = __esm(() => {
|
|
|
148805
148982
|
// node_modules/circuit-json-to-altium/lib/altium-schematic-colors.ts
|
|
148806
148983
|
var ALTIUM_SCHEMATIC_GRAPHIC_COLOR = 132, ALTIUM_SCHEMATIC_SHEET_AREA_COLOR = 16317695, ALTIUM_SCHEMATIC_WHITE = 16777215;
|
|
148807
148984
|
|
|
148985
|
+
// node_modules/circuit-json-to-altium/lib/create-altium-schematic-coordinate-fields.ts
|
|
148986
|
+
function createAltiumSchematicCoordinateFields(fieldName, coordinateValue) {
|
|
148987
|
+
const ticks = Math.round(coordinateValue * 1e5);
|
|
148988
|
+
if (!Number.isSafeInteger(ticks)) {
|
|
148989
|
+
throw new RangeError(`Invalid schematic coordinate ${fieldName}: ${coordinateValue}`);
|
|
148990
|
+
}
|
|
148991
|
+
const integer = Math.trunc(ticks / 1e5);
|
|
148992
|
+
const fraction = ticks - integer * 1e5;
|
|
148993
|
+
return [
|
|
148994
|
+
`${fieldName}=${integer}`,
|
|
148995
|
+
...fraction === 0 ? [] : [
|
|
148996
|
+
`${fieldName}_FRAC=${fraction < 0 ? "-" : ""}${String(Math.abs(fraction)).padStart(5, "0")}`
|
|
148997
|
+
]
|
|
148998
|
+
];
|
|
148999
|
+
}
|
|
149000
|
+
|
|
148808
149001
|
// node_modules/circuit-json-to-altium/lib/create-altium-schematic-off-sheet-port-record-fields.ts
|
|
148809
149002
|
function getAltiumSchematicPortIoType({
|
|
148810
149003
|
hasInputArrow,
|
|
@@ -148820,6 +149013,7 @@ function getAltiumSchematicPortIoType({
|
|
|
148820
149013
|
}
|
|
148821
149014
|
function createAltiumSchematicOffSheetPortRecordFields({
|
|
148822
149015
|
altiumPortPosition,
|
|
149016
|
+
facingDirection,
|
|
148823
149017
|
hasInputArrow,
|
|
148824
149018
|
hasOutputArrow,
|
|
148825
149019
|
portName
|
|
@@ -148831,6 +149025,7 @@ function createAltiumSchematicOffSheetPortRecordFields({
|
|
|
148831
149025
|
`LOCATION.Y=${altiumPortPosition.y}`,
|
|
148832
149026
|
`WIDTH=${altiumPortWidth}`,
|
|
148833
149027
|
`IOTYPE=${getAltiumSchematicPortIoType({ hasInputArrow, hasOutputArrow })}`,
|
|
149028
|
+
...facingDirection === "up" || facingDirection === "down" ? ["STYLE=4"] : [],
|
|
148834
149029
|
`NAME=${portName}`,
|
|
148835
149030
|
`FONTID=${ALTIUM_SCHEMATIC_OFF_SHEET_PORT_FONT_ID}`,
|
|
148836
149031
|
`COLOR=${ALTIUM_SCHEMATIC_PORT_COLOR}`,
|
|
@@ -148895,7 +149090,11 @@ function createAltiumSchematicFontTable({
|
|
|
148895
149090
|
const nativeTextSizesCircuitUnits = [
|
|
148896
149091
|
...schematicElements.flatMap((text) => text.type === "schematic_text" && (asString(text.schematic_component_id) || asString(text.source_trace_id)) ? [asNumber(text.font_size)] : []),
|
|
148897
149092
|
...hasNetLabels ? [SCHEMATIC_NET_LABEL_FONT_SIZE_CIRCUIT_UNITS] : [],
|
|
148898
|
-
...netLabelTextPresentations.map((text) => asNumber(text.font_size))
|
|
149093
|
+
...netLabelTextPresentations.map((text) => asNumber(text.font_size)),
|
|
149094
|
+
...schematicElements.flatMap((port) => port.type === "schematic_port" && asString(port.schematic_component_id) ? [
|
|
149095
|
+
SCHEMATIC_PIN_NUMBER_FONT_SIZE_CIRCUIT_UNITS,
|
|
149096
|
+
asPositiveNumber(port.display_pin_label_font_size, SCHEMATIC_PIN_NAME_FONT_SIZE_CIRCUIT_UNITS)
|
|
149097
|
+
] : [])
|
|
148899
149098
|
];
|
|
148900
149099
|
for (const size of nativeTextSizesCircuitUnits) {
|
|
148901
149100
|
if (size <= 0)
|
|
@@ -148931,27 +149130,11 @@ function createAltiumSchematicFontTable({
|
|
|
148931
149130
|
templateFontIdBySourceFontId
|
|
148932
149131
|
};
|
|
148933
149132
|
}
|
|
148934
|
-
var ALTIUM_UNITS_PER_CIRCUIT_UNIT = 20, ALTIUM_SCHEMATIC_COMPONENT_FONT_SIZE_POINTS = 4, ALTIUM_SCHEMATIC_ANNOTATION_FONT_NAME = "Arial", SCHEMATIC_NET_LABEL_FONT_SIZE_CIRCUIT_UNITS = 0.18;
|
|
149133
|
+
var ALTIUM_UNITS_PER_CIRCUIT_UNIT = 20, ALTIUM_SCHEMATIC_COMPONENT_FONT_SIZE_POINTS = 4, ALTIUM_SCHEMATIC_ANNOTATION_FONT_NAME = "Arial", SCHEMATIC_NET_LABEL_FONT_SIZE_CIRCUIT_UNITS = 0.18, SCHEMATIC_PIN_NAME_FONT_SIZE_CIRCUIT_UNITS = 0.15, SCHEMATIC_PIN_NUMBER_FONT_SIZE_CIRCUIT_UNITS = 0.2;
|
|
148935
149134
|
var init_create_altium_schematic_font_table = __esm(() => {
|
|
148936
149135
|
init_format();
|
|
148937
149136
|
});
|
|
148938
149137
|
|
|
148939
|
-
// node_modules/circuit-json-to-altium/lib/create-altium-schematic-coordinate-fields.ts
|
|
148940
|
-
function createAltiumSchematicCoordinateFields(fieldName, coordinateValue) {
|
|
148941
|
-
const ticks = Math.round(coordinateValue * 1e5);
|
|
148942
|
-
if (!Number.isSafeInteger(ticks)) {
|
|
148943
|
-
throw new RangeError(`Invalid schematic coordinate ${fieldName}: ${coordinateValue}`);
|
|
148944
|
-
}
|
|
148945
|
-
const integer = Math.trunc(ticks / 1e5);
|
|
148946
|
-
const fraction = ticks - integer * 1e5;
|
|
148947
|
-
return [
|
|
148948
|
-
`${fieldName}=${integer}`,
|
|
148949
|
-
...fraction === 0 ? [] : [
|
|
148950
|
-
`${fieldName}_FRAC=${fraction < 0 ? "-" : ""}${String(Math.abs(fraction)).padStart(5, "0")}`
|
|
148951
|
-
]
|
|
148952
|
-
];
|
|
148953
|
-
}
|
|
148954
|
-
|
|
148955
149138
|
// node_modules/circuit-json-to-altium/lib/estimate-altium-schematic-label-text-width.ts
|
|
148956
149139
|
function estimateAltiumSchematicLabelTextWidth(text, fontSize) {
|
|
148957
149140
|
return [...text].reduce((width, character) => width + (ASCII_GLYPH_ADVANCES[character.codePointAt(0) - 32] ?? 1) * fontSize, 0);
|
|
@@ -150920,6 +151103,8 @@ function createSchematicDocument({
|
|
|
150920
151103
|
cssColor: asString(explicitPinText?.color),
|
|
150921
151104
|
fallbackAltiumColor: ALTIUM_SCHEMATIC_GRAPHIC_COLOR
|
|
150922
151105
|
});
|
|
151106
|
+
const pinNameFontId = nativeTextFontTable.fontIdBySizeCircuitUnits.get(asPositiveNumber(schematicPort.display_pin_label_font_size, SCHEMATIC_PIN_NAME_FONT_SIZE_CIRCUIT_UNITS));
|
|
151107
|
+
const pinNumberFontId = nativeTextFontTable.fontIdBySizeCircuitUnits.get(SCHEMATIC_PIN_NUMBER_FONT_SIZE_CIRCUIT_UNITS);
|
|
150923
151108
|
addSchematicRecord([
|
|
150924
151109
|
"RECORD=2",
|
|
150925
151110
|
`OWNERINDEX=${altiumComponentRecordIndex}`,
|
|
@@ -150933,7 +151118,13 @@ function createSchematicDocument({
|
|
|
150933
151118
|
...schematicPort.has_input_arrow === true ? [`SYMBOL_INNEREDGE=${ALTIUM_PIN_CLOCK_SYMBOL}`] : [],
|
|
150934
151119
|
...schematicPort.is_drawn_with_inversion_circle === true ? [`SYMBOL_OUTEREDGE=${ALTIUM_PIN_INVERSION_SYMBOL}`] : [],
|
|
150935
151120
|
`COLOR=${pinColor}`,
|
|
150936
|
-
|
|
151121
|
+
`PINNAME_POSITIONCONGLOMERATE=${ALTIUM_PIN_CUSTOM_FONT_FLAG | ALTIUM_PIN_CUSTOM_POSITION_FLAG}`,
|
|
151122
|
+
...createAltiumSchematicCoordinateFields("NAME_CUSTOMPOSITION_MARGIN", -circuitToAltiumSchematicLength(SCHEMATIC_PIN_NAME_INSET_CIRCUIT_UNITS)),
|
|
151123
|
+
`NAME_CUSTOMFONTID=${pinNameFontId}`,
|
|
151124
|
+
`NAME_CUSTOMCOLOR=${pinColor}`,
|
|
151125
|
+
`PINDESIGNATOR_POSITIONCONGLOMERATE=${ALTIUM_PIN_CUSTOM_FONT_FLAG}`,
|
|
151126
|
+
`DESIGNATOR_CUSTOMFONTID=${pinNumberFontId}`,
|
|
151127
|
+
`DESIGNATOR_CUSTOMCOLOR=${pinColor}`
|
|
150937
151128
|
], schematicRecordContext);
|
|
150938
151129
|
}
|
|
150939
151130
|
for (const componentGraphicText of componentGraphicTexts) {
|
|
@@ -150958,6 +151149,7 @@ function createSchematicDocument({
|
|
|
150958
151149
|
continue;
|
|
150959
151150
|
addSchematicRecord(createAltiumSchematicOffSheetPortRecordFields({
|
|
150960
151151
|
altiumPortPosition: circuitToAltiumSchematicPoint(circuitPortPosition),
|
|
151152
|
+
facingDirection: asString(schematicPort.facing_direction),
|
|
150961
151153
|
hasInputArrow: schematicPort.has_input_arrow === true,
|
|
150962
151154
|
hasOutputArrow: schematicPort.has_output_arrow === true,
|
|
150963
151155
|
portName
|
|
@@ -151057,7 +151249,7 @@ function createSchematicDocument({
|
|
|
151057
151249
|
`)}\r
|
|
151058
151250
|
`;
|
|
151059
151251
|
}
|
|
151060
|
-
var ALTIUM_PIN_STANDARD_FLAGS = 32, ALTIUM_PIN_NAME_VISIBLE_FLAG = 8, ALTIUM_PIN_DESIGNATOR_VISIBLE_FLAG = 16, ALTIUM_PIN_CLOCK_SYMBOL = 3, ALTIUM_PIN_INVERSION_SYMBOL = 1, ALTIUM_SCHEMATIC_DEFAULT_COLOR3 = 3615007, ALTIUM_SCHEMATIC_FALLBACK_BODY_COLOR = 12779519, ALTIUM_PIN_ORIENTATION_BY_FACING_DIRECTION, DEFAULT_PIN_OUTWARD_DIRECTION, PIN_OUTWARD_DIRECTION_BY_FACING_DIRECTION;
|
|
151252
|
+
var ALTIUM_PIN_STANDARD_FLAGS = 32, ALTIUM_PIN_NAME_VISIBLE_FLAG = 8, ALTIUM_PIN_DESIGNATOR_VISIBLE_FLAG = 16, ALTIUM_PIN_CUSTOM_FONT_FLAG = 16, ALTIUM_PIN_CUSTOM_POSITION_FLAG = 1, SCHEMATIC_PIN_NAME_INSET_CIRCUIT_UNITS = 0.1, ALTIUM_PIN_CLOCK_SYMBOL = 3, ALTIUM_PIN_INVERSION_SYMBOL = 1, ALTIUM_SCHEMATIC_DEFAULT_COLOR3 = 3615007, ALTIUM_SCHEMATIC_FALLBACK_BODY_COLOR = 12779519, ALTIUM_PIN_ORIENTATION_BY_FACING_DIRECTION, DEFAULT_PIN_OUTWARD_DIRECTION, PIN_OUTWARD_DIRECTION_BY_FACING_DIRECTION;
|
|
151061
151253
|
var init_create_schematic_document = __esm(() => {
|
|
151062
151254
|
init_altium_color();
|
|
151063
151255
|
init_create_altium_schematic_font_table();
|
|
@@ -151155,9 +151347,12 @@ function extractAltiumSchematicTemplate({
|
|
|
151155
151347
|
const preservedRecords = sourceRecords.filter((record) => {
|
|
151156
151348
|
if (templateRecords.includes(record))
|
|
151157
151349
|
return true;
|
|
151350
|
+
if (record.recordKind === IMAGE_RECORD_KIND && document2.getParent(record) === undefined) {
|
|
151351
|
+
return true;
|
|
151352
|
+
}
|
|
151158
151353
|
return record.recordKind === "41" && document2.getParent(record) === undefined && referencedParameterNames.has(record.getDecoded("NAME") ?? "");
|
|
151159
151354
|
});
|
|
151160
|
-
const
|
|
151355
|
+
const preservedRecordSet = new Set(preservedRecords);
|
|
151161
151356
|
const generatedRecordIndexBySourceRecord = new Map(preservedRecords.map((record, index) => [record, index + 1]));
|
|
151162
151357
|
const recordFields = preservedRecords.map((record) => {
|
|
151163
151358
|
const parent = document2.getParent(record);
|
|
@@ -151174,7 +151369,7 @@ function extractAltiumSchematicTemplate({
|
|
|
151174
151369
|
});
|
|
151175
151370
|
const sheetRecord = sourceRecords.find((record) => record.recordKind === "31");
|
|
151176
151371
|
return {
|
|
151177
|
-
embeddedImages: document2.embeddedImages.flatMap((image) =>
|
|
151372
|
+
embeddedImages: document2.embeddedImages.flatMap((image) => preservedRecordSet.has(image.record) ? [
|
|
151178
151373
|
{
|
|
151179
151374
|
compressedBytes: image.getCompressedBytes(),
|
|
151180
151375
|
name: image.name
|
|
@@ -151185,7 +151380,7 @@ function extractAltiumSchematicTemplate({
|
|
|
151185
151380
|
sheetRecordFields: getTemplateSheetRecordFields(sheetRecord)
|
|
151186
151381
|
};
|
|
151187
151382
|
}
|
|
151188
|
-
var TEMPLATE_RECORD_KIND = "39", GENERATED_SHEET_FIELD_NAMES, FONT_FIELD_PATTERN;
|
|
151383
|
+
var TEMPLATE_RECORD_KIND = "39", IMAGE_RECORD_KIND = "30", GENERATED_SHEET_FIELD_NAMES, FONT_FIELD_PATTERN;
|
|
151189
151384
|
var init_extract_altium_schematic_template = __esm(() => {
|
|
151190
151385
|
init_dist4();
|
|
151191
151386
|
GENERATED_SHEET_FIELD_NAMES = new Set([
|
|
@@ -153243,7 +153438,7 @@ var import_perfect_cli = __toESM3(require_dist3(), 1);
|
|
|
153243
153438
|
// lib/getVersion.ts
|
|
153244
153439
|
import { createRequire as createRequire2 } from "node:module";
|
|
153245
153440
|
// package.json
|
|
153246
|
-
var version = "0.1.
|
|
153441
|
+
var version = "0.1.2052";
|
|
153247
153442
|
var package_default = {
|
|
153248
153443
|
name: "@tscircuit/cli",
|
|
153249
153444
|
version,
|
|
@@ -153288,7 +153483,7 @@ var package_default = {
|
|
|
153288
153483
|
chokidar: "4.0.1",
|
|
153289
153484
|
"circuit-json": "^0.0.480",
|
|
153290
153485
|
"circuit-json-to-3d-png": "^0.0.6",
|
|
153291
|
-
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#
|
|
153486
|
+
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#1a50d0dd2c0737cf940d92c0315852dc0111dd87",
|
|
153292
153487
|
"circuit-json-to-bom-csv": "^0.0.17",
|
|
153293
153488
|
"circuit-json-to-connectivity-map": "^0.0.25",
|
|
153294
153489
|
"circuit-json-to-fdm-component-box": "^0.0.2",
|
package/dist/lib/index.js
CHANGED
|
@@ -69109,7 +69109,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69109
69109
|
}));
|
|
69110
69110
|
};
|
|
69111
69111
|
// package.json
|
|
69112
|
-
var version = "0.1.
|
|
69112
|
+
var version = "0.1.2052";
|
|
69113
69113
|
var package_default = {
|
|
69114
69114
|
name: "@tscircuit/cli",
|
|
69115
69115
|
version,
|
|
@@ -69154,7 +69154,7 @@ var package_default = {
|
|
|
69154
69154
|
chokidar: "4.0.1",
|
|
69155
69155
|
"circuit-json": "^0.0.480",
|
|
69156
69156
|
"circuit-json-to-3d-png": "^0.0.6",
|
|
69157
|
-
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#
|
|
69157
|
+
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#1a50d0dd2c0737cf940d92c0315852dc0111dd87",
|
|
69158
69158
|
"circuit-json-to-bom-csv": "^0.0.17",
|
|
69159
69159
|
"circuit-json-to-connectivity-map": "^0.0.25",
|
|
69160
69160
|
"circuit-json-to-fdm-component-box": "^0.0.2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2053",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/cli"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"chokidar": "4.0.1",
|
|
43
43
|
"circuit-json": "^0.0.480",
|
|
44
44
|
"circuit-json-to-3d-png": "^0.0.6",
|
|
45
|
-
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#
|
|
45
|
+
"circuit-json-to-altium": "github:tscircuit/circuit-json-to-altium#1a50d0dd2c0737cf940d92c0315852dc0111dd87",
|
|
46
46
|
"circuit-json-to-bom-csv": "^0.0.17",
|
|
47
47
|
"circuit-json-to-connectivity-map": "^0.0.25",
|
|
48
48
|
"circuit-json-to-fdm-component-box": "^0.0.2",
|