@tscircuit/cli 0.1.1018 → 0.1.1019
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 +897 -538
- package/dist/lib/index.js +7 -2
- package/package.json +2 -1
package/dist/cli/main.js
CHANGED
|
@@ -68605,18 +68605,18 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68605
68605
|
abs = abs.replace(/\\/g, "/");
|
|
68606
68606
|
return abs;
|
|
68607
68607
|
}
|
|
68608
|
-
function isIgnored(self2,
|
|
68608
|
+
function isIgnored(self2, path44) {
|
|
68609
68609
|
if (!self2.ignore.length)
|
|
68610
68610
|
return false;
|
|
68611
68611
|
return self2.ignore.some(function(item) {
|
|
68612
|
-
return item.matcher.match(
|
|
68612
|
+
return item.matcher.match(path44) || !!(item.gmatcher && item.gmatcher.match(path44));
|
|
68613
68613
|
});
|
|
68614
68614
|
}
|
|
68615
|
-
function childrenIgnored(self2,
|
|
68615
|
+
function childrenIgnored(self2, path44) {
|
|
68616
68616
|
if (!self2.ignore.length)
|
|
68617
68617
|
return false;
|
|
68618
68618
|
return self2.ignore.some(function(item) {
|
|
68619
|
-
return !!(item.gmatcher && item.gmatcher.match(
|
|
68619
|
+
return !!(item.gmatcher && item.gmatcher.match(path44));
|
|
68620
68620
|
});
|
|
68621
68621
|
}
|
|
68622
68622
|
}
|
|
@@ -71664,18 +71664,19 @@ var registerStaticAssetLoaders = () => {
|
|
|
71664
71664
|
// cli/main.ts
|
|
71665
71665
|
var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
71666
71666
|
// package.json
|
|
71667
|
-
var version = "0.1.
|
|
71667
|
+
var version = "0.1.1018";
|
|
71668
71668
|
var package_default = {
|
|
71669
71669
|
name: "@tscircuit/cli",
|
|
71670
|
+
version,
|
|
71670
71671
|
main: "dist/cli/main.js",
|
|
71671
71672
|
exports: {
|
|
71672
71673
|
".": "./dist/cli/main.js",
|
|
71673
71674
|
"./lib": "./dist/lib/index.js"
|
|
71674
71675
|
},
|
|
71675
|
-
version,
|
|
71676
71676
|
devDependencies: {
|
|
71677
71677
|
"@babel/standalone": "^7.26.9",
|
|
71678
71678
|
"@biomejs/biome": "^1.9.4",
|
|
71679
|
+
"@tscircuit/circuit-json-placement-analysis": "^0.0.1",
|
|
71679
71680
|
"@tscircuit/circuit-json-util": "0.0.72",
|
|
71680
71681
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
71681
71682
|
"@tscircuit/file-server": "^0.0.32",
|
|
@@ -71735,6 +71736,10 @@ var package_default = {
|
|
|
71735
71736
|
peerDependencies: {
|
|
71736
71737
|
tscircuit: "*"
|
|
71737
71738
|
},
|
|
71739
|
+
exports: {
|
|
71740
|
+
".": "./dist/cli/main.js",
|
|
71741
|
+
"./lib": "./dist/lib/index.js"
|
|
71742
|
+
},
|
|
71738
71743
|
bin: {
|
|
71739
71744
|
"tscircuit-cli": "./cli/entrypoint.js"
|
|
71740
71745
|
},
|
|
@@ -82469,9 +82474,363 @@ var registerCheckNetlist = (program2) => {
|
|
|
82469
82474
|
};
|
|
82470
82475
|
|
|
82471
82476
|
// cli/check/placement/register.ts
|
|
82477
|
+
import fs38 from "node:fs";
|
|
82478
|
+
import path39 from "node:path";
|
|
82479
|
+
|
|
82480
|
+
// node_modules/@tscircuit/circuit-json-placement-analysis/dist/index.js
|
|
82481
|
+
var CENTER_ANCHOR = "center";
|
|
82482
|
+
var toNumber2 = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
82483
|
+
var fmtNumber = (value) => {
|
|
82484
|
+
if (Number.isInteger(value))
|
|
82485
|
+
return String(value);
|
|
82486
|
+
return value.toFixed(3).replace(/\.0+$/, "").replace(/(\.\d*?)0+$/, "$1");
|
|
82487
|
+
};
|
|
82488
|
+
var fmtMm = (value) => `${fmtNumber(value)}mm`;
|
|
82489
|
+
var withSignedMm = (value) => {
|
|
82490
|
+
const abs = fmtMm(Math.abs(value));
|
|
82491
|
+
return value >= 0 ? `+${abs}` : `-${abs}`;
|
|
82492
|
+
};
|
|
82493
|
+
var isOffBoardEdgeOffset = (boardEdge, offset) => {
|
|
82494
|
+
if (boardEdge === "board.minX" || boardEdge === "board.minY") {
|
|
82495
|
+
return offset < 0;
|
|
82496
|
+
}
|
|
82497
|
+
return offset > 0;
|
|
82498
|
+
};
|
|
82499
|
+
var getComponentToComponentCalcString = (componentName, otherComponentName, direction, distance) => {
|
|
82500
|
+
const d = fmtMm(distance);
|
|
82501
|
+
switch (direction) {
|
|
82502
|
+
case "right":
|
|
82503
|
+
return `${componentName}.pcbLeftEdgeX=calc(${otherComponentName}.maxX+${d})`;
|
|
82504
|
+
case "left":
|
|
82505
|
+
return `${componentName}.pcbRightEdgeX=calc(${otherComponentName}.minX-${d})`;
|
|
82506
|
+
case "up":
|
|
82507
|
+
return `${componentName}.pcbTopEdgeY=calc(${otherComponentName}.minY-${d})`;
|
|
82508
|
+
case "down":
|
|
82509
|
+
return `${componentName}.pcbBottomEdgeY=calc(${otherComponentName}.maxY+${d})`;
|
|
82510
|
+
}
|
|
82511
|
+
};
|
|
82512
|
+
var getComponentToBoardCalcString = (componentName, direction, distance) => {
|
|
82513
|
+
const d = fmtMm(distance);
|
|
82514
|
+
switch (direction) {
|
|
82515
|
+
case "right":
|
|
82516
|
+
return `${componentName}.centerX=calc(board.centerX+${d})`;
|
|
82517
|
+
case "left":
|
|
82518
|
+
return `${componentName}.centerX=calc(board.centerX-${d})`;
|
|
82519
|
+
case "up":
|
|
82520
|
+
return `${componentName}.centerY=calc(board.centerY-${d})`;
|
|
82521
|
+
case "down":
|
|
82522
|
+
return `${componentName}.centerY=calc(board.centerY+${d})`;
|
|
82523
|
+
}
|
|
82524
|
+
};
|
|
82525
|
+
var getDirectionAndDistance = (fromX, fromY, toX, toY) => {
|
|
82526
|
+
const dx = toX - fromX;
|
|
82527
|
+
const dy = toY - fromY;
|
|
82528
|
+
if (Math.abs(dx) >= Math.abs(dy)) {
|
|
82529
|
+
return {
|
|
82530
|
+
direction: dx >= 0 ? "right" : "left",
|
|
82531
|
+
distance: Math.abs(dx),
|
|
82532
|
+
axis: "x"
|
|
82533
|
+
};
|
|
82534
|
+
}
|
|
82535
|
+
return {
|
|
82536
|
+
direction: dy >= 0 ? "up" : "down",
|
|
82537
|
+
distance: Math.abs(dy),
|
|
82538
|
+
axis: "y"
|
|
82539
|
+
};
|
|
82540
|
+
};
|
|
82541
|
+
var lineItemToString = (lineItem) => {
|
|
82542
|
+
switch (lineItem.line_item_type) {
|
|
82543
|
+
case "absolute_component_position":
|
|
82544
|
+
return `${lineItem.component_name}.center=(${fmtMm(lineItem.anchor_position.x)}, ${fmtMm(lineItem.anchor_position.y)}) on ${lineItem.anchor_position.layer}`;
|
|
82545
|
+
case "relative_component_to_component_position":
|
|
82546
|
+
return getComponentToComponentCalcString(lineItem.component_name, lineItem.other_component_name, lineItem.direction, lineItem.distance);
|
|
82547
|
+
case "relative_component_to_board_position":
|
|
82548
|
+
return getComponentToBoardCalcString(lineItem.component_name, lineItem.direction, lineItem.distance);
|
|
82549
|
+
case "component_position_defined_as": {
|
|
82550
|
+
const bits = [];
|
|
82551
|
+
if (lineItem.x_definition)
|
|
82552
|
+
bits.push(`x=${lineItem.x_definition}`);
|
|
82553
|
+
if (lineItem.y_definition)
|
|
82554
|
+
bits.push(`y=${lineItem.y_definition}`);
|
|
82555
|
+
if (lineItem.placement_mode)
|
|
82556
|
+
bits.push(`placement_mode=${lineItem.placement_mode}`);
|
|
82557
|
+
if (bits.length === 0)
|
|
82558
|
+
return `${lineItem.component_name} has no explicit placement definition`;
|
|
82559
|
+
return `${lineItem.component_name} placement definition: ${bits.join(", ")}`;
|
|
82560
|
+
}
|
|
82561
|
+
case "component_anchor_alignment":
|
|
82562
|
+
return `${lineItem.component_name}.anchor_alignment="${lineItem.anchor_alignment}"`;
|
|
82563
|
+
case "component_bounds":
|
|
82564
|
+
return `${lineItem.component_name}.bounds=(minX=${fmtMm(lineItem.min_x)}, maxX=${fmtMm(lineItem.max_x)}, minY=${fmtMm(lineItem.min_y)}, maxY=${fmtMm(lineItem.max_y)})`;
|
|
82565
|
+
case "component_size":
|
|
82566
|
+
return `${lineItem.component_name}.size=(width=${fmtMm(lineItem.width)}, height=${fmtMm(lineItem.height)})`;
|
|
82567
|
+
case "component_orientation":
|
|
82568
|
+
return `${lineItem.component_name}.orientation=${lineItem.orientation}`;
|
|
82569
|
+
case "relative_component_edge_to_board_edge_position":
|
|
82570
|
+
return `${lineItem.component_name}.${lineItem.component_edge}=calc(${lineItem.board_edge}${withSignedMm(lineItem.offset)})${isOffBoardEdgeOffset(lineItem.board_edge, lineItem.offset) ? " [offboard]" : ""}`;
|
|
82571
|
+
default:
|
|
82572
|
+
return "";
|
|
82573
|
+
}
|
|
82574
|
+
};
|
|
82575
|
+
var analyzeComponentPlacement = (circuitJson, componentName) => {
|
|
82576
|
+
const sourceComponent = circuitJson.find((el) => el.type === "source_component" && el.name === componentName);
|
|
82577
|
+
const sourceComponentId = typeof sourceComponent?.source_component_id === "string" ? sourceComponent.source_component_id : null;
|
|
82578
|
+
const lineItems = [];
|
|
82579
|
+
if (!sourceComponent || !sourceComponentId) {
|
|
82580
|
+
return {
|
|
82581
|
+
getLineItems: () => [],
|
|
82582
|
+
getString: () => `Component ${componentName} was not found`
|
|
82583
|
+
};
|
|
82584
|
+
}
|
|
82585
|
+
const pcbComponent = circuitJson.find((el) => el.type === "pcb_component" && el.source_component_id === sourceComponentId);
|
|
82586
|
+
const center = pcbComponent && typeof pcbComponent.center === "object" && pcbComponent.center ? pcbComponent.center : null;
|
|
82587
|
+
const centerX = center ? toNumber2(center.x) : null;
|
|
82588
|
+
const centerY = center ? toNumber2(center.y) : null;
|
|
82589
|
+
const layer = typeof pcbComponent?.layer === "string" ? pcbComponent.layer : null;
|
|
82590
|
+
if (centerX !== null && centerY !== null && layer !== null) {
|
|
82591
|
+
lineItems.push({
|
|
82592
|
+
line_item_type: "absolute_component_position",
|
|
82593
|
+
component_name: componentName,
|
|
82594
|
+
anchor_alignment: CENTER_ANCHOR,
|
|
82595
|
+
anchor_position: {
|
|
82596
|
+
x: centerX,
|
|
82597
|
+
y: centerY,
|
|
82598
|
+
layer
|
|
82599
|
+
}
|
|
82600
|
+
});
|
|
82601
|
+
}
|
|
82602
|
+
const componentWidth = toNumber2(pcbComponent?.width);
|
|
82603
|
+
const componentHeight = toNumber2(pcbComponent?.height);
|
|
82604
|
+
let componentBounds = null;
|
|
82605
|
+
if (centerX !== null && centerY !== null && componentWidth !== null && componentHeight !== null) {
|
|
82606
|
+
const halfWidth = componentWidth / 2;
|
|
82607
|
+
const halfHeight = componentHeight / 2;
|
|
82608
|
+
componentBounds = {
|
|
82609
|
+
line_item_type: "component_bounds",
|
|
82610
|
+
component_name: componentName,
|
|
82611
|
+
width: componentWidth,
|
|
82612
|
+
height: componentHeight,
|
|
82613
|
+
min_x: centerX - halfWidth,
|
|
82614
|
+
max_x: centerX + halfWidth,
|
|
82615
|
+
min_y: centerY - halfHeight,
|
|
82616
|
+
max_y: centerY + halfHeight
|
|
82617
|
+
};
|
|
82618
|
+
lineItems.push(componentBounds);
|
|
82619
|
+
const componentSize = {
|
|
82620
|
+
line_item_type: "component_size",
|
|
82621
|
+
component_name: componentName,
|
|
82622
|
+
width: componentWidth,
|
|
82623
|
+
height: componentHeight
|
|
82624
|
+
};
|
|
82625
|
+
lineItems.push(componentSize);
|
|
82626
|
+
if (sourceComponent.ftype === "simple_pin_header") {
|
|
82627
|
+
const componentOrientation = {
|
|
82628
|
+
line_item_type: "component_orientation",
|
|
82629
|
+
component_name: componentName,
|
|
82630
|
+
orientation: componentWidth >= componentHeight ? "horizontal" : "vertical"
|
|
82631
|
+
};
|
|
82632
|
+
lineItems.push(componentOrientation);
|
|
82633
|
+
}
|
|
82634
|
+
}
|
|
82635
|
+
const anchorAlignmentFromSilk = typeof pcbComponent?.pcb_component_id === "string" ? circuitJson.find((el) => el.type === "pcb_silkscreen_text" && el.pcb_component_id === pcbComponent.pcb_component_id && typeof el.anchor_alignment === "string") : null;
|
|
82636
|
+
const anchorAlignment = typeof anchorAlignmentFromSilk?.anchor_alignment === "string" ? anchorAlignmentFromSilk.anchor_alignment : CENTER_ANCHOR;
|
|
82637
|
+
lineItems.push({
|
|
82638
|
+
line_item_type: "component_anchor_alignment",
|
|
82639
|
+
component_name: componentName,
|
|
82640
|
+
anchor_alignment: anchorAlignment
|
|
82641
|
+
});
|
|
82642
|
+
const xDefinitionRaw = sourceComponent.pcbX ?? sourceComponent.pcb_x ?? sourceComponent.x;
|
|
82643
|
+
const yDefinitionRaw = sourceComponent.pcbY ?? sourceComponent.pcb_y ?? sourceComponent.y;
|
|
82644
|
+
const xDefinition = xDefinitionRaw === undefined ? undefined : String(xDefinitionRaw);
|
|
82645
|
+
const yDefinition = yDefinitionRaw === undefined ? undefined : String(yDefinitionRaw);
|
|
82646
|
+
let placementMode = "none";
|
|
82647
|
+
if (xDefinition !== undefined || yDefinition !== undefined) {
|
|
82648
|
+
placementMode = "props_set";
|
|
82649
|
+
} else if (sourceComponent.placement_mode === "auto" || pcbComponent?.position_mode === "auto") {
|
|
82650
|
+
placementMode = "auto";
|
|
82651
|
+
}
|
|
82652
|
+
lineItems.push({
|
|
82653
|
+
line_item_type: "component_position_defined_as",
|
|
82654
|
+
component_name: componentName,
|
|
82655
|
+
x_definition: xDefinition,
|
|
82656
|
+
y_definition: yDefinition,
|
|
82657
|
+
placement_mode: placementMode
|
|
82658
|
+
});
|
|
82659
|
+
const pcbBoard = circuitJson.find((el) => el.type === "pcb_board");
|
|
82660
|
+
const boardCenter = pcbBoard && typeof pcbBoard.center === "object" && pcbBoard.center ? pcbBoard.center : null;
|
|
82661
|
+
const boardCenterX = boardCenter ? toNumber2(boardCenter.x) : null;
|
|
82662
|
+
const boardCenterY = boardCenter ? toNumber2(boardCenter.y) : null;
|
|
82663
|
+
if (componentBounds !== null && boardCenterX !== null && boardCenterY !== null && toNumber2(pcbBoard?.width) !== null && toNumber2(pcbBoard?.height) !== null) {
|
|
82664
|
+
const boardWidth = toNumber2(pcbBoard?.width);
|
|
82665
|
+
const boardHeight = toNumber2(pcbBoard?.height);
|
|
82666
|
+
const boardMinX = boardCenterX - boardWidth / 2;
|
|
82667
|
+
const boardMaxX = boardCenterX + boardWidth / 2;
|
|
82668
|
+
const boardMinY = boardCenterY - boardHeight / 2;
|
|
82669
|
+
const boardMaxY = boardCenterY + boardHeight / 2;
|
|
82670
|
+
const leftOffsetFromBoardMinX = componentBounds.min_x - boardMinX;
|
|
82671
|
+
const rightOffsetFromBoardMaxX = componentBounds.max_x - boardMaxX;
|
|
82672
|
+
const topOffsetFromBoardMinY = componentBounds.min_y - boardMinY;
|
|
82673
|
+
const bottomOffsetFromBoardMaxY = componentBounds.max_y - boardMaxY;
|
|
82674
|
+
const nearestHorizontal = Math.abs(leftOffsetFromBoardMinX) <= Math.abs(rightOffsetFromBoardMaxX) ? {
|
|
82675
|
+
line_item_type: "relative_component_edge_to_board_edge_position",
|
|
82676
|
+
component_name: componentName,
|
|
82677
|
+
component_edge: "pcbLeftEdgeX",
|
|
82678
|
+
board_edge: "board.minX",
|
|
82679
|
+
offset: leftOffsetFromBoardMinX
|
|
82680
|
+
} : {
|
|
82681
|
+
line_item_type: "relative_component_edge_to_board_edge_position",
|
|
82682
|
+
component_name: componentName,
|
|
82683
|
+
component_edge: "pcbRightEdgeX",
|
|
82684
|
+
board_edge: "board.maxX",
|
|
82685
|
+
offset: rightOffsetFromBoardMaxX
|
|
82686
|
+
};
|
|
82687
|
+
const nearestVertical = Math.abs(topOffsetFromBoardMinY) <= Math.abs(bottomOffsetFromBoardMaxY) ? {
|
|
82688
|
+
line_item_type: "relative_component_edge_to_board_edge_position",
|
|
82689
|
+
component_name: componentName,
|
|
82690
|
+
component_edge: "pcbTopEdgeY",
|
|
82691
|
+
board_edge: "board.minY",
|
|
82692
|
+
offset: topOffsetFromBoardMinY
|
|
82693
|
+
} : {
|
|
82694
|
+
line_item_type: "relative_component_edge_to_board_edge_position",
|
|
82695
|
+
component_name: componentName,
|
|
82696
|
+
component_edge: "pcbBottomEdgeY",
|
|
82697
|
+
board_edge: "board.maxY",
|
|
82698
|
+
offset: bottomOffsetFromBoardMaxY
|
|
82699
|
+
};
|
|
82700
|
+
lineItems.push(nearestHorizontal);
|
|
82701
|
+
lineItems.push(nearestVertical);
|
|
82702
|
+
const boardRelation = getDirectionAndDistance(boardCenterX, boardCenterY, componentBounds.min_x + componentBounds.width / 2, componentBounds.min_y + componentBounds.height / 2);
|
|
82703
|
+
const boardLineItem = {
|
|
82704
|
+
line_item_type: "relative_component_to_board_position",
|
|
82705
|
+
component_name: componentName,
|
|
82706
|
+
anchor_alignment: CENTER_ANCHOR,
|
|
82707
|
+
board_anchor_alignment: CENTER_ANCHOR,
|
|
82708
|
+
direction: boardRelation.direction,
|
|
82709
|
+
distance: boardRelation.distance,
|
|
82710
|
+
calc_distance: `abs(${componentName}.center.${boardRelation.axis} - board.center.${boardRelation.axis})`
|
|
82711
|
+
};
|
|
82712
|
+
lineItems.push(boardLineItem);
|
|
82713
|
+
}
|
|
82714
|
+
if (centerX !== null && centerY !== null) {
|
|
82715
|
+
const sourceComponentsById = /* @__PURE__ */ new Map;
|
|
82716
|
+
for (const el of circuitJson) {
|
|
82717
|
+
if (el.type === "source_component" && typeof el.source_component_id === "string" && typeof el.name === "string") {
|
|
82718
|
+
sourceComponentsById.set(el.source_component_id, el.name);
|
|
82719
|
+
}
|
|
82720
|
+
}
|
|
82721
|
+
const otherPcbComponents = circuitJson.filter((el) => el.type === "pcb_component" && el.source_component_id !== sourceComponentId && typeof el.source_component_id === "string");
|
|
82722
|
+
let closest = null;
|
|
82723
|
+
for (const other of otherPcbComponents) {
|
|
82724
|
+
const otherName = sourceComponentsById.get(other.source_component_id);
|
|
82725
|
+
if (!otherName)
|
|
82726
|
+
continue;
|
|
82727
|
+
const otherCenter = typeof other.center === "object" && other.center ? other.center : null;
|
|
82728
|
+
const otherCenterX = otherCenter ? toNumber2(otherCenter.x) : null;
|
|
82729
|
+
const otherCenterY = otherCenter ? toNumber2(otherCenter.y) : null;
|
|
82730
|
+
if (otherCenterX === null || otherCenterY === null)
|
|
82731
|
+
continue;
|
|
82732
|
+
const dx = otherCenterX - centerX;
|
|
82733
|
+
const dy = otherCenterY - centerY;
|
|
82734
|
+
const score = Math.hypot(dx, dy);
|
|
82735
|
+
if (!closest || score < closest.score) {
|
|
82736
|
+
closest = {
|
|
82737
|
+
name: otherName,
|
|
82738
|
+
centerX: otherCenterX,
|
|
82739
|
+
centerY: otherCenterY,
|
|
82740
|
+
score
|
|
82741
|
+
};
|
|
82742
|
+
}
|
|
82743
|
+
}
|
|
82744
|
+
if (closest) {
|
|
82745
|
+
const relation = getDirectionAndDistance(closest.centerX, closest.centerY, centerX, centerY);
|
|
82746
|
+
const relativeLineItem = {
|
|
82747
|
+
line_item_type: "relative_component_to_component_position",
|
|
82748
|
+
component_name: componentName,
|
|
82749
|
+
anchor_alignment: CENTER_ANCHOR,
|
|
82750
|
+
other_component_name: closest.name,
|
|
82751
|
+
other_anchor_alignment: CENTER_ANCHOR,
|
|
82752
|
+
direction: relation.direction,
|
|
82753
|
+
distance: relation.distance,
|
|
82754
|
+
calc_distance: `abs(${componentName}.center.${relation.axis} - ${closest.name}.center.${relation.axis})`
|
|
82755
|
+
};
|
|
82756
|
+
lineItems.push(relativeLineItem);
|
|
82757
|
+
}
|
|
82758
|
+
}
|
|
82759
|
+
return {
|
|
82760
|
+
getLineItems: () => lineItems,
|
|
82761
|
+
getString: () => lineItems.map(lineItemToString).join(`
|
|
82762
|
+
`)
|
|
82763
|
+
};
|
|
82764
|
+
};
|
|
82765
|
+
var analyzeAllPlacements = (circuitJson) => {
|
|
82766
|
+
const componentNames = [];
|
|
82767
|
+
const seenNames = /* @__PURE__ */ new Set;
|
|
82768
|
+
for (const el of circuitJson) {
|
|
82769
|
+
if (el.type !== "source_component" || typeof el.name !== "string")
|
|
82770
|
+
continue;
|
|
82771
|
+
if (seenNames.has(el.name))
|
|
82772
|
+
continue;
|
|
82773
|
+
seenNames.add(el.name);
|
|
82774
|
+
componentNames.push(el.name);
|
|
82775
|
+
}
|
|
82776
|
+
const analyses = componentNames.map((componentName) => ({
|
|
82777
|
+
componentName,
|
|
82778
|
+
analysis: analyzeComponentPlacement(circuitJson, componentName)
|
|
82779
|
+
}));
|
|
82780
|
+
const lineItems = analyses.flatMap(({ analysis }) => analysis.getLineItems());
|
|
82781
|
+
return {
|
|
82782
|
+
getLineItems: () => lineItems,
|
|
82783
|
+
getString: () => analyses.map(({ analysis }) => analysis.getString()).join(`
|
|
82784
|
+
`)
|
|
82785
|
+
};
|
|
82786
|
+
};
|
|
82787
|
+
|
|
82788
|
+
// cli/check/placement/register.ts
|
|
82789
|
+
var isPrebuiltCircuitJsonFile = (filePath) => {
|
|
82790
|
+
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
82791
|
+
return normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
82792
|
+
};
|
|
82793
|
+
var resolveInputFilePath = async (file) => {
|
|
82794
|
+
if (file) {
|
|
82795
|
+
return path39.isAbsolute(file) ? file : path39.resolve(process.cwd(), file);
|
|
82796
|
+
}
|
|
82797
|
+
const entrypoint = await getEntrypoint({
|
|
82798
|
+
projectDir: process.cwd()
|
|
82799
|
+
});
|
|
82800
|
+
if (!entrypoint) {
|
|
82801
|
+
throw new Error("No input file provided and no entrypoint found");
|
|
82802
|
+
}
|
|
82803
|
+
return entrypoint;
|
|
82804
|
+
};
|
|
82805
|
+
var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
82806
|
+
if (isPrebuiltCircuitJsonFile(filePath)) {
|
|
82807
|
+
const parsedJson = JSON.parse(fs38.readFileSync(filePath, "utf-8"));
|
|
82808
|
+
return Array.isArray(parsedJson) ? parsedJson : [];
|
|
82809
|
+
}
|
|
82810
|
+
const completePlatformConfig = getCompletePlatformConfig({
|
|
82811
|
+
pcbDisabled: true
|
|
82812
|
+
});
|
|
82813
|
+
const { circuitJson } = await generateCircuitJson({
|
|
82814
|
+
filePath,
|
|
82815
|
+
platformConfig: completePlatformConfig
|
|
82816
|
+
});
|
|
82817
|
+
return circuitJson;
|
|
82818
|
+
};
|
|
82819
|
+
var checkPlacement = async (file, refdes) => {
|
|
82820
|
+
const resolvedInputFilePath = await resolveInputFilePath(file);
|
|
82821
|
+
const circuitJson = await getCircuitJsonForPlacementCheck(resolvedInputFilePath);
|
|
82822
|
+
const analysis = refdes ? analyzeComponentPlacement(circuitJson, refdes) : analyzeAllPlacements(circuitJson);
|
|
82823
|
+
return analysis.getString();
|
|
82824
|
+
};
|
|
82472
82825
|
var registerCheckPlacement = (program2) => {
|
|
82473
|
-
program2.commands.find((c) => c.name() === "check").command("placement").description("Partially build and validate the placement").argument("[
|
|
82474
|
-
|
|
82826
|
+
program2.commands.find((c) => c.name() === "check").command("placement").description("Partially build and validate the placement").argument("[file]", "Path to the entry file").argument("[refdes]", "Optional refdes to scope the check").action(async (file, refdes) => {
|
|
82827
|
+
try {
|
|
82828
|
+
const output = await checkPlacement(file, refdes);
|
|
82829
|
+
console.log(output);
|
|
82830
|
+
} catch (error) {
|
|
82831
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
82832
|
+
process.exit(1);
|
|
82833
|
+
}
|
|
82475
82834
|
});
|
|
82476
82835
|
};
|
|
82477
82836
|
|
|
@@ -82488,26 +82847,26 @@ var registerCheckRouting = (program2) => {
|
|
|
82488
82847
|
};
|
|
82489
82848
|
|
|
82490
82849
|
// cli/clone/register.ts
|
|
82491
|
-
import * as
|
|
82492
|
-
import * as
|
|
82850
|
+
import * as fs41 from "node:fs";
|
|
82851
|
+
import * as path42 from "node:path";
|
|
82493
82852
|
|
|
82494
82853
|
// cli/clone/clone-bug-report.ts
|
|
82495
82854
|
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
82496
82855
|
var import_prompts4 = __toESM2(require_prompts3(), 1);
|
|
82497
|
-
import * as
|
|
82498
|
-
import * as
|
|
82856
|
+
import * as fs40 from "node:fs";
|
|
82857
|
+
import * as path41 from "node:path";
|
|
82499
82858
|
|
|
82500
82859
|
// cli/clone/handle-existing-directory.ts
|
|
82501
82860
|
var import_prompts3 = __toESM2(require_prompts3(), 1);
|
|
82502
|
-
import * as
|
|
82503
|
-
import * as
|
|
82861
|
+
import * as fs39 from "node:fs";
|
|
82862
|
+
import * as path40 from "node:path";
|
|
82504
82863
|
var handleExistingDirectory = async (dirPath) => {
|
|
82505
|
-
if (!
|
|
82864
|
+
if (!fs39.existsSync(dirPath))
|
|
82506
82865
|
return;
|
|
82507
82866
|
const response = await import_prompts3.default({
|
|
82508
82867
|
type: "select",
|
|
82509
82868
|
name: "action",
|
|
82510
|
-
message: `Directory "${
|
|
82869
|
+
message: `Directory "${path40.basename(dirPath)}" already exists. What would you like to do?`,
|
|
82511
82870
|
choices: [
|
|
82512
82871
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
82513
82872
|
{
|
|
@@ -82522,7 +82881,7 @@ var handleExistingDirectory = async (dirPath) => {
|
|
|
82522
82881
|
process.exit(0);
|
|
82523
82882
|
}
|
|
82524
82883
|
if (response.action === "delete") {
|
|
82525
|
-
|
|
82884
|
+
fs39.rmSync(dirPath, { recursive: true, force: true });
|
|
82526
82885
|
console.log(`Deleted existing directory: ${dirPath}`);
|
|
82527
82886
|
} else if (response.action === "merge") {
|
|
82528
82887
|
console.log(`Merging files into existing directory: ${dirPath}`);
|
|
@@ -82548,12 +82907,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
82548
82907
|
return commonSegments.join("/");
|
|
82549
82908
|
};
|
|
82550
82909
|
var sanitizeRelativePath = (relativePath) => {
|
|
82551
|
-
const normalizedPath =
|
|
82910
|
+
const normalizedPath = path41.normalize(relativePath);
|
|
82552
82911
|
if (!normalizedPath)
|
|
82553
82912
|
return null;
|
|
82554
|
-
if (
|
|
82913
|
+
if (path41.isAbsolute(normalizedPath))
|
|
82555
82914
|
return null;
|
|
82556
|
-
const segments = normalizedPath.split(
|
|
82915
|
+
const segments = normalizedPath.split(path41.sep);
|
|
82557
82916
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
82558
82917
|
return null;
|
|
82559
82918
|
}
|
|
@@ -82568,7 +82927,7 @@ var cloneBugReport = async ({
|
|
|
82568
82927
|
console.error("Bug report ID must not be empty.");
|
|
82569
82928
|
process.exit(1);
|
|
82570
82929
|
}
|
|
82571
|
-
let dirPath =
|
|
82930
|
+
let dirPath = path41.resolve(`bug-report-${trimmedBugReportId}`);
|
|
82572
82931
|
await handleExistingDirectory(dirPath);
|
|
82573
82932
|
const ky2 = getRegistryApiKy();
|
|
82574
82933
|
let zipBuffer;
|
|
@@ -82586,7 +82945,7 @@ var cloneBugReport = async ({
|
|
|
82586
82945
|
}
|
|
82587
82946
|
process.exit(1);
|
|
82588
82947
|
}
|
|
82589
|
-
|
|
82948
|
+
fs40.mkdirSync(dirPath, { recursive: true });
|
|
82590
82949
|
const zip = await import_jszip2.default.loadAsync(zipBuffer);
|
|
82591
82950
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
82592
82951
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
@@ -82598,29 +82957,29 @@ var cloneBugReport = async ({
|
|
|
82598
82957
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
82599
82958
|
continue;
|
|
82600
82959
|
}
|
|
82601
|
-
const fullPath =
|
|
82602
|
-
|
|
82960
|
+
const fullPath = path41.join(dirPath, sanitizedRelativePath);
|
|
82961
|
+
fs40.mkdirSync(path41.dirname(fullPath), { recursive: true });
|
|
82603
82962
|
const fileContent = await entry.async("nodebuffer");
|
|
82604
|
-
|
|
82963
|
+
fs40.writeFileSync(fullPath, fileContent);
|
|
82605
82964
|
}
|
|
82606
|
-
const packageJsonPath =
|
|
82607
|
-
if (
|
|
82965
|
+
const packageJsonPath = path41.join(dirPath, "package.json");
|
|
82966
|
+
if (fs40.existsSync(packageJsonPath)) {
|
|
82608
82967
|
try {
|
|
82609
|
-
const packageJson = JSON.parse(
|
|
82968
|
+
const packageJson = JSON.parse(fs40.readFileSync(packageJsonPath, "utf-8"));
|
|
82610
82969
|
const packageName = packageJson?.name;
|
|
82611
82970
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
82612
82971
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
82613
|
-
const suggestedDirPath =
|
|
82972
|
+
const suggestedDirPath = path41.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
82614
82973
|
if (suggestedDirPath !== dirPath) {
|
|
82615
82974
|
const response = await import_prompts4.default({
|
|
82616
82975
|
type: "confirm",
|
|
82617
82976
|
name: "rename",
|
|
82618
82977
|
initial: true,
|
|
82619
|
-
message: `Rename the directory to "${
|
|
82978
|
+
message: `Rename the directory to "${path41.basename(suggestedDirPath)}"?`
|
|
82620
82979
|
});
|
|
82621
82980
|
if (response.rename) {
|
|
82622
82981
|
await handleExistingDirectory(suggestedDirPath);
|
|
82623
|
-
|
|
82982
|
+
fs40.renameSync(dirPath, suggestedDirPath);
|
|
82624
82983
|
dirPath = suggestedDirPath;
|
|
82625
82984
|
}
|
|
82626
82985
|
}
|
|
@@ -82629,9 +82988,9 @@ var cloneBugReport = async ({
|
|
|
82629
82988
|
console.warn("Unable to read package name for renaming:", error);
|
|
82630
82989
|
}
|
|
82631
82990
|
}
|
|
82632
|
-
|
|
82991
|
+
fs40.writeFileSync(path41.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
82633
82992
|
generateTsConfig(dirPath);
|
|
82634
|
-
const relativeDirPath =
|
|
82993
|
+
const relativeDirPath = path41.relative(originalCwd, dirPath);
|
|
82635
82994
|
console.log(kleur_default.green(`
|
|
82636
82995
|
Successfully cloned bug report to:`));
|
|
82637
82996
|
console.log(` ${dirPath}/
|
|
@@ -82670,7 +83029,7 @@ var registerClone = (program2) => {
|
|
|
82670
83029
|
const [, author, packageName] = match;
|
|
82671
83030
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
82672
83031
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
82673
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
83032
|
+
const dirPath = userSettingToIncludeAuthor ? path42.resolve(`${author}.${packageName}`) : path42.resolve(packageName);
|
|
82674
83033
|
await handleExistingDirectory(dirPath);
|
|
82675
83034
|
const ky2 = getRegistryApiKy();
|
|
82676
83035
|
let packageFileList = {
|
|
@@ -82691,13 +83050,13 @@ var registerClone = (program2) => {
|
|
|
82691
83050
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
82692
83051
|
process.exit(1);
|
|
82693
83052
|
}
|
|
82694
|
-
|
|
83053
|
+
fs41.mkdirSync(dirPath, { recursive: true });
|
|
82695
83054
|
for (const fileInfo of packageFileList.package_files) {
|
|
82696
83055
|
const filePath = fileInfo.file_path.replace(/^\/+/, "");
|
|
82697
83056
|
if (!filePath)
|
|
82698
83057
|
continue;
|
|
82699
|
-
const fullPath =
|
|
82700
|
-
|
|
83058
|
+
const fullPath = path42.join(dirPath, filePath);
|
|
83059
|
+
fs41.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
82701
83060
|
try {
|
|
82702
83061
|
const fileContent = await ky2.get("package_files/get", {
|
|
82703
83062
|
searchParams: {
|
|
@@ -82708,14 +83067,14 @@ var registerClone = (program2) => {
|
|
|
82708
83067
|
}).json();
|
|
82709
83068
|
const { is_text: isText, content_text: contentText } = fileContent.package_file;
|
|
82710
83069
|
if (isText && typeof contentText === "string") {
|
|
82711
|
-
|
|
83070
|
+
fs41.writeFileSync(fullPath, contentText);
|
|
82712
83071
|
} else if (!isText) {
|
|
82713
83072
|
const fileBuffer = await ky2.get("package_files/download", {
|
|
82714
83073
|
searchParams: {
|
|
82715
83074
|
package_file_id: fileContent.package_file.package_file_id
|
|
82716
83075
|
}
|
|
82717
83076
|
}).arrayBuffer();
|
|
82718
|
-
|
|
83077
|
+
fs41.writeFileSync(fullPath, Buffer.from(fileBuffer));
|
|
82719
83078
|
} else {
|
|
82720
83079
|
console.warn(`Skipping ${filePath} due to empty content.`);
|
|
82721
83080
|
}
|
|
@@ -82723,10 +83082,10 @@ var registerClone = (program2) => {
|
|
|
82723
83082
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
82724
83083
|
}
|
|
82725
83084
|
}
|
|
82726
|
-
|
|
83085
|
+
fs41.writeFileSync(path42.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
82727
83086
|
generateTsConfig(dirPath);
|
|
82728
83087
|
await setupTsciProject(dirPath);
|
|
82729
|
-
const relativeDirPath =
|
|
83088
|
+
const relativeDirPath = path42.relative(originalCwd, dirPath);
|
|
82730
83089
|
console.log(kleur_default.green(`
|
|
82731
83090
|
Successfully cloned to:`));
|
|
82732
83091
|
console.log(` ${dirPath}/
|
|
@@ -82793,8 +83152,8 @@ var registerConfigSet = (program2) => {
|
|
|
82793
83152
|
};
|
|
82794
83153
|
|
|
82795
83154
|
// cli/convert/register.ts
|
|
82796
|
-
import
|
|
82797
|
-
import
|
|
83155
|
+
import fs42 from "node:fs/promises";
|
|
83156
|
+
import path43 from "node:path";
|
|
82798
83157
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
82799
83158
|
|
|
82800
83159
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -82915,15 +83274,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
82915
83274
|
var registerConvert = (program2) => {
|
|
82916
83275
|
program2.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
82917
83276
|
try {
|
|
82918
|
-
const inputPath =
|
|
82919
|
-
const modContent = await
|
|
83277
|
+
const inputPath = path43.resolve(file);
|
|
83278
|
+
const modContent = await fs42.readFile(inputPath, "utf-8");
|
|
82920
83279
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
82921
|
-
const componentName = options.name ??
|
|
83280
|
+
const componentName = options.name ?? path43.basename(inputPath, ".kicad_mod");
|
|
82922
83281
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
82923
83282
|
componentName
|
|
82924
83283
|
});
|
|
82925
|
-
const outputPath = options.output ?
|
|
82926
|
-
await
|
|
83284
|
+
const outputPath = options.output ? path43.resolve(options.output) : path43.join(path43.dirname(inputPath), `${componentName}.tsx`);
|
|
83285
|
+
await fs42.writeFile(outputPath, tsx);
|
|
82927
83286
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
82928
83287
|
} catch (error) {
|
|
82929
83288
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -82933,13 +83292,13 @@ var registerConvert = (program2) => {
|
|
|
82933
83292
|
};
|
|
82934
83293
|
|
|
82935
83294
|
// cli/dev/register.ts
|
|
82936
|
-
import * as
|
|
83295
|
+
import * as fs49 from "node:fs";
|
|
82937
83296
|
import * as net from "node:net";
|
|
82938
|
-
import * as
|
|
83297
|
+
import * as path51 from "node:path";
|
|
82939
83298
|
|
|
82940
83299
|
// lib/server/createHttpServer.ts
|
|
82941
83300
|
import * as http from "node:http";
|
|
82942
|
-
import * as
|
|
83301
|
+
import * as fs44 from "node:fs";
|
|
82943
83302
|
|
|
82944
83303
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
82945
83304
|
var import_node_utils = __toESM2(require_dist5(), 1);
|
|
@@ -83641,10 +84000,10 @@ var databaseSchema = z5.object({
|
|
|
83641
84000
|
files: z5.array(fileSchema).default([]),
|
|
83642
84001
|
events: z5.array(eventSchema).default([])
|
|
83643
84002
|
});
|
|
83644
|
-
function normalizePath(
|
|
83645
|
-
if (!
|
|
84003
|
+
function normalizePath(path44) {
|
|
84004
|
+
if (!path44 || path44 === "/")
|
|
83646
84005
|
return "";
|
|
83647
|
-
let normalized =
|
|
84006
|
+
let normalized = path44.replace(/\\+/g, "/").replace(/\/\/+/, "/");
|
|
83648
84007
|
if (normalized.startsWith("/")) {
|
|
83649
84008
|
normalized = normalized.slice(1);
|
|
83650
84009
|
}
|
|
@@ -84501,14 +84860,14 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
84501
84860
|
};
|
|
84502
84861
|
|
|
84503
84862
|
// lib/server/kicad-pcm-proxy.ts
|
|
84504
|
-
import * as
|
|
84505
|
-
import * as
|
|
84863
|
+
import * as fs43 from "node:fs";
|
|
84864
|
+
import * as path44 from "node:path";
|
|
84506
84865
|
var getSourceFilesChecksum = (projectDir) => {
|
|
84507
84866
|
const sourceFiles = globbySync(["**/*.tsx", "**/*.ts", "**/*.json", "!node_modules/**", "!dist/**"], { cwd: projectDir });
|
|
84508
84867
|
let checksum = "";
|
|
84509
84868
|
for (const file of sourceFiles) {
|
|
84510
84869
|
try {
|
|
84511
|
-
const stat =
|
|
84870
|
+
const stat = fs43.statSync(path44.join(projectDir, file));
|
|
84512
84871
|
checksum += `${file}:${stat.mtimeMs};`;
|
|
84513
84872
|
} catch {}
|
|
84514
84873
|
}
|
|
@@ -84528,9 +84887,9 @@ var createKicadPcmProxy = ({
|
|
|
84528
84887
|
};
|
|
84529
84888
|
const handleRequest = async (url, res) => {
|
|
84530
84889
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
84531
|
-
const distDir =
|
|
84532
|
-
const pcmDir =
|
|
84533
|
-
const filePath =
|
|
84890
|
+
const distDir = path44.join(projectDir, "dist");
|
|
84891
|
+
const pcmDir = path44.join(distDir, "pcm");
|
|
84892
|
+
const filePath = path44.join(pcmDir, requestedFile);
|
|
84534
84893
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
84535
84894
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
84536
84895
|
if (needsRebuild) {
|
|
@@ -84575,12 +84934,12 @@ Rebuilding KiCad PCM assets...`));
|
|
|
84575
84934
|
}
|
|
84576
84935
|
}
|
|
84577
84936
|
}
|
|
84578
|
-
if (!
|
|
84937
|
+
if (!fs43.existsSync(filePath)) {
|
|
84579
84938
|
res.writeHead(404);
|
|
84580
84939
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
84581
84940
|
return;
|
|
84582
84941
|
}
|
|
84583
|
-
const ext =
|
|
84942
|
+
const ext = path44.extname(filePath).toLowerCase();
|
|
84584
84943
|
let contentType = "application/octet-stream";
|
|
84585
84944
|
if (ext === ".json") {
|
|
84586
84945
|
contentType = "application/json";
|
|
@@ -84588,7 +84947,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
84588
84947
|
contentType = "application/zip";
|
|
84589
84948
|
}
|
|
84590
84949
|
try {
|
|
84591
|
-
const content =
|
|
84950
|
+
const content = fs43.readFileSync(filePath);
|
|
84592
84951
|
res.writeHead(200, { "Content-Type": contentType });
|
|
84593
84952
|
res.end(content);
|
|
84594
84953
|
} catch (error) {
|
|
@@ -84621,7 +84980,7 @@ var createHttpServer = async ({
|
|
|
84621
84980
|
return;
|
|
84622
84981
|
}
|
|
84623
84982
|
try {
|
|
84624
|
-
const content =
|
|
84983
|
+
const content = fs44.readFileSync(standaloneFilePath, "utf8");
|
|
84625
84984
|
res.writeHead(200, {
|
|
84626
84985
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
84627
84986
|
});
|
|
@@ -84712,8 +85071,8 @@ class EventsWatcher extends EventEmitter {
|
|
|
84712
85071
|
}
|
|
84713
85072
|
|
|
84714
85073
|
// cli/dev/DevServer.ts
|
|
84715
|
-
import
|
|
84716
|
-
import
|
|
85074
|
+
import path49 from "node:path";
|
|
85075
|
+
import fs47 from "node:fs";
|
|
84717
85076
|
|
|
84718
85077
|
// node_modules/chokidar/esm/index.js
|
|
84719
85078
|
import { stat as statcb } from "fs";
|
|
@@ -84792,7 +85151,7 @@ class ReaddirpStream extends Readable {
|
|
|
84792
85151
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
84793
85152
|
const statMethod = opts.lstat ? lstat : stat;
|
|
84794
85153
|
if (wantBigintFsStats) {
|
|
84795
|
-
this._stat = (
|
|
85154
|
+
this._stat = (path45) => statMethod(path45, { bigint: true });
|
|
84796
85155
|
} else {
|
|
84797
85156
|
this._stat = statMethod;
|
|
84798
85157
|
}
|
|
@@ -84817,8 +85176,8 @@ class ReaddirpStream extends Readable {
|
|
|
84817
85176
|
const par = this.parent;
|
|
84818
85177
|
const fil = par && par.files;
|
|
84819
85178
|
if (fil && fil.length > 0) {
|
|
84820
|
-
const { path:
|
|
84821
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
85179
|
+
const { path: path45, depth } = par;
|
|
85180
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path45));
|
|
84822
85181
|
const awaited = await Promise.all(slice);
|
|
84823
85182
|
for (const entry of awaited) {
|
|
84824
85183
|
if (!entry)
|
|
@@ -84858,20 +85217,20 @@ class ReaddirpStream extends Readable {
|
|
|
84858
85217
|
this.reading = false;
|
|
84859
85218
|
}
|
|
84860
85219
|
}
|
|
84861
|
-
async _exploreDir(
|
|
85220
|
+
async _exploreDir(path45, depth) {
|
|
84862
85221
|
let files;
|
|
84863
85222
|
try {
|
|
84864
|
-
files = await readdir(
|
|
85223
|
+
files = await readdir(path45, this._rdOptions);
|
|
84865
85224
|
} catch (error) {
|
|
84866
85225
|
this._onError(error);
|
|
84867
85226
|
}
|
|
84868
|
-
return { files, depth, path:
|
|
85227
|
+
return { files, depth, path: path45 };
|
|
84869
85228
|
}
|
|
84870
|
-
async _formatEntry(dirent,
|
|
85229
|
+
async _formatEntry(dirent, path45) {
|
|
84871
85230
|
let entry;
|
|
84872
85231
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
84873
85232
|
try {
|
|
84874
|
-
const fullPath = presolve(pjoin(
|
|
85233
|
+
const fullPath = presolve(pjoin(path45, basename4));
|
|
84875
85234
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
|
|
84876
85235
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
84877
85236
|
} catch (err) {
|
|
@@ -85269,16 +85628,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
85269
85628
|
};
|
|
85270
85629
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
85271
85630
|
var FsWatchInstances = new Map;
|
|
85272
|
-
function createFsWatchInstance(
|
|
85631
|
+
function createFsWatchInstance(path45, options, listener, errHandler, emitRaw) {
|
|
85273
85632
|
const handleEvent = (rawEvent, evPath) => {
|
|
85274
|
-
listener(
|
|
85275
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
85276
|
-
if (evPath &&
|
|
85277
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
85633
|
+
listener(path45);
|
|
85634
|
+
emitRaw(rawEvent, evPath, { watchedPath: path45 });
|
|
85635
|
+
if (evPath && path45 !== evPath) {
|
|
85636
|
+
fsWatchBroadcast(sysPath.resolve(path45, evPath), KEY_LISTENERS, sysPath.join(path45, evPath));
|
|
85278
85637
|
}
|
|
85279
85638
|
};
|
|
85280
85639
|
try {
|
|
85281
|
-
return fs_watch(
|
|
85640
|
+
return fs_watch(path45, {
|
|
85282
85641
|
persistent: options.persistent
|
|
85283
85642
|
}, handleEvent);
|
|
85284
85643
|
} catch (error) {
|
|
@@ -85294,12 +85653,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
85294
85653
|
listener(val1, val2, val3);
|
|
85295
85654
|
});
|
|
85296
85655
|
};
|
|
85297
|
-
var setFsWatchListener = (
|
|
85656
|
+
var setFsWatchListener = (path45, fullPath, options, handlers) => {
|
|
85298
85657
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
85299
85658
|
let cont = FsWatchInstances.get(fullPath);
|
|
85300
85659
|
let watcher;
|
|
85301
85660
|
if (!options.persistent) {
|
|
85302
|
-
watcher = createFsWatchInstance(
|
|
85661
|
+
watcher = createFsWatchInstance(path45, options, listener, errHandler, rawEmitter);
|
|
85303
85662
|
if (!watcher)
|
|
85304
85663
|
return;
|
|
85305
85664
|
return watcher.close.bind(watcher);
|
|
@@ -85309,7 +85668,7 @@ var setFsWatchListener = (path44, fullPath, options, handlers) => {
|
|
|
85309
85668
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
85310
85669
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
85311
85670
|
} else {
|
|
85312
|
-
watcher = createFsWatchInstance(
|
|
85671
|
+
watcher = createFsWatchInstance(path45, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
85313
85672
|
if (!watcher)
|
|
85314
85673
|
return;
|
|
85315
85674
|
watcher.on(EV.ERROR, async (error) => {
|
|
@@ -85318,7 +85677,7 @@ var setFsWatchListener = (path44, fullPath, options, handlers) => {
|
|
|
85318
85677
|
cont.watcherUnusable = true;
|
|
85319
85678
|
if (isWindows && error.code === "EPERM") {
|
|
85320
85679
|
try {
|
|
85321
|
-
const fd = await open(
|
|
85680
|
+
const fd = await open(path45, "r");
|
|
85322
85681
|
await fd.close();
|
|
85323
85682
|
broadcastErr(error);
|
|
85324
85683
|
} catch (err) {}
|
|
@@ -85348,7 +85707,7 @@ var setFsWatchListener = (path44, fullPath, options, handlers) => {
|
|
|
85348
85707
|
};
|
|
85349
85708
|
};
|
|
85350
85709
|
var FsWatchFileInstances = new Map;
|
|
85351
|
-
var setFsWatchFileListener = (
|
|
85710
|
+
var setFsWatchFileListener = (path45, fullPath, options, handlers) => {
|
|
85352
85711
|
const { listener, rawEmitter } = handlers;
|
|
85353
85712
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
85354
85713
|
const copts = cont && cont.options;
|
|
@@ -85370,7 +85729,7 @@ var setFsWatchFileListener = (path44, fullPath, options, handlers) => {
|
|
|
85370
85729
|
});
|
|
85371
85730
|
const currmtime = curr.mtimeMs;
|
|
85372
85731
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
85373
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
85732
|
+
foreach(cont.listeners, (listener2) => listener2(path45, curr));
|
|
85374
85733
|
}
|
|
85375
85734
|
})
|
|
85376
85735
|
};
|
|
@@ -85393,13 +85752,13 @@ class NodeFsHandler {
|
|
|
85393
85752
|
this.fsw = fsW;
|
|
85394
85753
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
85395
85754
|
}
|
|
85396
|
-
_watchWithNodeFs(
|
|
85755
|
+
_watchWithNodeFs(path45, listener) {
|
|
85397
85756
|
const opts = this.fsw.options;
|
|
85398
|
-
const directory = sysPath.dirname(
|
|
85399
|
-
const basename5 = sysPath.basename(
|
|
85757
|
+
const directory = sysPath.dirname(path45);
|
|
85758
|
+
const basename5 = sysPath.basename(path45);
|
|
85400
85759
|
const parent = this.fsw._getWatchedDir(directory);
|
|
85401
85760
|
parent.add(basename5);
|
|
85402
|
-
const absolutePath = sysPath.resolve(
|
|
85761
|
+
const absolutePath = sysPath.resolve(path45);
|
|
85403
85762
|
const options = {
|
|
85404
85763
|
persistent: opts.persistent
|
|
85405
85764
|
};
|
|
@@ -85409,12 +85768,12 @@ class NodeFsHandler {
|
|
|
85409
85768
|
if (opts.usePolling) {
|
|
85410
85769
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
85411
85770
|
options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
|
|
85412
|
-
closer = setFsWatchFileListener(
|
|
85771
|
+
closer = setFsWatchFileListener(path45, absolutePath, options, {
|
|
85413
85772
|
listener,
|
|
85414
85773
|
rawEmitter: this.fsw._emitRaw
|
|
85415
85774
|
});
|
|
85416
85775
|
} else {
|
|
85417
|
-
closer = setFsWatchListener(
|
|
85776
|
+
closer = setFsWatchListener(path45, absolutePath, options, {
|
|
85418
85777
|
listener,
|
|
85419
85778
|
errHandler: this._boundHandleError,
|
|
85420
85779
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -85432,7 +85791,7 @@ class NodeFsHandler {
|
|
|
85432
85791
|
let prevStats = stats;
|
|
85433
85792
|
if (parent.has(basename5))
|
|
85434
85793
|
return;
|
|
85435
|
-
const listener = async (
|
|
85794
|
+
const listener = async (path45, newStats) => {
|
|
85436
85795
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
85437
85796
|
return;
|
|
85438
85797
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -85446,11 +85805,11 @@ class NodeFsHandler {
|
|
|
85446
85805
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
85447
85806
|
}
|
|
85448
85807
|
if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
|
|
85449
|
-
this.fsw._closeFile(
|
|
85808
|
+
this.fsw._closeFile(path45);
|
|
85450
85809
|
prevStats = newStats2;
|
|
85451
85810
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
85452
85811
|
if (closer2)
|
|
85453
|
-
this.fsw._addPathCloser(
|
|
85812
|
+
this.fsw._addPathCloser(path45, closer2);
|
|
85454
85813
|
} else {
|
|
85455
85814
|
prevStats = newStats2;
|
|
85456
85815
|
}
|
|
@@ -85474,7 +85833,7 @@ class NodeFsHandler {
|
|
|
85474
85833
|
}
|
|
85475
85834
|
return closer;
|
|
85476
85835
|
}
|
|
85477
|
-
async _handleSymlink(entry, directory,
|
|
85836
|
+
async _handleSymlink(entry, directory, path45, item) {
|
|
85478
85837
|
if (this.fsw.closed) {
|
|
85479
85838
|
return;
|
|
85480
85839
|
}
|
|
@@ -85484,7 +85843,7 @@ class NodeFsHandler {
|
|
|
85484
85843
|
this.fsw._incrReadyCount();
|
|
85485
85844
|
let linkPath;
|
|
85486
85845
|
try {
|
|
85487
|
-
linkPath = await fsrealpath(
|
|
85846
|
+
linkPath = await fsrealpath(path45);
|
|
85488
85847
|
} catch (e) {
|
|
85489
85848
|
this.fsw._emitReady();
|
|
85490
85849
|
return true;
|
|
@@ -85494,12 +85853,12 @@ class NodeFsHandler {
|
|
|
85494
85853
|
if (dir.has(item)) {
|
|
85495
85854
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
85496
85855
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
85497
|
-
this.fsw._emit(EV.CHANGE,
|
|
85856
|
+
this.fsw._emit(EV.CHANGE, path45, entry.stats);
|
|
85498
85857
|
}
|
|
85499
85858
|
} else {
|
|
85500
85859
|
dir.add(item);
|
|
85501
85860
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
85502
|
-
this.fsw._emit(EV.ADD,
|
|
85861
|
+
this.fsw._emit(EV.ADD, path45, entry.stats);
|
|
85503
85862
|
}
|
|
85504
85863
|
this.fsw._emitReady();
|
|
85505
85864
|
return true;
|
|
@@ -85528,9 +85887,9 @@ class NodeFsHandler {
|
|
|
85528
85887
|
return;
|
|
85529
85888
|
}
|
|
85530
85889
|
const item = entry.path;
|
|
85531
|
-
let
|
|
85890
|
+
let path45 = sysPath.join(directory, item);
|
|
85532
85891
|
current.add(item);
|
|
85533
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
85892
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path45, item)) {
|
|
85534
85893
|
return;
|
|
85535
85894
|
}
|
|
85536
85895
|
if (this.fsw.closed) {
|
|
@@ -85539,8 +85898,8 @@ class NodeFsHandler {
|
|
|
85539
85898
|
}
|
|
85540
85899
|
if (item === target || !target && !previous.has(item)) {
|
|
85541
85900
|
this.fsw._incrReadyCount();
|
|
85542
|
-
|
|
85543
|
-
this._addToNodeFs(
|
|
85901
|
+
path45 = sysPath.join(dir, sysPath.relative(dir, path45));
|
|
85902
|
+
this._addToNodeFs(path45, initialAdd, wh, depth + 1);
|
|
85544
85903
|
}
|
|
85545
85904
|
}).on(EV.ERROR, this._boundHandleError);
|
|
85546
85905
|
return new Promise((resolve7, reject) => {
|
|
@@ -85589,13 +85948,13 @@ class NodeFsHandler {
|
|
|
85589
85948
|
}
|
|
85590
85949
|
return closer;
|
|
85591
85950
|
}
|
|
85592
|
-
async _addToNodeFs(
|
|
85951
|
+
async _addToNodeFs(path45, initialAdd, priorWh, depth, target) {
|
|
85593
85952
|
const ready = this.fsw._emitReady;
|
|
85594
|
-
if (this.fsw._isIgnored(
|
|
85953
|
+
if (this.fsw._isIgnored(path45) || this.fsw.closed) {
|
|
85595
85954
|
ready();
|
|
85596
85955
|
return false;
|
|
85597
85956
|
}
|
|
85598
|
-
const wh = this.fsw._getWatchHelpers(
|
|
85957
|
+
const wh = this.fsw._getWatchHelpers(path45);
|
|
85599
85958
|
if (priorWh) {
|
|
85600
85959
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
85601
85960
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -85611,8 +85970,8 @@ class NodeFsHandler {
|
|
|
85611
85970
|
const follow = this.fsw.options.followSymlinks;
|
|
85612
85971
|
let closer;
|
|
85613
85972
|
if (stats.isDirectory()) {
|
|
85614
|
-
const absPath = sysPath.resolve(
|
|
85615
|
-
const targetPath = follow ? await fsrealpath(
|
|
85973
|
+
const absPath = sysPath.resolve(path45);
|
|
85974
|
+
const targetPath = follow ? await fsrealpath(path45) : path45;
|
|
85616
85975
|
if (this.fsw.closed)
|
|
85617
85976
|
return;
|
|
85618
85977
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -85622,29 +85981,29 @@ class NodeFsHandler {
|
|
|
85622
85981
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
85623
85982
|
}
|
|
85624
85983
|
} else if (stats.isSymbolicLink()) {
|
|
85625
|
-
const targetPath = follow ? await fsrealpath(
|
|
85984
|
+
const targetPath = follow ? await fsrealpath(path45) : path45;
|
|
85626
85985
|
if (this.fsw.closed)
|
|
85627
85986
|
return;
|
|
85628
85987
|
const parent = sysPath.dirname(wh.watchPath);
|
|
85629
85988
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
85630
85989
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
85631
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
85990
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path45, wh, targetPath);
|
|
85632
85991
|
if (this.fsw.closed)
|
|
85633
85992
|
return;
|
|
85634
85993
|
if (targetPath !== undefined) {
|
|
85635
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
85994
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path45), targetPath);
|
|
85636
85995
|
}
|
|
85637
85996
|
} else {
|
|
85638
85997
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
85639
85998
|
}
|
|
85640
85999
|
ready();
|
|
85641
86000
|
if (closer)
|
|
85642
|
-
this.fsw._addPathCloser(
|
|
86001
|
+
this.fsw._addPathCloser(path45, closer);
|
|
85643
86002
|
return false;
|
|
85644
86003
|
} catch (error) {
|
|
85645
86004
|
if (this.fsw._handleError(error)) {
|
|
85646
86005
|
ready();
|
|
85647
|
-
return
|
|
86006
|
+
return path45;
|
|
85648
86007
|
}
|
|
85649
86008
|
}
|
|
85650
86009
|
}
|
|
@@ -85687,26 +86046,26 @@ function createPattern(matcher) {
|
|
|
85687
86046
|
}
|
|
85688
86047
|
return () => false;
|
|
85689
86048
|
}
|
|
85690
|
-
function normalizePath2(
|
|
85691
|
-
if (typeof
|
|
86049
|
+
function normalizePath2(path45) {
|
|
86050
|
+
if (typeof path45 !== "string")
|
|
85692
86051
|
throw new Error("string expected");
|
|
85693
|
-
|
|
85694
|
-
|
|
86052
|
+
path45 = sysPath2.normalize(path45);
|
|
86053
|
+
path45 = path45.replace(/\\/g, "/");
|
|
85695
86054
|
let prepend = false;
|
|
85696
|
-
if (
|
|
86055
|
+
if (path45.startsWith("//"))
|
|
85697
86056
|
prepend = true;
|
|
85698
86057
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
85699
|
-
while (
|
|
85700
|
-
|
|
86058
|
+
while (path45.match(DOUBLE_SLASH_RE2))
|
|
86059
|
+
path45 = path45.replace(DOUBLE_SLASH_RE2, "/");
|
|
85701
86060
|
if (prepend)
|
|
85702
|
-
|
|
85703
|
-
return
|
|
86061
|
+
path45 = "/" + path45;
|
|
86062
|
+
return path45;
|
|
85704
86063
|
}
|
|
85705
86064
|
function matchPatterns(patterns, testString, stats) {
|
|
85706
|
-
const
|
|
86065
|
+
const path45 = normalizePath2(testString);
|
|
85707
86066
|
for (let index = 0;index < patterns.length; index++) {
|
|
85708
86067
|
const pattern = patterns[index];
|
|
85709
|
-
if (pattern(
|
|
86068
|
+
if (pattern(path45, stats)) {
|
|
85710
86069
|
return true;
|
|
85711
86070
|
}
|
|
85712
86071
|
}
|
|
@@ -85746,19 +86105,19 @@ var toUnix = (string) => {
|
|
|
85746
86105
|
}
|
|
85747
86106
|
return str;
|
|
85748
86107
|
};
|
|
85749
|
-
var normalizePathToUnix = (
|
|
85750
|
-
var normalizeIgnored = (cwd = "") => (
|
|
85751
|
-
if (typeof
|
|
85752
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
86108
|
+
var normalizePathToUnix = (path45) => toUnix(sysPath2.normalize(toUnix(path45)));
|
|
86109
|
+
var normalizeIgnored = (cwd = "") => (path45) => {
|
|
86110
|
+
if (typeof path45 === "string") {
|
|
86111
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path45) ? path45 : sysPath2.join(cwd, path45));
|
|
85753
86112
|
} else {
|
|
85754
|
-
return
|
|
86113
|
+
return path45;
|
|
85755
86114
|
}
|
|
85756
86115
|
};
|
|
85757
|
-
var getAbsolutePath = (
|
|
85758
|
-
if (sysPath2.isAbsolute(
|
|
85759
|
-
return
|
|
86116
|
+
var getAbsolutePath = (path45, cwd) => {
|
|
86117
|
+
if (sysPath2.isAbsolute(path45)) {
|
|
86118
|
+
return path45;
|
|
85760
86119
|
}
|
|
85761
|
-
return sysPath2.join(cwd,
|
|
86120
|
+
return sysPath2.join(cwd, path45);
|
|
85762
86121
|
};
|
|
85763
86122
|
var EMPTY_SET = Object.freeze(new Set);
|
|
85764
86123
|
|
|
@@ -85815,10 +86174,10 @@ var STAT_METHOD_F = "stat";
|
|
|
85815
86174
|
var STAT_METHOD_L = "lstat";
|
|
85816
86175
|
|
|
85817
86176
|
class WatchHelper {
|
|
85818
|
-
constructor(
|
|
86177
|
+
constructor(path45, follow, fsw) {
|
|
85819
86178
|
this.fsw = fsw;
|
|
85820
|
-
const watchPath =
|
|
85821
|
-
this.path =
|
|
86179
|
+
const watchPath = path45;
|
|
86180
|
+
this.path = path45 = path45.replace(REPLACER_RE, "");
|
|
85822
86181
|
this.watchPath = watchPath;
|
|
85823
86182
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
85824
86183
|
this.dirParts = [];
|
|
@@ -85931,20 +86290,20 @@ class FSWatcher extends EventEmitter2 {
|
|
|
85931
86290
|
this._closePromise = undefined;
|
|
85932
86291
|
let paths = unifyPaths(paths_);
|
|
85933
86292
|
if (cwd) {
|
|
85934
|
-
paths = paths.map((
|
|
85935
|
-
const absPath = getAbsolutePath(
|
|
86293
|
+
paths = paths.map((path45) => {
|
|
86294
|
+
const absPath = getAbsolutePath(path45, cwd);
|
|
85936
86295
|
return absPath;
|
|
85937
86296
|
});
|
|
85938
86297
|
}
|
|
85939
|
-
paths.forEach((
|
|
85940
|
-
this._removeIgnoredPath(
|
|
86298
|
+
paths.forEach((path45) => {
|
|
86299
|
+
this._removeIgnoredPath(path45);
|
|
85941
86300
|
});
|
|
85942
86301
|
this._userIgnored = undefined;
|
|
85943
86302
|
if (!this._readyCount)
|
|
85944
86303
|
this._readyCount = 0;
|
|
85945
86304
|
this._readyCount += paths.length;
|
|
85946
|
-
Promise.all(paths.map(async (
|
|
85947
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
86305
|
+
Promise.all(paths.map(async (path45) => {
|
|
86306
|
+
const res = await this._nodeFsHandler._addToNodeFs(path45, !_internal, undefined, 0, _origAdd);
|
|
85948
86307
|
if (res)
|
|
85949
86308
|
this._emitReady();
|
|
85950
86309
|
return res;
|
|
@@ -85963,17 +86322,17 @@ class FSWatcher extends EventEmitter2 {
|
|
|
85963
86322
|
return this;
|
|
85964
86323
|
const paths = unifyPaths(paths_);
|
|
85965
86324
|
const { cwd } = this.options;
|
|
85966
|
-
paths.forEach((
|
|
85967
|
-
if (!sysPath2.isAbsolute(
|
|
86325
|
+
paths.forEach((path45) => {
|
|
86326
|
+
if (!sysPath2.isAbsolute(path45) && !this._closers.has(path45)) {
|
|
85968
86327
|
if (cwd)
|
|
85969
|
-
|
|
85970
|
-
|
|
86328
|
+
path45 = sysPath2.join(cwd, path45);
|
|
86329
|
+
path45 = sysPath2.resolve(path45);
|
|
85971
86330
|
}
|
|
85972
|
-
this._closePath(
|
|
85973
|
-
this._addIgnoredPath(
|
|
85974
|
-
if (this._watched.has(
|
|
86331
|
+
this._closePath(path45);
|
|
86332
|
+
this._addIgnoredPath(path45);
|
|
86333
|
+
if (this._watched.has(path45)) {
|
|
85975
86334
|
this._addIgnoredPath({
|
|
85976
|
-
path:
|
|
86335
|
+
path: path45,
|
|
85977
86336
|
recursive: true
|
|
85978
86337
|
});
|
|
85979
86338
|
}
|
|
@@ -86022,38 +86381,38 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86022
86381
|
if (event !== EVENTS.ERROR)
|
|
86023
86382
|
this.emit(EVENTS.ALL, ...args);
|
|
86024
86383
|
}
|
|
86025
|
-
async _emit(event,
|
|
86384
|
+
async _emit(event, path45, stats) {
|
|
86026
86385
|
if (this.closed)
|
|
86027
86386
|
return;
|
|
86028
86387
|
const opts = this.options;
|
|
86029
86388
|
if (isWindows)
|
|
86030
|
-
|
|
86389
|
+
path45 = sysPath2.normalize(path45);
|
|
86031
86390
|
if (opts.cwd)
|
|
86032
|
-
|
|
86033
|
-
const args = [event,
|
|
86391
|
+
path45 = sysPath2.relative(opts.cwd, path45);
|
|
86392
|
+
const args = [event, path45];
|
|
86034
86393
|
if (stats != null)
|
|
86035
86394
|
args.push(stats);
|
|
86036
86395
|
const awf = opts.awaitWriteFinish;
|
|
86037
86396
|
let pw;
|
|
86038
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
86397
|
+
if (awf && (pw = this._pendingWrites.get(path45))) {
|
|
86039
86398
|
pw.lastChange = new Date;
|
|
86040
86399
|
return this;
|
|
86041
86400
|
}
|
|
86042
86401
|
if (opts.atomic) {
|
|
86043
86402
|
if (event === EVENTS.UNLINK) {
|
|
86044
|
-
this._pendingUnlinks.set(
|
|
86403
|
+
this._pendingUnlinks.set(path45, args);
|
|
86045
86404
|
setTimeout(() => {
|
|
86046
|
-
this._pendingUnlinks.forEach((entry,
|
|
86405
|
+
this._pendingUnlinks.forEach((entry, path46) => {
|
|
86047
86406
|
this.emit(...entry);
|
|
86048
86407
|
this.emit(EVENTS.ALL, ...entry);
|
|
86049
|
-
this._pendingUnlinks.delete(
|
|
86408
|
+
this._pendingUnlinks.delete(path46);
|
|
86050
86409
|
});
|
|
86051
86410
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
86052
86411
|
return this;
|
|
86053
86412
|
}
|
|
86054
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
86413
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path45)) {
|
|
86055
86414
|
event = args[0] = EVENTS.CHANGE;
|
|
86056
|
-
this._pendingUnlinks.delete(
|
|
86415
|
+
this._pendingUnlinks.delete(path45);
|
|
86057
86416
|
}
|
|
86058
86417
|
}
|
|
86059
86418
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -86071,16 +86430,16 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86071
86430
|
this.emitWithAll(event, args);
|
|
86072
86431
|
}
|
|
86073
86432
|
};
|
|
86074
|
-
this._awaitWriteFinish(
|
|
86433
|
+
this._awaitWriteFinish(path45, awf.stabilityThreshold, event, awfEmit);
|
|
86075
86434
|
return this;
|
|
86076
86435
|
}
|
|
86077
86436
|
if (event === EVENTS.CHANGE) {
|
|
86078
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
86437
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path45, 50);
|
|
86079
86438
|
if (isThrottled)
|
|
86080
86439
|
return this;
|
|
86081
86440
|
}
|
|
86082
86441
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
86083
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
86442
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path45) : path45;
|
|
86084
86443
|
let stats2;
|
|
86085
86444
|
try {
|
|
86086
86445
|
stats2 = await stat3(fullPath);
|
|
@@ -86099,23 +86458,23 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86099
86458
|
}
|
|
86100
86459
|
return error || this.closed;
|
|
86101
86460
|
}
|
|
86102
|
-
_throttle(actionType,
|
|
86461
|
+
_throttle(actionType, path45, timeout2) {
|
|
86103
86462
|
if (!this._throttled.has(actionType)) {
|
|
86104
86463
|
this._throttled.set(actionType, new Map);
|
|
86105
86464
|
}
|
|
86106
86465
|
const action = this._throttled.get(actionType);
|
|
86107
86466
|
if (!action)
|
|
86108
86467
|
throw new Error("invalid throttle");
|
|
86109
|
-
const actionPath = action.get(
|
|
86468
|
+
const actionPath = action.get(path45);
|
|
86110
86469
|
if (actionPath) {
|
|
86111
86470
|
actionPath.count++;
|
|
86112
86471
|
return false;
|
|
86113
86472
|
}
|
|
86114
86473
|
let timeoutObject;
|
|
86115
86474
|
const clear = () => {
|
|
86116
|
-
const item = action.get(
|
|
86475
|
+
const item = action.get(path45);
|
|
86117
86476
|
const count = item ? item.count : 0;
|
|
86118
|
-
action.delete(
|
|
86477
|
+
action.delete(path45);
|
|
86119
86478
|
clearTimeout(timeoutObject);
|
|
86120
86479
|
if (item)
|
|
86121
86480
|
clearTimeout(item.timeoutObject);
|
|
@@ -86123,50 +86482,50 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86123
86482
|
};
|
|
86124
86483
|
timeoutObject = setTimeout(clear, timeout2);
|
|
86125
86484
|
const thr = { timeoutObject, clear, count: 0 };
|
|
86126
|
-
action.set(
|
|
86485
|
+
action.set(path45, thr);
|
|
86127
86486
|
return thr;
|
|
86128
86487
|
}
|
|
86129
86488
|
_incrReadyCount() {
|
|
86130
86489
|
return this._readyCount++;
|
|
86131
86490
|
}
|
|
86132
|
-
_awaitWriteFinish(
|
|
86491
|
+
_awaitWriteFinish(path45, threshold, event, awfEmit) {
|
|
86133
86492
|
const awf = this.options.awaitWriteFinish;
|
|
86134
86493
|
if (typeof awf !== "object")
|
|
86135
86494
|
return;
|
|
86136
86495
|
const pollInterval = awf.pollInterval;
|
|
86137
86496
|
let timeoutHandler;
|
|
86138
|
-
let fullPath =
|
|
86139
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
86140
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
86497
|
+
let fullPath = path45;
|
|
86498
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path45)) {
|
|
86499
|
+
fullPath = sysPath2.join(this.options.cwd, path45);
|
|
86141
86500
|
}
|
|
86142
86501
|
const now = new Date;
|
|
86143
86502
|
const writes = this._pendingWrites;
|
|
86144
86503
|
function awaitWriteFinishFn(prevStat) {
|
|
86145
86504
|
statcb(fullPath, (err, curStat) => {
|
|
86146
|
-
if (err || !writes.has(
|
|
86505
|
+
if (err || !writes.has(path45)) {
|
|
86147
86506
|
if (err && err.code !== "ENOENT")
|
|
86148
86507
|
awfEmit(err);
|
|
86149
86508
|
return;
|
|
86150
86509
|
}
|
|
86151
86510
|
const now2 = Number(new Date);
|
|
86152
86511
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
86153
|
-
writes.get(
|
|
86512
|
+
writes.get(path45).lastChange = now2;
|
|
86154
86513
|
}
|
|
86155
|
-
const pw = writes.get(
|
|
86514
|
+
const pw = writes.get(path45);
|
|
86156
86515
|
const df = now2 - pw.lastChange;
|
|
86157
86516
|
if (df >= threshold) {
|
|
86158
|
-
writes.delete(
|
|
86517
|
+
writes.delete(path45);
|
|
86159
86518
|
awfEmit(undefined, curStat);
|
|
86160
86519
|
} else {
|
|
86161
86520
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
86162
86521
|
}
|
|
86163
86522
|
});
|
|
86164
86523
|
}
|
|
86165
|
-
if (!writes.has(
|
|
86166
|
-
writes.set(
|
|
86524
|
+
if (!writes.has(path45)) {
|
|
86525
|
+
writes.set(path45, {
|
|
86167
86526
|
lastChange: now,
|
|
86168
86527
|
cancelWait: () => {
|
|
86169
|
-
writes.delete(
|
|
86528
|
+
writes.delete(path45);
|
|
86170
86529
|
clearTimeout(timeoutHandler);
|
|
86171
86530
|
return event;
|
|
86172
86531
|
}
|
|
@@ -86174,8 +86533,8 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86174
86533
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
86175
86534
|
}
|
|
86176
86535
|
}
|
|
86177
|
-
_isIgnored(
|
|
86178
|
-
if (this.options.atomic && DOT_RE.test(
|
|
86536
|
+
_isIgnored(path45, stats) {
|
|
86537
|
+
if (this.options.atomic && DOT_RE.test(path45))
|
|
86179
86538
|
return true;
|
|
86180
86539
|
if (!this._userIgnored) {
|
|
86181
86540
|
const { cwd } = this.options;
|
|
@@ -86185,13 +86544,13 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86185
86544
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
86186
86545
|
this._userIgnored = anymatch(list, undefined);
|
|
86187
86546
|
}
|
|
86188
|
-
return this._userIgnored(
|
|
86547
|
+
return this._userIgnored(path45, stats);
|
|
86189
86548
|
}
|
|
86190
|
-
_isntIgnored(
|
|
86191
|
-
return !this._isIgnored(
|
|
86549
|
+
_isntIgnored(path45, stat4) {
|
|
86550
|
+
return !this._isIgnored(path45, stat4);
|
|
86192
86551
|
}
|
|
86193
|
-
_getWatchHelpers(
|
|
86194
|
-
return new WatchHelper(
|
|
86552
|
+
_getWatchHelpers(path45) {
|
|
86553
|
+
return new WatchHelper(path45, this.options.followSymlinks, this);
|
|
86195
86554
|
}
|
|
86196
86555
|
_getWatchedDir(directory) {
|
|
86197
86556
|
const dir = sysPath2.resolve(directory);
|
|
@@ -86205,57 +86564,57 @@ class FSWatcher extends EventEmitter2 {
|
|
|
86205
86564
|
return Boolean(Number(stats.mode) & 256);
|
|
86206
86565
|
}
|
|
86207
86566
|
_remove(directory, item, isDirectory2) {
|
|
86208
|
-
const
|
|
86209
|
-
const fullPath = sysPath2.resolve(
|
|
86210
|
-
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(
|
|
86211
|
-
if (!this._throttle("remove",
|
|
86567
|
+
const path45 = sysPath2.join(directory, item);
|
|
86568
|
+
const fullPath = sysPath2.resolve(path45);
|
|
86569
|
+
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path45) || this._watched.has(fullPath);
|
|
86570
|
+
if (!this._throttle("remove", path45, 100))
|
|
86212
86571
|
return;
|
|
86213
86572
|
if (!isDirectory2 && this._watched.size === 1) {
|
|
86214
86573
|
this.add(directory, item, true);
|
|
86215
86574
|
}
|
|
86216
|
-
const wp = this._getWatchedDir(
|
|
86575
|
+
const wp = this._getWatchedDir(path45);
|
|
86217
86576
|
const nestedDirectoryChildren = wp.getChildren();
|
|
86218
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
86577
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path45, nested));
|
|
86219
86578
|
const parent = this._getWatchedDir(directory);
|
|
86220
86579
|
const wasTracked = parent.has(item);
|
|
86221
86580
|
parent.remove(item);
|
|
86222
86581
|
if (this._symlinkPaths.has(fullPath)) {
|
|
86223
86582
|
this._symlinkPaths.delete(fullPath);
|
|
86224
86583
|
}
|
|
86225
|
-
let relPath =
|
|
86584
|
+
let relPath = path45;
|
|
86226
86585
|
if (this.options.cwd)
|
|
86227
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
86586
|
+
relPath = sysPath2.relative(this.options.cwd, path45);
|
|
86228
86587
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
86229
86588
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
86230
86589
|
if (event === EVENTS.ADD)
|
|
86231
86590
|
return;
|
|
86232
86591
|
}
|
|
86233
|
-
this._watched.delete(
|
|
86592
|
+
this._watched.delete(path45);
|
|
86234
86593
|
this._watched.delete(fullPath);
|
|
86235
86594
|
const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
86236
|
-
if (wasTracked && !this._isIgnored(
|
|
86237
|
-
this._emit(eventName,
|
|
86238
|
-
this._closePath(
|
|
86595
|
+
if (wasTracked && !this._isIgnored(path45))
|
|
86596
|
+
this._emit(eventName, path45);
|
|
86597
|
+
this._closePath(path45);
|
|
86239
86598
|
}
|
|
86240
|
-
_closePath(
|
|
86241
|
-
this._closeFile(
|
|
86242
|
-
const dir = sysPath2.dirname(
|
|
86243
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
86599
|
+
_closePath(path45) {
|
|
86600
|
+
this._closeFile(path45);
|
|
86601
|
+
const dir = sysPath2.dirname(path45);
|
|
86602
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path45));
|
|
86244
86603
|
}
|
|
86245
|
-
_closeFile(
|
|
86246
|
-
const closers = this._closers.get(
|
|
86604
|
+
_closeFile(path45) {
|
|
86605
|
+
const closers = this._closers.get(path45);
|
|
86247
86606
|
if (!closers)
|
|
86248
86607
|
return;
|
|
86249
86608
|
closers.forEach((closer) => closer());
|
|
86250
|
-
this._closers.delete(
|
|
86609
|
+
this._closers.delete(path45);
|
|
86251
86610
|
}
|
|
86252
|
-
_addPathCloser(
|
|
86611
|
+
_addPathCloser(path45, closer) {
|
|
86253
86612
|
if (!closer)
|
|
86254
86613
|
return;
|
|
86255
|
-
let list = this._closers.get(
|
|
86614
|
+
let list = this._closers.get(path45);
|
|
86256
86615
|
if (!list) {
|
|
86257
86616
|
list = [];
|
|
86258
|
-
this._closers.set(
|
|
86617
|
+
this._closers.set(path45, list);
|
|
86259
86618
|
}
|
|
86260
86619
|
list.push(closer);
|
|
86261
86620
|
}
|
|
@@ -86285,8 +86644,8 @@ function watch(paths, options = {}) {
|
|
|
86285
86644
|
|
|
86286
86645
|
// lib/shared/push-snippet.ts
|
|
86287
86646
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
86288
|
-
import * as
|
|
86289
|
-
import * as
|
|
86647
|
+
import * as fs45 from "node:fs";
|
|
86648
|
+
import * as path47 from "node:path";
|
|
86290
86649
|
import Debug2 from "debug";
|
|
86291
86650
|
|
|
86292
86651
|
// lib/utils/validate-package-name.ts
|
|
@@ -86304,7 +86663,7 @@ var validatePackageName = (name) => {
|
|
|
86304
86663
|
};
|
|
86305
86664
|
|
|
86306
86665
|
// cli/dev/get-package-file-paths.ts
|
|
86307
|
-
import * as
|
|
86666
|
+
import * as path45 from "node:path";
|
|
86308
86667
|
var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
86309
86668
|
const ignorePatterns = [
|
|
86310
86669
|
...DEFAULT_IGNORED_PATTERNS,
|
|
@@ -86315,7 +86674,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
86315
86674
|
ignore: ignorePatterns
|
|
86316
86675
|
});
|
|
86317
86676
|
fileNames.sort();
|
|
86318
|
-
return fileNames.map((fileName) =>
|
|
86677
|
+
return fileNames.map((fileName) => path45.join(projectDir, fileName));
|
|
86319
86678
|
};
|
|
86320
86679
|
|
|
86321
86680
|
// lib/utils/check-org-access.ts
|
|
@@ -86331,7 +86690,7 @@ var checkOrgAccess = async (ky2, orgTscircuitHandle) => {
|
|
|
86331
86690
|
};
|
|
86332
86691
|
|
|
86333
86692
|
// lib/shared/is-binary-file.ts
|
|
86334
|
-
import * as
|
|
86693
|
+
import * as path46 from "node:path";
|
|
86335
86694
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
86336
86695
|
".glb",
|
|
86337
86696
|
".gltf",
|
|
@@ -86347,7 +86706,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
86347
86706
|
".tar"
|
|
86348
86707
|
]);
|
|
86349
86708
|
var isBinaryFile = (filePath) => {
|
|
86350
|
-
const ext =
|
|
86709
|
+
const ext = path46.extname(filePath).toLowerCase();
|
|
86351
86710
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
86352
86711
|
};
|
|
86353
86712
|
|
|
@@ -86373,8 +86732,8 @@ var debug2 = Debug2("tsci:push-snippet");
|
|
|
86373
86732
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
86374
86733
|
const zip = new import_jszip3.default;
|
|
86375
86734
|
for (const fullFilePath of filePaths) {
|
|
86376
|
-
const relativeFilePath =
|
|
86377
|
-
zip.file(relativeFilePath,
|
|
86735
|
+
const relativeFilePath = path47.relative(projectDir, fullFilePath);
|
|
86736
|
+
zip.file(relativeFilePath, fs45.readFileSync(fullFilePath));
|
|
86378
86737
|
}
|
|
86379
86738
|
const archive = await zip.generateAsync({
|
|
86380
86739
|
type: "uint8array",
|
|
@@ -86411,24 +86770,24 @@ var pushSnippet = async ({
|
|
|
86411
86770
|
return onExit(1);
|
|
86412
86771
|
}
|
|
86413
86772
|
const packageJsonPath = [
|
|
86414
|
-
|
|
86415
|
-
|
|
86416
|
-
].find((
|
|
86417
|
-
const projectDir = packageJsonPath ?
|
|
86773
|
+
path47.resolve(path47.join(path47.dirname(snippetFilePath), "package.json")),
|
|
86774
|
+
path47.resolve(path47.join(process.cwd(), "package.json"))
|
|
86775
|
+
].find((path48) => fs45.existsSync(path48));
|
|
86776
|
+
const projectDir = packageJsonPath ? path47.dirname(packageJsonPath) : path47.dirname(snippetFilePath);
|
|
86418
86777
|
if (!packageJsonPath) {
|
|
86419
86778
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
86420
86779
|
return onExit(1);
|
|
86421
86780
|
}
|
|
86422
86781
|
let packageJson = {};
|
|
86423
|
-
if (
|
|
86782
|
+
if (fs45.existsSync(packageJsonPath)) {
|
|
86424
86783
|
try {
|
|
86425
|
-
packageJson = JSON.parse(
|
|
86784
|
+
packageJson = JSON.parse(fs45.readFileSync(packageJsonPath).toString());
|
|
86426
86785
|
} catch {
|
|
86427
86786
|
onError("Invalid package.json");
|
|
86428
86787
|
return onExit(1);
|
|
86429
86788
|
}
|
|
86430
86789
|
}
|
|
86431
|
-
if (!
|
|
86790
|
+
if (!fs45.existsSync(snippetFilePath)) {
|
|
86432
86791
|
onError(`File not found: ${snippetFilePath}`);
|
|
86433
86792
|
return onExit(1);
|
|
86434
86793
|
}
|
|
@@ -86469,7 +86828,7 @@ var pushSnippet = async ({
|
|
|
86469
86828
|
}
|
|
86470
86829
|
unscopedPackageName = inputName;
|
|
86471
86830
|
packageJson.name = `@tsci/${currentUsername}.${unscopedPackageName}`;
|
|
86472
|
-
|
|
86831
|
+
fs45.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
86473
86832
|
}
|
|
86474
86833
|
let accountName = currentUsername;
|
|
86475
86834
|
if (packageJsonAuthor && currentUsername !== packageJsonAuthor) {
|
|
@@ -86500,7 +86859,7 @@ var pushSnippet = async ({
|
|
|
86500
86859
|
const updatePackageJsonVersion = (newVersion) => {
|
|
86501
86860
|
try {
|
|
86502
86861
|
packageJson.version = newVersion ?? `${packageVersion}`;
|
|
86503
|
-
|
|
86862
|
+
fs45.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
86504
86863
|
} catch (error) {
|
|
86505
86864
|
onError(`Failed to update package.json version: ${error}`);
|
|
86506
86865
|
}
|
|
@@ -86608,7 +86967,7 @@ var pushSnippet = async ({
|
|
|
86608
86967
|
json: archivePayload
|
|
86609
86968
|
});
|
|
86610
86969
|
for (const fullFilePath of filePaths) {
|
|
86611
|
-
const relativeFilePath =
|
|
86970
|
+
const relativeFilePath = path47.relative(projectDir, fullFilePath);
|
|
86612
86971
|
uploadResults.succeeded.push(relativeFilePath);
|
|
86613
86972
|
}
|
|
86614
86973
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -86618,8 +86977,8 @@ var pushSnippet = async ({
|
|
|
86618
86977
|
}
|
|
86619
86978
|
if (uploadResults.succeeded.length === 0) {
|
|
86620
86979
|
for (const fullFilePath of filePaths) {
|
|
86621
|
-
const relativeFilePath =
|
|
86622
|
-
const fileBuffer =
|
|
86980
|
+
const relativeFilePath = path47.relative(projectDir, fullFilePath);
|
|
86981
|
+
const fileBuffer = fs45.readFileSync(fullFilePath);
|
|
86623
86982
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
86624
86983
|
const payload = {
|
|
86625
86984
|
file_path: relativeFilePath,
|
|
@@ -86690,16 +87049,16 @@ import Debug3 from "debug";
|
|
|
86690
87049
|
|
|
86691
87050
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
86692
87051
|
import * as ts from "typescript";
|
|
86693
|
-
import * as
|
|
86694
|
-
import * as
|
|
87052
|
+
import * as path48 from "path";
|
|
87053
|
+
import * as fs46 from "fs";
|
|
86695
87054
|
function getAllDependencyPackages(projectDir) {
|
|
86696
|
-
const packageJsonPath =
|
|
87055
|
+
const packageJsonPath = path48.join(projectDir, "package.json");
|
|
86697
87056
|
const allPackages = new Set;
|
|
86698
|
-
if (!
|
|
87057
|
+
if (!fs46.existsSync(packageJsonPath)) {
|
|
86699
87058
|
return allPackages;
|
|
86700
87059
|
}
|
|
86701
87060
|
try {
|
|
86702
|
-
const packageJson = JSON.parse(
|
|
87061
|
+
const packageJson = JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8"));
|
|
86703
87062
|
const deps = packageJson.dependencies || {};
|
|
86704
87063
|
const devDeps = packageJson.devDependencies || {};
|
|
86705
87064
|
for (const packageName of Object.keys(deps)) {
|
|
@@ -86714,11 +87073,11 @@ function getAllDependencyPackages(projectDir) {
|
|
|
86714
87073
|
return allPackages;
|
|
86715
87074
|
}
|
|
86716
87075
|
function getNodeModuleImports(filePath) {
|
|
86717
|
-
const absolutePath =
|
|
86718
|
-
if (!
|
|
87076
|
+
const absolutePath = path48.resolve(filePath);
|
|
87077
|
+
if (!fs46.existsSync(absolutePath)) {
|
|
86719
87078
|
return [];
|
|
86720
87079
|
}
|
|
86721
|
-
const content =
|
|
87080
|
+
const content = fs46.readFileSync(absolutePath, "utf-8");
|
|
86722
87081
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
86723
87082
|
const imports = new Set;
|
|
86724
87083
|
function visit(node) {
|
|
@@ -86768,17 +87127,17 @@ function resolveNodeModuleImport({
|
|
|
86768
87127
|
}) {
|
|
86769
87128
|
const packageName = getPackageNameFromImport(importPath);
|
|
86770
87129
|
const searchPaths = [
|
|
86771
|
-
|
|
87130
|
+
path48.join(projectDir, "node_modules", packageName)
|
|
86772
87131
|
];
|
|
86773
87132
|
if (searchFromDir) {
|
|
86774
|
-
let currentDir =
|
|
86775
|
-
const projectDirNormalized =
|
|
87133
|
+
let currentDir = path48.dirname(searchFromDir);
|
|
87134
|
+
const projectDirNormalized = path48.normalize(projectDir);
|
|
86776
87135
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
86777
|
-
const candidatePath =
|
|
87136
|
+
const candidatePath = path48.join(currentDir, "node_modules", packageName);
|
|
86778
87137
|
if (!searchPaths.includes(candidatePath)) {
|
|
86779
87138
|
searchPaths.push(candidatePath);
|
|
86780
87139
|
}
|
|
86781
|
-
const parentDir =
|
|
87140
|
+
const parentDir = path48.dirname(currentDir);
|
|
86782
87141
|
if (parentDir === currentDir)
|
|
86783
87142
|
break;
|
|
86784
87143
|
currentDir = parentDir;
|
|
@@ -86786,7 +87145,7 @@ function resolveNodeModuleImport({
|
|
|
86786
87145
|
}
|
|
86787
87146
|
let packageDir;
|
|
86788
87147
|
for (const candidatePath of searchPaths) {
|
|
86789
|
-
if (
|
|
87148
|
+
if (fs46.existsSync(candidatePath)) {
|
|
86790
87149
|
packageDir = candidatePath;
|
|
86791
87150
|
break;
|
|
86792
87151
|
}
|
|
@@ -86794,25 +87153,25 @@ function resolveNodeModuleImport({
|
|
|
86794
87153
|
if (!packageDir) {
|
|
86795
87154
|
return [];
|
|
86796
87155
|
}
|
|
86797
|
-
const packageJsonPath =
|
|
86798
|
-
const hasPackageJson =
|
|
86799
|
-
const packageJson = hasPackageJson ? JSON.parse(
|
|
87156
|
+
const packageJsonPath = path48.join(packageDir, "package.json");
|
|
87157
|
+
const hasPackageJson = fs46.existsSync(packageJsonPath);
|
|
87158
|
+
const packageJson = hasPackageJson ? JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8")) : null;
|
|
86800
87159
|
const resolvedFiles = [];
|
|
86801
87160
|
if (importPath !== packageName) {
|
|
86802
87161
|
const subpath = importPath.slice(packageName.length + 1);
|
|
86803
87162
|
const possiblePaths = [
|
|
86804
|
-
|
|
86805
|
-
|
|
86806
|
-
|
|
86807
|
-
|
|
86808
|
-
|
|
86809
|
-
|
|
86810
|
-
|
|
86811
|
-
|
|
86812
|
-
|
|
87163
|
+
path48.join(packageDir, subpath),
|
|
87164
|
+
path48.join(packageDir, `${subpath}.js`),
|
|
87165
|
+
path48.join(packageDir, `${subpath}.mjs`),
|
|
87166
|
+
path48.join(packageDir, `${subpath}.ts`),
|
|
87167
|
+
path48.join(packageDir, `${subpath}.tsx`),
|
|
87168
|
+
path48.join(packageDir, subpath, "index.js"),
|
|
87169
|
+
path48.join(packageDir, subpath, "index.mjs"),
|
|
87170
|
+
path48.join(packageDir, subpath, "index.ts"),
|
|
87171
|
+
path48.join(packageDir, subpath, "index.tsx")
|
|
86813
87172
|
];
|
|
86814
87173
|
for (const p of possiblePaths) {
|
|
86815
|
-
if (
|
|
87174
|
+
if (fs46.existsSync(p) && fs46.statSync(p).isFile()) {
|
|
86816
87175
|
resolvedFiles.push(p);
|
|
86817
87176
|
break;
|
|
86818
87177
|
}
|
|
@@ -86844,25 +87203,25 @@ function resolveNodeModuleImport({
|
|
|
86844
87203
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
86845
87204
|
].filter((entry) => typeof entry === "string");
|
|
86846
87205
|
for (const entry of entryPoints) {
|
|
86847
|
-
const entryPath =
|
|
86848
|
-
if (
|
|
87206
|
+
const entryPath = path48.join(packageDir, entry);
|
|
87207
|
+
if (fs46.existsSync(entryPath) && fs46.statSync(entryPath).isFile()) {
|
|
86849
87208
|
resolvedFiles.push(entryPath);
|
|
86850
87209
|
}
|
|
86851
87210
|
}
|
|
86852
87211
|
if (resolvedFiles.length === 0) {
|
|
86853
87212
|
const fallbackPaths = [
|
|
86854
|
-
|
|
86855
|
-
|
|
86856
|
-
|
|
86857
|
-
|
|
86858
|
-
|
|
86859
|
-
|
|
86860
|
-
|
|
86861
|
-
|
|
86862
|
-
|
|
87213
|
+
path48.join(packageDir, "index.js"),
|
|
87214
|
+
path48.join(packageDir, "index.mjs"),
|
|
87215
|
+
path48.join(packageDir, "index.ts"),
|
|
87216
|
+
path48.join(packageDir, "index.tsx"),
|
|
87217
|
+
path48.join(packageDir, "dist", "index.js"),
|
|
87218
|
+
path48.join(packageDir, "dist", "index.mjs"),
|
|
87219
|
+
path48.join(packageDir, "lib", "index.js"),
|
|
87220
|
+
path48.join(packageDir, "src", "index.ts"),
|
|
87221
|
+
path48.join(packageDir, "src", "index.tsx")
|
|
86863
87222
|
];
|
|
86864
87223
|
for (const p of fallbackPaths) {
|
|
86865
|
-
if (
|
|
87224
|
+
if (fs46.existsSync(p) && fs46.statSync(p).isFile()) {
|
|
86866
87225
|
resolvedFiles.push(p);
|
|
86867
87226
|
break;
|
|
86868
87227
|
}
|
|
@@ -86900,12 +87259,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
86900
87259
|
}
|
|
86901
87260
|
}
|
|
86902
87261
|
function getLocalDependencies(filePath) {
|
|
86903
|
-
const absolutePath =
|
|
86904
|
-
const baseDir =
|
|
86905
|
-
if (!
|
|
87262
|
+
const absolutePath = path48.resolve(filePath);
|
|
87263
|
+
const baseDir = path48.dirname(absolutePath);
|
|
87264
|
+
if (!fs46.existsSync(absolutePath)) {
|
|
86906
87265
|
return [];
|
|
86907
87266
|
}
|
|
86908
|
-
const content =
|
|
87267
|
+
const content = fs46.readFileSync(absolutePath, "utf-8");
|
|
86909
87268
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
86910
87269
|
const dependencies2 = [];
|
|
86911
87270
|
function visit(node) {
|
|
@@ -86927,20 +87286,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
86927
87286
|
}
|
|
86928
87287
|
function resolveLocalImport(importPath, baseDir) {
|
|
86929
87288
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
86930
|
-
const resolvedPath =
|
|
86931
|
-
if (
|
|
87289
|
+
const resolvedPath = path48.resolve(baseDir, importPath);
|
|
87290
|
+
if (fs46.existsSync(resolvedPath) && fs46.statSync(resolvedPath).isFile()) {
|
|
86932
87291
|
return resolvedPath;
|
|
86933
87292
|
}
|
|
86934
87293
|
for (const ext of extensions) {
|
|
86935
87294
|
const pathWithExt = resolvedPath + ext;
|
|
86936
|
-
if (
|
|
87295
|
+
if (fs46.existsSync(pathWithExt)) {
|
|
86937
87296
|
return pathWithExt;
|
|
86938
87297
|
}
|
|
86939
87298
|
}
|
|
86940
|
-
if (
|
|
87299
|
+
if (fs46.existsSync(resolvedPath) && fs46.statSync(resolvedPath).isDirectory()) {
|
|
86941
87300
|
for (const ext of extensions) {
|
|
86942
|
-
const indexPath =
|
|
86943
|
-
if (
|
|
87301
|
+
const indexPath = path48.join(resolvedPath, `index${ext}`);
|
|
87302
|
+
if (fs46.existsSync(indexPath)) {
|
|
86944
87303
|
return indexPath;
|
|
86945
87304
|
}
|
|
86946
87305
|
}
|
|
@@ -86965,12 +87324,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
86965
87324
|
function collectLocalPackageFiles(packageDir) {
|
|
86966
87325
|
const buildDirs = ["dist", "build"];
|
|
86967
87326
|
for (const dirName of buildDirs) {
|
|
86968
|
-
const dirPath =
|
|
86969
|
-
if (
|
|
87327
|
+
const dirPath = path48.join(packageDir, dirName);
|
|
87328
|
+
if (fs46.existsSync(dirPath)) {
|
|
86970
87329
|
const files = walkDirectory(dirPath, new Set);
|
|
86971
87330
|
if (files.length > 0) {
|
|
86972
|
-
const packageJsonPath =
|
|
86973
|
-
if (
|
|
87331
|
+
const packageJsonPath = path48.join(packageDir, "package.json");
|
|
87332
|
+
if (fs46.existsSync(packageJsonPath)) {
|
|
86974
87333
|
files.push(packageJsonPath);
|
|
86975
87334
|
}
|
|
86976
87335
|
return files;
|
|
@@ -86981,11 +87340,11 @@ function collectLocalPackageFiles(packageDir) {
|
|
|
86981
87340
|
}
|
|
86982
87341
|
function walkDirectory(dir, excludedDirs) {
|
|
86983
87342
|
const files = [];
|
|
86984
|
-
if (!
|
|
87343
|
+
if (!fs46.existsSync(dir))
|
|
86985
87344
|
return files;
|
|
86986
|
-
const entries =
|
|
87345
|
+
const entries = fs46.readdirSync(dir, { withFileTypes: true });
|
|
86987
87346
|
for (const entry of entries) {
|
|
86988
|
-
const fullPath =
|
|
87347
|
+
const fullPath = path48.join(dir, entry.name);
|
|
86989
87348
|
if (entry.isDirectory()) {
|
|
86990
87349
|
if (excludedDirs.has(entry.name)) {
|
|
86991
87350
|
continue;
|
|
@@ -87046,13 +87405,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
87046
87405
|
processedPackages.add(packageName);
|
|
87047
87406
|
if (resolvedFiles.length > 0) {
|
|
87048
87407
|
const firstResolvedFile = resolvedFiles[0];
|
|
87049
|
-
let packageDir =
|
|
87408
|
+
let packageDir = path48.dirname(firstResolvedFile);
|
|
87050
87409
|
let hasPackageJson = false;
|
|
87051
87410
|
while (packageDir.includes("node_modules")) {
|
|
87052
|
-
const packageJsonPath =
|
|
87053
|
-
if (
|
|
87411
|
+
const packageJsonPath = path48.join(packageDir, "package.json");
|
|
87412
|
+
if (fs46.existsSync(packageJsonPath)) {
|
|
87054
87413
|
try {
|
|
87055
|
-
const pkgJson = JSON.parse(
|
|
87414
|
+
const pkgJson = JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8"));
|
|
87056
87415
|
if (pkgJson.name === packageName) {
|
|
87057
87416
|
hasPackageJson = true;
|
|
87058
87417
|
break;
|
|
@@ -87060,15 +87419,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
87060
87419
|
} catch {}
|
|
87061
87420
|
}
|
|
87062
87421
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
87063
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
87422
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path48.sep))) {
|
|
87064
87423
|
break;
|
|
87065
87424
|
}
|
|
87066
|
-
const parentDir =
|
|
87425
|
+
const parentDir = path48.dirname(packageDir);
|
|
87067
87426
|
if (parentDir === packageDir)
|
|
87068
87427
|
break;
|
|
87069
87428
|
packageDir = parentDir;
|
|
87070
87429
|
}
|
|
87071
|
-
if (
|
|
87430
|
+
if (fs46.existsSync(packageDir)) {
|
|
87072
87431
|
if (hasPackageJson) {
|
|
87073
87432
|
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
87074
87433
|
packageFiles.forEach((file) => allFiles.add(file));
|
|
@@ -87113,7 +87472,7 @@ class DevServer {
|
|
|
87113
87472
|
}) {
|
|
87114
87473
|
this.port = port;
|
|
87115
87474
|
this.componentFilePath = componentFilePath;
|
|
87116
|
-
this.projectDir = projectDir ??
|
|
87475
|
+
this.projectDir = projectDir ?? path49.dirname(componentFilePath);
|
|
87117
87476
|
this.kicadPcm = kicadPcm ?? false;
|
|
87118
87477
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
87119
87478
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
@@ -87124,7 +87483,7 @@ class DevServer {
|
|
|
87124
87483
|
async start() {
|
|
87125
87484
|
const { server } = await createHttpServer({
|
|
87126
87485
|
port: this.port,
|
|
87127
|
-
defaultMainComponentPath:
|
|
87486
|
+
defaultMainComponentPath: path49.relative(this.projectDir, this.componentFilePath),
|
|
87128
87487
|
kicadPcm: this.kicadPcm,
|
|
87129
87488
|
projectDir: this.projectDir,
|
|
87130
87489
|
entryFile: this.componentFilePath
|
|
@@ -87140,7 +87499,7 @@ class DevServer {
|
|
|
87140
87499
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
87141
87500
|
persistent: true,
|
|
87142
87501
|
ignoreInitial: true,
|
|
87143
|
-
ignored: (p) => shouldIgnorePath(
|
|
87502
|
+
ignored: (p) => shouldIgnorePath(path49.relative(this.projectDir, p), this.ignoredFiles)
|
|
87144
87503
|
});
|
|
87145
87504
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
87146
87505
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -87155,27 +87514,27 @@ class DevServer {
|
|
|
87155
87514
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
87156
87515
|
searchParams: { file_path: ev.file_path }
|
|
87157
87516
|
}).json();
|
|
87158
|
-
const fullPath =
|
|
87159
|
-
const dirPath =
|
|
87160
|
-
if (!
|
|
87161
|
-
|
|
87517
|
+
const fullPath = path49.join(this.projectDir, ev.file_path);
|
|
87518
|
+
const dirPath = path49.dirname(fullPath);
|
|
87519
|
+
if (!fs47.existsSync(dirPath)) {
|
|
87520
|
+
fs47.mkdirSync(dirPath, { recursive: true });
|
|
87162
87521
|
}
|
|
87163
87522
|
if (file.binary_content_b64) {
|
|
87164
87523
|
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
87165
|
-
|
|
87524
|
+
fs47.writeFileSync(fullPath, decodedContent);
|
|
87166
87525
|
} else {
|
|
87167
|
-
|
|
87526
|
+
fs47.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
87168
87527
|
}
|
|
87169
87528
|
}
|
|
87170
87529
|
async handleFileDeletedEventFromServer(ev) {
|
|
87171
|
-
const fullPath =
|
|
87172
|
-
if (
|
|
87530
|
+
const fullPath = path49.join(this.projectDir, ev.file_path);
|
|
87531
|
+
if (fs47.existsSync(fullPath)) {
|
|
87173
87532
|
debug3(`Deleting file ${ev.file_path} from filesystem`);
|
|
87174
|
-
|
|
87533
|
+
fs47.unlinkSync(fullPath);
|
|
87175
87534
|
}
|
|
87176
87535
|
}
|
|
87177
87536
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
87178
|
-
const relativeFilePath =
|
|
87537
|
+
const relativeFilePath = path49.relative(this.projectDir, absoluteFilePath);
|
|
87179
87538
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
87180
87539
|
return;
|
|
87181
87540
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -87190,14 +87549,14 @@ class DevServer {
|
|
|
87190
87549
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
87191
87550
|
}
|
|
87192
87551
|
async checkAndUploadNewNodeModules(filePath) {
|
|
87193
|
-
const ext =
|
|
87552
|
+
const ext = path49.extname(filePath).toLowerCase();
|
|
87194
87553
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
87195
87554
|
if (!isSourceFile)
|
|
87196
87555
|
return;
|
|
87197
87556
|
try {
|
|
87198
87557
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
87199
87558
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
87200
|
-
const relativePath =
|
|
87559
|
+
const relativePath = path49.relative(this.projectDir, file);
|
|
87201
87560
|
return !this.uploadedNodeModules.has(relativePath);
|
|
87202
87561
|
});
|
|
87203
87562
|
if (newFiles.length === 0)
|
|
@@ -87210,7 +87569,7 @@ class DevServer {
|
|
|
87210
87569
|
}
|
|
87211
87570
|
}
|
|
87212
87571
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
87213
|
-
const relativeFilePath =
|
|
87572
|
+
const relativeFilePath = path49.relative(this.projectDir, absoluteFilePath);
|
|
87214
87573
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
87215
87574
|
return;
|
|
87216
87575
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -87248,8 +87607,8 @@ class DevServer {
|
|
|
87248
87607
|
debug3(`Successfully deleted file ${relativeFilePath} from server`);
|
|
87249
87608
|
}
|
|
87250
87609
|
async handleFileRename(oldPath, newPath) {
|
|
87251
|
-
const oldRelativePath =
|
|
87252
|
-
const newRelativePath =
|
|
87610
|
+
const oldRelativePath = path49.relative(this.projectDir, oldPath);
|
|
87611
|
+
const newRelativePath = path49.relative(this.projectDir, newPath);
|
|
87253
87612
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
87254
87613
|
return;
|
|
87255
87614
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -87267,7 +87626,7 @@ class DevServer {
|
|
|
87267
87626
|
});
|
|
87268
87627
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
87269
87628
|
for (const filePath of filePaths) {
|
|
87270
|
-
const relativeFilePath =
|
|
87629
|
+
const relativeFilePath = path49.relative(this.projectDir, filePath);
|
|
87271
87630
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
87272
87631
|
await this.postFileUpsert({
|
|
87273
87632
|
filePath: relativeFilePath,
|
|
@@ -87299,7 +87658,7 @@ class DevServer {
|
|
|
87299
87658
|
}
|
|
87300
87659
|
async uploadNodeModuleFiles(files) {
|
|
87301
87660
|
for (const nodeModuleFile of files) {
|
|
87302
|
-
const relativeFilePath =
|
|
87661
|
+
const relativeFilePath = path49.relative(this.projectDir, nodeModuleFile);
|
|
87303
87662
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
87304
87663
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
87305
87664
|
await this.postFileUpsert({
|
|
@@ -87357,12 +87716,12 @@ class DevServer {
|
|
|
87357
87716
|
await this.filesystemWatcher?.close();
|
|
87358
87717
|
}
|
|
87359
87718
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
87360
|
-
const ext =
|
|
87719
|
+
const ext = path49.extname(relativeFilePath).toLowerCase();
|
|
87361
87720
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
87362
|
-
const fileBuffer =
|
|
87721
|
+
const fileBuffer = fs47.readFileSync(absoluteFilePath);
|
|
87363
87722
|
return { binary_content_b64: fileBuffer.toString("base64") };
|
|
87364
87723
|
}
|
|
87365
|
-
return { text_content:
|
|
87724
|
+
return { text_content: fs47.readFileSync(absoluteFilePath, "utf-8") };
|
|
87366
87725
|
}
|
|
87367
87726
|
async handleInstallPackage(full_package_name) {
|
|
87368
87727
|
const postEvent = async (event, message) => {
|
|
@@ -87392,10 +87751,10 @@ class DevServer {
|
|
|
87392
87751
|
}
|
|
87393
87752
|
|
|
87394
87753
|
// cli/dev/resolve-dev-target.ts
|
|
87395
|
-
import * as
|
|
87396
|
-
import * as
|
|
87754
|
+
import * as fs48 from "node:fs";
|
|
87755
|
+
import * as path50 from "node:path";
|
|
87397
87756
|
var findSelectableFiles = (projectDir) => {
|
|
87398
|
-
const boardFiles = findBoardFiles({ projectDir }).filter((file) =>
|
|
87757
|
+
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs48.existsSync(file)).sort();
|
|
87399
87758
|
if (boardFiles.length > 0) {
|
|
87400
87759
|
return boardFiles;
|
|
87401
87760
|
}
|
|
@@ -87403,7 +87762,7 @@ var findSelectableFiles = (projectDir) => {
|
|
|
87403
87762
|
cwd: projectDir,
|
|
87404
87763
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
87405
87764
|
});
|
|
87406
|
-
return files.map((file) =>
|
|
87765
|
+
return files.map((file) => path50.resolve(projectDir, file)).filter((file) => fs48.existsSync(file)).sort();
|
|
87407
87766
|
};
|
|
87408
87767
|
var isValidDevFile = (filePath) => {
|
|
87409
87768
|
return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
|
|
@@ -87411,18 +87770,18 @@ var isValidDevFile = (filePath) => {
|
|
|
87411
87770
|
var resolveDevTarget = async (file) => {
|
|
87412
87771
|
let projectDir = process.cwd();
|
|
87413
87772
|
if (file) {
|
|
87414
|
-
const resolvedPath =
|
|
87415
|
-
if (
|
|
87773
|
+
const resolvedPath = path50.resolve(file);
|
|
87774
|
+
if (fs48.existsSync(resolvedPath) && fs48.statSync(resolvedPath).isDirectory()) {
|
|
87416
87775
|
projectDir = resolvedPath;
|
|
87417
87776
|
const availableFiles2 = findSelectableFiles(projectDir);
|
|
87418
87777
|
if (availableFiles2.length === 0) {
|
|
87419
87778
|
console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
|
|
87420
87779
|
return null;
|
|
87421
87780
|
}
|
|
87422
|
-
console.log("Selected file:",
|
|
87781
|
+
console.log("Selected file:", path50.relative(projectDir, availableFiles2[0]));
|
|
87423
87782
|
return { absolutePath: availableFiles2[0], projectDir };
|
|
87424
87783
|
}
|
|
87425
|
-
if (!
|
|
87784
|
+
if (!fs48.existsSync(resolvedPath)) {
|
|
87426
87785
|
console.error(`Error: File not found: ${file}`);
|
|
87427
87786
|
return null;
|
|
87428
87787
|
}
|
|
@@ -87433,7 +87792,7 @@ var resolveDevTarget = async (file) => {
|
|
|
87433
87792
|
return { absolutePath: resolvedPath, projectDir };
|
|
87434
87793
|
}
|
|
87435
87794
|
const entrypointPath = await getEntrypoint({ onError: () => {} });
|
|
87436
|
-
if (entrypointPath &&
|
|
87795
|
+
if (entrypointPath && fs48.existsSync(entrypointPath)) {
|
|
87437
87796
|
console.log("Found entrypoint at:", entrypointPath);
|
|
87438
87797
|
return { absolutePath: entrypointPath, projectDir };
|
|
87439
87798
|
}
|
|
@@ -87442,7 +87801,7 @@ var resolveDevTarget = async (file) => {
|
|
|
87442
87801
|
console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
|
|
87443
87802
|
return null;
|
|
87444
87803
|
}
|
|
87445
|
-
console.log("Selected file:",
|
|
87804
|
+
console.log("Selected file:", path50.relative(projectDir, availableFiles[0]));
|
|
87446
87805
|
return { absolutePath: availableFiles[0], projectDir };
|
|
87447
87806
|
};
|
|
87448
87807
|
|
|
@@ -87458,12 +87817,12 @@ var isPortAvailable = (port) => {
|
|
|
87458
87817
|
});
|
|
87459
87818
|
};
|
|
87460
87819
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
87461
|
-
const tsconfigPath =
|
|
87462
|
-
if (!
|
|
87820
|
+
const tsconfigPath = path51.join(projectDir, "tsconfig.json");
|
|
87821
|
+
if (!fs49.existsSync(tsconfigPath)) {
|
|
87463
87822
|
return;
|
|
87464
87823
|
}
|
|
87465
87824
|
try {
|
|
87466
|
-
const tsconfig = JSON.parse(
|
|
87825
|
+
const tsconfig = JSON.parse(fs49.readFileSync(tsconfigPath, "utf-8"));
|
|
87467
87826
|
const types = tsconfig?.compilerOptions?.types;
|
|
87468
87827
|
if (!Array.isArray(types) || !types.includes("tscircuit")) {
|
|
87469
87828
|
console.warn(kleur_default.yellow('Warning: "tscircuit" is missing from tsconfig.json compilerOptions.types. Add it (e.g. "types": ["tscircuit"]) to ensure CLI-provided types work correctly.'));
|
|
@@ -87495,7 +87854,7 @@ var registerDev = (program2) => {
|
|
|
87495
87854
|
|
|
87496
87855
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
87497
87856
|
console.log(`
|
|
87498
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
87857
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path51.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
87499
87858
|
|
|
87500
87859
|
`);
|
|
87501
87860
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -87523,15 +87882,15 @@ var checkLoggedIn = () => {
|
|
|
87523
87882
|
|
|
87524
87883
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
87525
87884
|
import { spawnSync } from "node:child_process";
|
|
87526
|
-
import
|
|
87885
|
+
import fs50 from "node:fs";
|
|
87527
87886
|
import os5 from "node:os";
|
|
87528
|
-
import
|
|
87887
|
+
import path52 from "node:path";
|
|
87529
87888
|
var hasBunInstalled = () => {
|
|
87530
87889
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
87531
87890
|
return result.status === 0;
|
|
87532
87891
|
};
|
|
87533
87892
|
var createTempProject = (tempDir) => {
|
|
87534
|
-
const packageJsonPath =
|
|
87893
|
+
const packageJsonPath = path52.join(tempDir, "package.json");
|
|
87535
87894
|
const packageJson = {
|
|
87536
87895
|
name: "tsci-doctor-check",
|
|
87537
87896
|
version: "0.0.0",
|
|
@@ -87540,7 +87899,7 @@ var createTempProject = (tempDir) => {
|
|
|
87540
87899
|
"@tsci/does-not-exist": "0.0.0"
|
|
87541
87900
|
}
|
|
87542
87901
|
};
|
|
87543
|
-
|
|
87902
|
+
fs50.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
87544
87903
|
};
|
|
87545
87904
|
var checkGlobalNpmrcRegistry = async () => {
|
|
87546
87905
|
const name = "Global .npmrc configured for tscircuit NPM registry?";
|
|
@@ -87551,7 +87910,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
87551
87910
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
87552
87911
|
};
|
|
87553
87912
|
}
|
|
87554
|
-
const tempDir =
|
|
87913
|
+
const tempDir = fs50.mkdtempSync(path52.join(os5.tmpdir(), "tsci-doctor-"));
|
|
87555
87914
|
try {
|
|
87556
87915
|
createTempProject(tempDir);
|
|
87557
87916
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -87589,7 +87948,7 @@ ${result.stderr ?? ""}`;
|
|
|
87589
87948
|
}
|
|
87590
87949
|
return { name, success: true };
|
|
87591
87950
|
} finally {
|
|
87592
|
-
|
|
87951
|
+
fs50.rmSync(tempDir, { recursive: true, force: true });
|
|
87593
87952
|
}
|
|
87594
87953
|
};
|
|
87595
87954
|
|
|
@@ -87622,8 +87981,8 @@ var registerDoctor = (program2) => {
|
|
|
87622
87981
|
};
|
|
87623
87982
|
|
|
87624
87983
|
// lib/shared/export-snippet.ts
|
|
87625
|
-
import
|
|
87626
|
-
import
|
|
87984
|
+
import fs51 from "node:fs";
|
|
87985
|
+
import path53 from "node:path";
|
|
87627
87986
|
import { promisify as promisify3 } from "node:util";
|
|
87628
87987
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
87629
87988
|
|
|
@@ -88696,9 +89055,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
88696
89055
|
const stringifyCoordinates = (coordinates) => {
|
|
88697
89056
|
return coordinates.join(" ");
|
|
88698
89057
|
};
|
|
88699
|
-
const stringifyPath = (
|
|
89058
|
+
const stringifyPath = (path53, level) => {
|
|
88700
89059
|
const padding = indent.repeat(level);
|
|
88701
|
-
return `${padding}(path ${
|
|
89060
|
+
return `${padding}(path ${path53.layer} ${path53.width} ${stringifyCoordinates(path53.coordinates)})`;
|
|
88702
89061
|
};
|
|
88703
89062
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
88704
89063
|
`;
|
|
@@ -88880,7 +89239,7 @@ var debug10 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
|
|
|
88880
89239
|
|
|
88881
89240
|
// lib/shared/export-snippet.ts
|
|
88882
89241
|
var import_jszip4 = __toESM2(require_lib4(), 1);
|
|
88883
|
-
var writeFileAsync = promisify3(
|
|
89242
|
+
var writeFileAsync = promisify3(fs51.writeFile);
|
|
88884
89243
|
var ALLOWED_EXPORT_FORMATS = [
|
|
88885
89244
|
"json",
|
|
88886
89245
|
"circuit-json",
|
|
@@ -88925,10 +89284,10 @@ var exportSnippet = async ({
|
|
|
88925
89284
|
onError(`Invalid format: ${format}`);
|
|
88926
89285
|
return onExit(1);
|
|
88927
89286
|
}
|
|
88928
|
-
const projectDir =
|
|
88929
|
-
const outputBaseName =
|
|
89287
|
+
const projectDir = path53.dirname(filePath);
|
|
89288
|
+
const outputBaseName = path53.basename(filePath).replace(/\.[^.]+$/, "");
|
|
88930
89289
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
88931
|
-
const outputDestination =
|
|
89290
|
+
const outputDestination = path53.join(projectDir, outputPath ?? outputFileName);
|
|
88932
89291
|
if (format === "kicad-library") {
|
|
88933
89292
|
try {
|
|
88934
89293
|
const result = await convertToKicadLibrary({
|
|
@@ -89125,12 +89484,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
89125
89484
|
};
|
|
89126
89485
|
|
|
89127
89486
|
// lib/eecircuit-engine/run-simulation.ts
|
|
89128
|
-
import { promises as
|
|
89129
|
-
import
|
|
89487
|
+
import { promises as fs52, existsSync as existsSync13 } from "node:fs";
|
|
89488
|
+
import path54 from "node:path";
|
|
89130
89489
|
import os6 from "node:os";
|
|
89131
89490
|
var sim = null;
|
|
89132
89491
|
var fetchSimulation = async () => {
|
|
89133
|
-
const tempFilePath =
|
|
89492
|
+
const tempFilePath = path54.join(os6.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
89134
89493
|
if (!existsSync13(tempFilePath)) {
|
|
89135
89494
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
89136
89495
|
const response = await fetch(url);
|
|
@@ -89138,7 +89497,7 @@ var fetchSimulation = async () => {
|
|
|
89138
89497
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
89139
89498
|
}
|
|
89140
89499
|
const scriptContent = await response.text();
|
|
89141
|
-
await
|
|
89500
|
+
await fs52.writeFile(tempFilePath, scriptContent);
|
|
89142
89501
|
}
|
|
89143
89502
|
const module2 = await import(tempFilePath);
|
|
89144
89503
|
return module2.Simulation;
|
|
@@ -89227,8 +89586,8 @@ var resultToCsv = (result) => {
|
|
|
89227
89586
|
};
|
|
89228
89587
|
|
|
89229
89588
|
// cli/export/register.ts
|
|
89230
|
-
import
|
|
89231
|
-
import { promises as
|
|
89589
|
+
import path55 from "node:path";
|
|
89590
|
+
import { promises as fs53 } from "node:fs";
|
|
89232
89591
|
var registerExport = (program2) => {
|
|
89233
89592
|
program2.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").action(async (file, options) => {
|
|
89234
89593
|
const formatOption = options.format ?? "json";
|
|
@@ -89240,12 +89599,12 @@ var registerExport = (program2) => {
|
|
|
89240
89599
|
});
|
|
89241
89600
|
if (circuitJson) {
|
|
89242
89601
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
89243
|
-
const outputSpicePath = options.output ??
|
|
89244
|
-
await
|
|
89602
|
+
const outputSpicePath = options.output ?? path55.join(path55.dirname(file), `${path55.basename(file, path55.extname(file))}.spice.cir`);
|
|
89603
|
+
await fs53.writeFile(outputSpicePath, spiceString);
|
|
89245
89604
|
const { result } = await runSimulation(spiceString);
|
|
89246
89605
|
const csvContent = resultToCsv(result);
|
|
89247
89606
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
89248
|
-
await
|
|
89607
|
+
await fs53.writeFile(outputCsvPath, csvContent);
|
|
89249
89608
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
89250
89609
|
}
|
|
89251
89610
|
process.exit(0);
|
|
@@ -90713,8 +91072,8 @@ function getErrorMap() {
|
|
|
90713
91072
|
return overrideErrorMap;
|
|
90714
91073
|
}
|
|
90715
91074
|
var makeIssue = (params2) => {
|
|
90716
|
-
const { data, path:
|
|
90717
|
-
const fullPath = [...
|
|
91075
|
+
const { data, path: path56, errorMaps, issueData } = params2;
|
|
91076
|
+
const fullPath = [...path56, ...issueData.path || []];
|
|
90718
91077
|
const fullIssue = {
|
|
90719
91078
|
...issueData,
|
|
90720
91079
|
path: fullPath
|
|
@@ -90822,11 +91181,11 @@ var errorUtil;
|
|
|
90822
91181
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
90823
91182
|
})(errorUtil || (errorUtil = {}));
|
|
90824
91183
|
var ParseInputLazyPath = class {
|
|
90825
|
-
constructor(parent, value,
|
|
91184
|
+
constructor(parent, value, path56, key) {
|
|
90826
91185
|
this._cachedPath = [];
|
|
90827
91186
|
this.parent = parent;
|
|
90828
91187
|
this.data = value;
|
|
90829
|
-
this._path =
|
|
91188
|
+
this._path = path56;
|
|
90830
91189
|
this._key = key;
|
|
90831
91190
|
}
|
|
90832
91191
|
get path() {
|
|
@@ -99013,7 +99372,7 @@ var ss = ys;
|
|
|
99013
99372
|
var ms2 = { paths: { diag1: { type: "path", points: [{ x: -0.1, y: -0.1 }, { x: 0.1, y: 0.1 }], color: "primary", fill: false }, diag2: { type: "path", points: [{ x: -0.1, y: 0.1 }, { x: 0.1, y: -0.1 }], color: "primary", fill: false }, stem: { type: "path", points: [{ x: -0.2, y: 0 }, { x: 0, y: 0 }], color: "primary", fill: false } }, texts: {}, refblocks: { left1: { x: -0.2, y: 0 } }, bounds: { minX: -0.19, maxX: 0.2, minY: -0.12, maxY: 0.12, width: 0.39, height: 0.24, centerX: 0, centerY: 0 }, circles: {} };
|
|
99014
99373
|
var { paths: Yd, bounds: ns, refblocks: Xd } = ms2;
|
|
99015
99374
|
var U = e({ primitives: [...Object.values(Yd)], ports: [{ ...Xd.left1, labels: ["1"] }], center: { x: ns.centerX, y: ns.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
|
|
99016
|
-
var
|
|
99375
|
+
var fs54 = r(U, "down");
|
|
99017
99376
|
var hs = r(U, "left");
|
|
99018
99377
|
var cs = r(U, "up");
|
|
99019
99378
|
var g = { paths: { path11: { type: "path", points: [{ x: -0.4, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.55 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.55 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
@@ -99616,7 +99975,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
99616
99975
|
Vb.anchor = "middle_left";
|
|
99617
99976
|
jb.anchor = "middle_right";
|
|
99618
99977
|
var tf = Il;
|
|
99619
|
-
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down:
|
|
99978
|
+
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down: fs54, not_connected_left: hs, not_connected_right: U, not_connected_up: cs, npn_bipolar_transistor_down: ds, npn_bipolar_transistor_horz: bs, npn_bipolar_transistor_left: _s, npn_bipolar_transistor_right: gs, npn_bipolar_transistor_up: us, npn_bipolar_transistor_vert: vs, opamp_no_power_down: As, opamp_no_power_left: Ps, opamp_no_power_right: W, opamp_no_power_up: Ss, opamp_with_power_down: Rs, opamp_with_power_left: Ts, opamp_with_power_right: H, opamp_with_power_up: Es, p_channel_d_mosfet_transistor_horz: x0, p_channel_d_mosfet_transistor_vert: js, p_channel_e_mosfet_transistor_horz: m0, p_channel_e_mosfet_transistor_vert: $s, photodiode_horz: n0, photodiode_vert: Is, pjfet_transistor_horz: h0, pjfet_transistor_vert: Us, pnp_bipolar_transistor_down: Ws, pnp_bipolar_transistor_horz: Hs, pnp_bipolar_transistor_left: Zs, pnp_bipolar_transistor_right: Qs, pnp_bipolar_transistor_up: Ks, pnp_bipolar_transistor_vert: tm, potentiometer_horz: v0, potentiometer_vert: im, potentiometer2_down: ym, potentiometer2_left: xm, potentiometer2_right: Z, potentiometer2_up: sm, potentiometer3_down: mm2, potentiometer3_left: nm, potentiometer3_right: fm, potentiometer3_up: hm, power_factor_meter_horz: R0, power_factor_meter_vert: _m, push_button_normally_closed_momentary_horz: E0, push_button_normally_closed_momentary_vert: wm, push_button_normally_open_momentary_horz: X0, push_button_normally_open_momentary_vert: Fm, rail_down: Tm, rail_left: Ym, rail_right: Lm, rail_up: jm, rectifier_diode_horz: j0, rectifier_diode_vert: Om, resistor_down: $m, resistor_left: Cm, resistor_right: Im, resistor_up: qm, resonator_down: Gm, resonator_horz: N0, resonator_left: Um, resonator_right: et, resonator_up: Wm, resonator_vert: Hm, schottky_diode_down: Qm, schottky_diode_left: Km, schottky_diode_right: rt, schottky_diode_up: tn, silicon_controlled_rectifier_horz: I0, silicon_controlled_rectifier_vert: on2, solderjumper2_bridged12_down: ln, solderjumper2_bridged12_left: pn, solderjumper2_bridged12_right: an, solderjumper2_bridged12_up: yn, solderjumper2_down: xn, solderjumper2_left: sn, solderjumper2_right: mn, solderjumper2_up: nn, solderjumper3_bridged12_down: fn, solderjumper3_bridged12_left: hn, solderjumper3_bridged12_right: cn, solderjumper3_bridged12_up: dn, solderjumper3_bridged123_down: bn, solderjumper3_bridged123_left: _n, solderjumper3_bridged123_right: gn, solderjumper3_bridged123_up: un, solderjumper3_bridged23_down: vn, solderjumper3_bridged23_left: wn, solderjumper3_bridged23_right: An, solderjumper3_bridged23_up: Pn, solderjumper3_down: Sn, solderjumper3_left: Fn, solderjumper3_right: Rn, solderjumper3_up: Tn, spdt_normally_closed_switch_down: Yn, spdt_normally_closed_switch_left: Xn, spdt_normally_closed_switch_right: xt, spdt_normally_closed_switch_up: Ln, spdt_switch_down: jn, spdt_switch_left: kn, spdt_switch_right: st, spdt_switch_up: zn, spst_normally_closed_switch_down: On, spst_normally_closed_switch_left: Jn, spst_normally_closed_switch_right: mt, spst_normally_closed_switch_up: $n, spst_switch_down: Mn, spst_switch_left: Cn, spst_switch_right: nt, spst_switch_up: Nn, square_wave_down: In, square_wave_left: Bn, square_wave_right: qn, square_wave_up: Dn, step_recovery_diode_horz: B0, step_recovery_diode_vert: Gn, tachometer_horz: Yt, tachometer_vert: Zn, testpoint_down: t1, testpoint_left: e1, testpoint_right: ht, testpoint_up: i1, tilted_ground_down: p1, tilted_ground_left: a1, tilted_ground_right: wt, tilted_ground_up: D0, triac_horz: G0, triac_vert: s1, tunnel_diode_horz: W0, tunnel_diode_vert: h1, unijunction_transistor_horz: Z0, unijunction_transistor_vert: u1, usbc: w1, var_meter_horz: K0, var_meter_vert: S1, varactor_diode_horz: er, varactor_diode_vert: E1, varistor_horz: or, varistor_vert: V1, varmeter_horz: Xt, varmeter_vert: O1, vcc_down: J1, vcc_left: $1, vcc_right: M1, vcc_up: C1, volt_meter_horz: lr, volt_meter_vert: N1, watt_hour_meter_horz: Lt, watt_hour_meter_vert: D1, wattmeter_horz: Vt, wattmeter_vert: H1, zener_diode_horz: xr, zener_diode_vert: tf };
|
|
99620
99979
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
99621
99980
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
99622
99981
|
lineThickness = 0
|
|
@@ -101924,11 +102283,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
101924
102283
|
fiber = fiber.next, id--;
|
|
101925
102284
|
return fiber;
|
|
101926
102285
|
}
|
|
101927
|
-
function copyWithSetImpl(obj,
|
|
101928
|
-
if (index >=
|
|
102286
|
+
function copyWithSetImpl(obj, path56, index, value) {
|
|
102287
|
+
if (index >= path56.length)
|
|
101929
102288
|
return value;
|
|
101930
|
-
var key =
|
|
101931
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
102289
|
+
var key = path56[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
102290
|
+
updated[key] = copyWithSetImpl(obj[key], path56, index + 1, value);
|
|
101932
102291
|
return updated;
|
|
101933
102292
|
}
|
|
101934
102293
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -101948,11 +102307,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
101948
102307
|
index + 1 === oldPath.length ? (updated[newPath[index]] = updated[oldKey], isArrayImpl(updated) ? updated.splice(oldKey, 1) : delete updated[oldKey]) : updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index + 1);
|
|
101949
102308
|
return updated;
|
|
101950
102309
|
}
|
|
101951
|
-
function copyWithDeleteImpl(obj,
|
|
101952
|
-
var key =
|
|
101953
|
-
if (index + 1 ===
|
|
102310
|
+
function copyWithDeleteImpl(obj, path56, index) {
|
|
102311
|
+
var key = path56[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
102312
|
+
if (index + 1 === path56.length)
|
|
101954
102313
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
101955
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
102314
|
+
updated[key] = copyWithDeleteImpl(obj[key], path56, index + 1);
|
|
101956
102315
|
return updated;
|
|
101957
102316
|
}
|
|
101958
102317
|
function shouldSuspendImpl() {
|
|
@@ -110978,29 +111337,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
110978
111337
|
var didWarnAboutNestedUpdates = false;
|
|
110979
111338
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
110980
111339
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
110981
|
-
overrideHookState = function(fiber, id,
|
|
111340
|
+
overrideHookState = function(fiber, id, path56, value) {
|
|
110982
111341
|
id = findHook(fiber, id);
|
|
110983
|
-
id !== null && (
|
|
111342
|
+
id !== null && (path56 = copyWithSetImpl(id.memoizedState, path56, 0, value), id.memoizedState = path56, id.baseState = path56, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path56 = enqueueConcurrentRenderForLane(fiber, 2), path56 !== null && scheduleUpdateOnFiber(path56, fiber, 2));
|
|
110984
111343
|
};
|
|
110985
|
-
overrideHookStateDeletePath = function(fiber, id,
|
|
111344
|
+
overrideHookStateDeletePath = function(fiber, id, path56) {
|
|
110986
111345
|
id = findHook(fiber, id);
|
|
110987
|
-
id !== null && (
|
|
111346
|
+
id !== null && (path56 = copyWithDeleteImpl(id.memoizedState, path56, 0), id.memoizedState = path56, id.baseState = path56, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path56 = enqueueConcurrentRenderForLane(fiber, 2), path56 !== null && scheduleUpdateOnFiber(path56, fiber, 2));
|
|
110988
111347
|
};
|
|
110989
111348
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
110990
111349
|
id = findHook(fiber, id);
|
|
110991
111350
|
id !== null && (oldPath = copyWithRename(id.memoizedState, oldPath, newPath), id.memoizedState = oldPath, id.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
110992
111351
|
};
|
|
110993
|
-
overrideProps = function(fiber,
|
|
110994
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
111352
|
+
overrideProps = function(fiber, path56, value) {
|
|
111353
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path56, 0, value);
|
|
110995
111354
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
110996
|
-
|
|
110997
|
-
|
|
111355
|
+
path56 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
111356
|
+
path56 !== null && scheduleUpdateOnFiber(path56, fiber, 2);
|
|
110998
111357
|
};
|
|
110999
|
-
overridePropsDeletePath = function(fiber,
|
|
111000
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
111358
|
+
overridePropsDeletePath = function(fiber, path56) {
|
|
111359
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path56, 0);
|
|
111001
111360
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
111002
|
-
|
|
111003
|
-
|
|
111361
|
+
path56 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
111362
|
+
path56 !== null && scheduleUpdateOnFiber(path56, fiber, 2);
|
|
111004
111363
|
};
|
|
111005
111364
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
111006
111365
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -117303,7 +117662,7 @@ var parsePin = (pinString) => {
|
|
|
117303
117662
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
117304
117663
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
117305
117664
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
117306
|
-
const
|
|
117665
|
+
const path56 = pathMatch ? pathMatch[1] : "";
|
|
117307
117666
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
117308
117667
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
117309
117668
|
const r2 = Number.parseFloat(rotation4);
|
|
@@ -117317,7 +117676,7 @@ var parsePin = (pinString) => {
|
|
|
117317
117676
|
rotation: Number.isNaN(r2) ? 0 : r2,
|
|
117318
117677
|
label,
|
|
117319
117678
|
labelColor,
|
|
117320
|
-
path:
|
|
117679
|
+
path: path56,
|
|
117321
117680
|
arrow
|
|
117322
117681
|
};
|
|
117323
117682
|
};
|
|
@@ -117757,15 +118116,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
117757
118116
|
}
|
|
117758
118117
|
}
|
|
117759
118118
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
117760
|
-
const
|
|
118119
|
+
const path56 = [];
|
|
117761
118120
|
for (let i22 = 0;i22 <= numPoints; i22++) {
|
|
117762
118121
|
const t3 = i22 / numPoints;
|
|
117763
118122
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
117764
118123
|
const x22 = centerX + radius * Math.cos(angle2);
|
|
117765
118124
|
const y22 = centerY + radius * Math.sin(angle2);
|
|
117766
|
-
|
|
118125
|
+
path56.push({ x: x22, y: y22 });
|
|
117767
118126
|
}
|
|
117768
|
-
return
|
|
118127
|
+
return path56;
|
|
117769
118128
|
}
|
|
117770
118129
|
var __defProp4 = Object.defineProperty;
|
|
117771
118130
|
var __export22 = (target, all) => {
|
|
@@ -126844,17 +127203,17 @@ var ObstacleList = class {
|
|
|
126844
127203
|
return obstacles;
|
|
126845
127204
|
}
|
|
126846
127205
|
};
|
|
126847
|
-
function removePathLoops(
|
|
126848
|
-
if (
|
|
126849
|
-
return
|
|
126850
|
-
const result = [{ ...
|
|
126851
|
-
let currentLayer =
|
|
126852
|
-
for (let i22 = 1;i22 <
|
|
126853
|
-
const currentSegment = { start:
|
|
126854
|
-
const isVia =
|
|
126855
|
-
if (
|
|
126856
|
-
result.push({ ...
|
|
126857
|
-
currentLayer =
|
|
127206
|
+
function removePathLoops(path56) {
|
|
127207
|
+
if (path56.length < 4)
|
|
127208
|
+
return path56;
|
|
127209
|
+
const result = [{ ...path56[0] }];
|
|
127210
|
+
let currentLayer = path56[0].layer;
|
|
127211
|
+
for (let i22 = 1;i22 < path56.length; i22++) {
|
|
127212
|
+
const currentSegment = { start: path56[i22 - 1], end: path56[i22] };
|
|
127213
|
+
const isVia = path56[i22].route_type === "via" || path56[i22 - 1].route_type === "via";
|
|
127214
|
+
if (path56[i22].layer !== currentLayer || isVia) {
|
|
127215
|
+
result.push({ ...path56[i22] });
|
|
127216
|
+
currentLayer = path56[i22].layer;
|
|
126858
127217
|
continue;
|
|
126859
127218
|
}
|
|
126860
127219
|
let intersectionFound = false;
|
|
@@ -126883,8 +127242,8 @@ function removePathLoops(path55) {
|
|
|
126883
127242
|
result.push(intersectionPoint);
|
|
126884
127243
|
}
|
|
126885
127244
|
const lastPoint = result[result.length - 1];
|
|
126886
|
-
if (lastPoint.x !==
|
|
126887
|
-
result.push(
|
|
127245
|
+
if (lastPoint.x !== path56[i22].x || lastPoint.y !== path56[i22].y) {
|
|
127246
|
+
result.push(path56[i22]);
|
|
126888
127247
|
}
|
|
126889
127248
|
}
|
|
126890
127249
|
return result;
|
|
@@ -127373,10 +127732,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
127373
127732
|
});
|
|
127374
127733
|
}
|
|
127375
127734
|
if (current2.parent) {
|
|
127376
|
-
const
|
|
127735
|
+
const path56 = [];
|
|
127377
127736
|
let p22 = current2;
|
|
127378
127737
|
while (p22) {
|
|
127379
|
-
|
|
127738
|
+
path56.unshift(p22);
|
|
127380
127739
|
p22 = p22.parent;
|
|
127381
127740
|
}
|
|
127382
127741
|
debugSolution.push({
|
|
@@ -127384,7 +127743,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
127384
127743
|
pcb_component_id: "",
|
|
127385
127744
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
127386
127745
|
layer: "top",
|
|
127387
|
-
route:
|
|
127746
|
+
route: path56,
|
|
127388
127747
|
stroke_width: 0.01
|
|
127389
127748
|
});
|
|
127390
127749
|
}
|
|
@@ -135735,7 +136094,7 @@ var ps2 = class extends e3 {
|
|
|
135735
136094
|
return t3;
|
|
135736
136095
|
}
|
|
135737
136096
|
};
|
|
135738
|
-
var
|
|
136097
|
+
var fs55 = (t3) => {
|
|
135739
136098
|
const e22 = [], s22 = [], n22 = [], i22 = ht2(t3);
|
|
135740
136099
|
if (t3.connections)
|
|
135741
136100
|
for (const e32 of t3.connections)
|
|
@@ -138358,7 +138717,7 @@ var Tn2 = class extends e3 {
|
|
|
138358
138717
|
const t3 = M22.map((t42) => ({ x: t42.x, y: t42.y }));
|
|
138359
138718
|
t3.push({ ...t3[0] }), v22.push({ points: t3, strokeColor: "rgba(0, 136, 255, 0.95)" });
|
|
138360
138719
|
}
|
|
138361
|
-
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22,
|
|
138720
|
+
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22, fs55(this.getOutputSimpleRouteJson())) : null].filter(Boolean);
|
|
138362
138721
|
return t(...b22);
|
|
138363
138722
|
}
|
|
138364
138723
|
preview() {
|
|
@@ -151829,10 +152188,10 @@ var findFirstCollision = (pts, rects, opts = {}) => {
|
|
|
151829
152188
|
}
|
|
151830
152189
|
return null;
|
|
151831
152190
|
};
|
|
151832
|
-
var isPathCollidingWithObstacles = (
|
|
151833
|
-
for (let i22 = 0;i22 <
|
|
152191
|
+
var isPathCollidingWithObstacles = (path56, obstacles) => {
|
|
152192
|
+
for (let i22 = 0;i22 < path56.length - 1; i22++) {
|
|
151834
152193
|
for (const obstacle of obstacles) {
|
|
151835
|
-
if (segmentIntersectsRect(
|
|
152194
|
+
if (segmentIntersectsRect(path56[i22], path56[i22 + 1], obstacle)) {
|
|
151836
152195
|
return true;
|
|
151837
152196
|
}
|
|
151838
152197
|
}
|
|
@@ -152026,36 +152385,36 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152026
152385
|
this.error = "No collision-free path found";
|
|
152027
152386
|
return;
|
|
152028
152387
|
}
|
|
152029
|
-
const { path:
|
|
152388
|
+
const { path: path56, collisionChipIds } = state;
|
|
152030
152389
|
const [PA, PB] = this.pins;
|
|
152031
|
-
const collision = findFirstCollision(
|
|
152390
|
+
const collision = findFirstCollision(path56, this.obstacles);
|
|
152032
152391
|
if (!collision) {
|
|
152033
|
-
const first =
|
|
152034
|
-
const last =
|
|
152392
|
+
const first = path56[0];
|
|
152393
|
+
const last = path56[path56.length - 1];
|
|
152035
152394
|
const EPS42 = 0.000000001;
|
|
152036
152395
|
const samePoint = (p22, q22) => Math.abs(p22.x - q22.x) < EPS42 && Math.abs(p22.y - q22.y) < EPS42;
|
|
152037
152396
|
if (samePoint(first, { x: PA.x, y: PA.y }) && samePoint(last, { x: PB.x, y: PB.y })) {
|
|
152038
|
-
this.solvedTracePath =
|
|
152397
|
+
this.solvedTracePath = path56;
|
|
152039
152398
|
this.solved = true;
|
|
152040
152399
|
}
|
|
152041
152400
|
return;
|
|
152042
152401
|
}
|
|
152043
152402
|
let { segIndex, rect } = collision;
|
|
152044
152403
|
const isFirstSegment = segIndex === 0;
|
|
152045
|
-
const isLastSegment = segIndex ===
|
|
152404
|
+
const isLastSegment = segIndex === path56.length - 2;
|
|
152046
152405
|
if (isFirstSegment) {
|
|
152047
|
-
if (
|
|
152406
|
+
if (path56.length < 3) {
|
|
152048
152407
|
return;
|
|
152049
152408
|
}
|
|
152050
152409
|
segIndex = 1;
|
|
152051
152410
|
} else if (isLastSegment) {
|
|
152052
|
-
if (
|
|
152411
|
+
if (path56.length < 3) {
|
|
152053
152412
|
return;
|
|
152054
152413
|
}
|
|
152055
|
-
segIndex =
|
|
152414
|
+
segIndex = path56.length - 3;
|
|
152056
152415
|
}
|
|
152057
|
-
const a22 =
|
|
152058
|
-
const b22 =
|
|
152416
|
+
const a22 = path56[segIndex];
|
|
152417
|
+
const b22 = path56[segIndex + 1];
|
|
152059
152418
|
const axis = this.axisOfSegment(a22, b22);
|
|
152060
152419
|
if (!axis) {
|
|
152061
152420
|
return;
|
|
@@ -152073,7 +152432,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152073
152432
|
}
|
|
152074
152433
|
const newStates = [];
|
|
152075
152434
|
for (const coord of candidates) {
|
|
152076
|
-
const newPath = shiftSegmentOrth(
|
|
152435
|
+
const newPath = shiftSegmentOrth(path56, segIndex, axis, coord);
|
|
152077
152436
|
if (!newPath)
|
|
152078
152437
|
continue;
|
|
152079
152438
|
const key = pathKey(newPath);
|
|
@@ -152109,8 +152468,8 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152109
152468
|
strokeColor: "blue",
|
|
152110
152469
|
strokeDash: "5 5"
|
|
152111
152470
|
});
|
|
152112
|
-
for (const { path:
|
|
152113
|
-
g22.lines.push({ points:
|
|
152471
|
+
for (const { path: path56, collisionChipIds: collisionRectIds } of this.queue) {
|
|
152472
|
+
g22.lines.push({ points: path56, strokeColor: "teal", strokeDash: "2 2" });
|
|
152114
152473
|
}
|
|
152115
152474
|
if (this.solvedTracePath) {
|
|
152116
152475
|
g22.lines.push({ points: this.solvedTracePath, strokeColor: "green" });
|
|
@@ -152347,9 +152706,9 @@ var TraceOverlapIssueSolver = class extends BaseSolver3 {
|
|
|
152347
152706
|
solvedTracePathIndex,
|
|
152348
152707
|
traceSegmentIndex
|
|
152349
152708
|
} of group.pathsWithOverlap) {
|
|
152350
|
-
const
|
|
152351
|
-
const segStart =
|
|
152352
|
-
const segEnd =
|
|
152709
|
+
const path56 = this.traceNetIslands[group.connNetId][solvedTracePathIndex];
|
|
152710
|
+
const segStart = path56.tracePath[traceSegmentIndex];
|
|
152711
|
+
const segEnd = path56.tracePath[traceSegmentIndex + 1];
|
|
152353
152712
|
graphics.lines.push({
|
|
152354
152713
|
points: [segStart, segEnd],
|
|
152355
152714
|
strokeColor: "red"
|
|
@@ -152393,11 +152752,11 @@ var TraceOverlapShiftSolver = class extends BaseSolver3 {
|
|
|
152393
152752
|
computeTraceNetIslands() {
|
|
152394
152753
|
const islands = {};
|
|
152395
152754
|
for (const original of this.inputTracePaths) {
|
|
152396
|
-
const
|
|
152397
|
-
const key =
|
|
152755
|
+
const path56 = this.correctedTraceMap[original.mspPairId] ?? original;
|
|
152756
|
+
const key = path56.globalConnNetId;
|
|
152398
152757
|
if (!islands[key])
|
|
152399
152758
|
islands[key] = [];
|
|
152400
|
-
islands[key].push(
|
|
152759
|
+
islands[key].push(path56);
|
|
152401
152760
|
}
|
|
152402
152761
|
return islands;
|
|
152403
152762
|
}
|
|
@@ -152645,9 +153004,9 @@ function rectIntersectsAnyTrace(bounds, inputTraceMap, hostPathId, hostSegIndex)
|
|
|
152645
153004
|
}
|
|
152646
153005
|
return { hasIntersection: false };
|
|
152647
153006
|
}
|
|
152648
|
-
function lengthOfTrace(
|
|
153007
|
+
function lengthOfTrace(path56) {
|
|
152649
153008
|
let sum = 0;
|
|
152650
|
-
const pts =
|
|
153009
|
+
const pts = path56.tracePath;
|
|
152651
153010
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
152652
153011
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
152653
153012
|
}
|
|
@@ -153176,9 +153535,9 @@ var NetLabelPlacementSolver = class extends BaseSolver3 {
|
|
|
153176
153535
|
}
|
|
153177
153536
|
const compTraces = (byGlobal[globalConnNetId] ?? []).filter((t3) => component.has(t3.pins[0].pinId) && component.has(t3.pins[1].pinId));
|
|
153178
153537
|
if (compTraces.length > 0) {
|
|
153179
|
-
const lengthOf = (
|
|
153538
|
+
const lengthOf = (path56) => {
|
|
153180
153539
|
let sum = 0;
|
|
153181
|
-
const pts =
|
|
153540
|
+
const pts = path56.tracePath;
|
|
153182
153541
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
153183
153542
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
153184
153543
|
}
|
|
@@ -153323,12 +153682,12 @@ var detectTraceLabelOverlap = (traces, netLabels) => {
|
|
|
153323
153682
|
}
|
|
153324
153683
|
return overlaps;
|
|
153325
153684
|
};
|
|
153326
|
-
var findTraceViolationZone = (
|
|
153685
|
+
var findTraceViolationZone = (path56, labelBounds) => {
|
|
153327
153686
|
const isPointInside = (p22) => p22.x > labelBounds.minX && p22.x < labelBounds.maxX && p22.y > labelBounds.minY && p22.y < labelBounds.maxY;
|
|
153328
153687
|
let firstInsideIndex = -1;
|
|
153329
153688
|
let lastInsideIndex = -1;
|
|
153330
|
-
for (let i22 = 0;i22 <
|
|
153331
|
-
if (isPointInside(
|
|
153689
|
+
for (let i22 = 0;i22 < path56.length; i22++) {
|
|
153690
|
+
if (isPointInside(path56[i22])) {
|
|
153332
153691
|
if (firstInsideIndex === -1) {
|
|
153333
153692
|
firstInsideIndex = i22;
|
|
153334
153693
|
}
|
|
@@ -153337,20 +153696,20 @@ var findTraceViolationZone = (path55, labelBounds) => {
|
|
|
153337
153696
|
}
|
|
153338
153697
|
return { firstInsideIndex, lastInsideIndex };
|
|
153339
153698
|
};
|
|
153340
|
-
var simplifyPath = (
|
|
153341
|
-
if (
|
|
153342
|
-
return
|
|
153343
|
-
const newPath = [
|
|
153344
|
-
for (let i22 = 1;i22 <
|
|
153699
|
+
var simplifyPath = (path56) => {
|
|
153700
|
+
if (path56.length < 3)
|
|
153701
|
+
return path56;
|
|
153702
|
+
const newPath = [path56[0]];
|
|
153703
|
+
for (let i22 = 1;i22 < path56.length - 1; i22++) {
|
|
153345
153704
|
const p12 = newPath[newPath.length - 1];
|
|
153346
|
-
const p22 =
|
|
153347
|
-
const p32 =
|
|
153705
|
+
const p22 = path56[i22];
|
|
153706
|
+
const p32 = path56[i22 + 1];
|
|
153348
153707
|
if (isVertical(p12, p22) && isVertical(p22, p32) || isHorizontal(p12, p22) && isHorizontal(p22, p32)) {
|
|
153349
153708
|
continue;
|
|
153350
153709
|
}
|
|
153351
153710
|
newPath.push(p22);
|
|
153352
153711
|
}
|
|
153353
|
-
newPath.push(
|
|
153712
|
+
newPath.push(path56[path56.length - 1]);
|
|
153354
153713
|
if (newPath.length < 3)
|
|
153355
153714
|
return newPath;
|
|
153356
153715
|
const finalPath = [newPath[0]];
|
|
@@ -153610,12 +153969,12 @@ var hasCollisionsWithLabels = (pathSegments, labels) => {
|
|
|
153610
153969
|
return false;
|
|
153611
153970
|
};
|
|
153612
153971
|
var minimizeTurns = ({
|
|
153613
|
-
path:
|
|
153972
|
+
path: path56,
|
|
153614
153973
|
obstacles,
|
|
153615
153974
|
labelBounds
|
|
153616
153975
|
}) => {
|
|
153617
|
-
if (
|
|
153618
|
-
return
|
|
153976
|
+
if (path56.length <= 2) {
|
|
153977
|
+
return path56;
|
|
153619
153978
|
}
|
|
153620
153979
|
const recognizeStairStepPattern = (pathToCheck, startIdx) => {
|
|
153621
153980
|
if (startIdx >= pathToCheck.length - 3)
|
|
@@ -153647,7 +154006,7 @@ var minimizeTurns = ({
|
|
|
153647
154006
|
}
|
|
153648
154007
|
return isStairStep && endIdx - startIdx >= 3 ? endIdx : -1;
|
|
153649
154008
|
};
|
|
153650
|
-
let optimizedPath = [...
|
|
154009
|
+
let optimizedPath = [...path56];
|
|
153651
154010
|
let currentTurns = countTurns(optimizedPath);
|
|
153652
154011
|
let improved = true;
|
|
153653
154012
|
while (improved) {
|
|
@@ -161252,9 +161611,9 @@ var getFileExtension = (filename) => {
|
|
|
161252
161611
|
const extension = lastSegment.split(".").pop();
|
|
161253
161612
|
return extension?.toLowerCase() ?? null;
|
|
161254
161613
|
};
|
|
161255
|
-
var joinUrlPath = (base,
|
|
161614
|
+
var joinUrlPath = (base, path56) => {
|
|
161256
161615
|
const trimmedBase = base.replace(/\/+$/, "");
|
|
161257
|
-
const trimmedPath =
|
|
161616
|
+
const trimmedPath = path56.replace(/^\/+/, "");
|
|
161258
161617
|
return `${trimmedBase}/${trimmedPath}`;
|
|
161259
161618
|
};
|
|
161260
161619
|
var constructAssetUrl = (targetUrl, baseUrl) => {
|
|
@@ -162568,7 +162927,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
162568
162927
|
for (let i22 = 0;i22 < portsWithPosition.length - 1; i22++) {
|
|
162569
162928
|
const start = portsWithPosition[i22];
|
|
162570
162929
|
const end = portsWithPosition[i22 + 1];
|
|
162571
|
-
const
|
|
162930
|
+
const path56 = calculateElbow({
|
|
162572
162931
|
x: start.position.x,
|
|
162573
162932
|
y: start.position.y,
|
|
162574
162933
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -162577,8 +162936,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
162577
162936
|
y: end.position.y,
|
|
162578
162937
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
162579
162938
|
});
|
|
162580
|
-
for (let j22 = 0;j22 <
|
|
162581
|
-
elbowEdges.push({ from:
|
|
162939
|
+
for (let j22 = 0;j22 < path56.length - 1; j22++) {
|
|
162940
|
+
elbowEdges.push({ from: path56[j22], to: path56[j22 + 1] });
|
|
162582
162941
|
}
|
|
162583
162942
|
}
|
|
162584
162943
|
const doesSegmentIntersectRect2 = (edge, rect) => {
|
|
@@ -163771,20 +164130,20 @@ var parseLibraryFootprintRef = (s22) => {
|
|
|
163771
164130
|
};
|
|
163772
164131
|
var isStaticAssetPath = (s22) => s22.startsWith("/");
|
|
163773
164132
|
var resolveStaticFileImportDebug = (0, import_debug92.default)("tscircuit:core:resolveStaticFileImport");
|
|
163774
|
-
async function resolveStaticFileImport(
|
|
163775
|
-
if (!
|
|
163776
|
-
return
|
|
164133
|
+
async function resolveStaticFileImport(path56, platform) {
|
|
164134
|
+
if (!path56)
|
|
164135
|
+
return path56;
|
|
163777
164136
|
const resolver = platform?.resolveProjectStaticFileImportUrl;
|
|
163778
|
-
if (resolver &&
|
|
164137
|
+
if (resolver && path56.startsWith("/")) {
|
|
163779
164138
|
try {
|
|
163780
|
-
const resolved = await resolver(
|
|
164139
|
+
const resolved = await resolver(path56);
|
|
163781
164140
|
if (resolved)
|
|
163782
164141
|
return resolved;
|
|
163783
164142
|
} catch (error) {
|
|
163784
164143
|
resolveStaticFileImportDebug("failed to resolve static file via platform resolver", error);
|
|
163785
164144
|
}
|
|
163786
164145
|
}
|
|
163787
|
-
return constructAssetUrl(
|
|
164146
|
+
return constructAssetUrl(path56, platform?.projectBaseUrl);
|
|
163788
164147
|
}
|
|
163789
164148
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
163790
164149
|
let { footprint } = component.props;
|
|
@@ -168872,7 +169231,7 @@ var Group6 = class extends NormalComponent3 {
|
|
|
168872
169231
|
});
|
|
168873
169232
|
}
|
|
168874
169233
|
if (debug112.enabled) {
|
|
168875
|
-
const graphicsObject =
|
|
169234
|
+
const graphicsObject = fs55(simpleRouteJson);
|
|
168876
169235
|
graphicsObject.title = `autorouting-${this.props.name}`;
|
|
168877
169236
|
global.debugGraphics?.push(graphicsObject);
|
|
168878
169237
|
}
|
|
@@ -171431,7 +171790,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
171431
171790
|
}
|
|
171432
171791
|
const portPos = port._getGlobalSchematicPositionAfterLayout();
|
|
171433
171792
|
const portFacing = convertFacingDirectionToElbowDirection(port.facingDirection ?? "right") ?? "x+";
|
|
171434
|
-
const
|
|
171793
|
+
const path56 = calculateElbow({
|
|
171435
171794
|
x: portPos.x,
|
|
171436
171795
|
y: portPos.y,
|
|
171437
171796
|
facingDirection: portFacing
|
|
@@ -171440,13 +171799,13 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
171440
171799
|
y: anchorPos.y,
|
|
171441
171800
|
facingDirection: anchorFacing
|
|
171442
171801
|
});
|
|
171443
|
-
if (!Array.isArray(
|
|
171802
|
+
if (!Array.isArray(path56) || path56.length < 2)
|
|
171444
171803
|
continue;
|
|
171445
171804
|
const edges = [];
|
|
171446
|
-
for (let i22 = 0;i22 <
|
|
171805
|
+
for (let i22 = 0;i22 < path56.length - 1; i22++) {
|
|
171447
171806
|
edges.push({
|
|
171448
|
-
from: { x:
|
|
171449
|
-
to: { x:
|
|
171807
|
+
from: { x: path56[i22].x, y: path56[i22].y },
|
|
171808
|
+
to: { x: path56[i22 + 1].x, y: path56[i22 + 1].y }
|
|
171450
171809
|
});
|
|
171451
171810
|
}
|
|
171452
171811
|
let source_trace_id;
|
|
@@ -173758,8 +174117,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
173758
174117
|
*/
|
|
173759
174118
|
|
|
173760
174119
|
// lib/import/import-component-from-jlcpcb.ts
|
|
173761
|
-
import
|
|
173762
|
-
import
|
|
174120
|
+
import fs56 from "node:fs/promises";
|
|
174121
|
+
import path56 from "node:path";
|
|
173763
174122
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
173764
174123
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
173765
174124
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -173767,10 +174126,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
173767
174126
|
if (!fileName) {
|
|
173768
174127
|
throw new Error("Could not determine file name of converted component");
|
|
173769
174128
|
}
|
|
173770
|
-
const importsDir =
|
|
173771
|
-
await
|
|
173772
|
-
const filePath =
|
|
173773
|
-
await
|
|
174129
|
+
const importsDir = path56.join(projectDir, "imports");
|
|
174130
|
+
await fs56.mkdir(importsDir, { recursive: true });
|
|
174131
|
+
const filePath = path56.join(importsDir, `${fileName}.tsx`);
|
|
174132
|
+
await fs56.writeFile(filePath, tsx);
|
|
173774
174133
|
return { filePath };
|
|
173775
174134
|
};
|
|
173776
174135
|
|
|
@@ -175114,13 +175473,13 @@ var registerImport = (program2) => {
|
|
|
175114
175473
|
};
|
|
175115
175474
|
|
|
175116
175475
|
// cli/init/register.ts
|
|
175117
|
-
import * as
|
|
175118
|
-
import * as
|
|
175476
|
+
import * as fs58 from "node:fs";
|
|
175477
|
+
import * as path59 from "node:path";
|
|
175119
175478
|
|
|
175120
175479
|
// lib/shared/generate-gitignore-file.ts
|
|
175121
|
-
import
|
|
175480
|
+
import path57 from "node:path";
|
|
175122
175481
|
var generateGitIgnoreFile = (dir) => {
|
|
175123
|
-
const gitignorePath =
|
|
175482
|
+
const gitignorePath = path57.join(dir, ".gitignore");
|
|
175124
175483
|
const gitignoreContent = `# Dependencies
|
|
175125
175484
|
node_modules/
|
|
175126
175485
|
|
|
@@ -175155,8 +175514,8 @@ yarn-error.log*
|
|
|
175155
175514
|
};
|
|
175156
175515
|
|
|
175157
175516
|
// lib/shared/setup-tscircuit-skill.ts
|
|
175158
|
-
import * as
|
|
175159
|
-
import * as
|
|
175517
|
+
import * as fs57 from "node:fs";
|
|
175518
|
+
import * as path58 from "node:path";
|
|
175160
175519
|
var SKILL_REPO_API_URL = "https://api.github.com/repos/tscircuit/skill/contents";
|
|
175161
175520
|
var SKILL_DIR_NAME = ".claude/skills/tscircuit";
|
|
175162
175521
|
async function fetchGitHubContents(apiUrl) {
|
|
@@ -175176,36 +175535,36 @@ async function fetchFileContent(downloadUrl) {
|
|
|
175176
175535
|
async function downloadDirectory(apiUrl, targetDir) {
|
|
175177
175536
|
const contents = await fetchGitHubContents(apiUrl);
|
|
175178
175537
|
for (const item of contents) {
|
|
175179
|
-
const targetPath =
|
|
175538
|
+
const targetPath = path58.join(targetDir, item.name);
|
|
175180
175539
|
if (item.type === "dir") {
|
|
175181
|
-
|
|
175540
|
+
fs57.mkdirSync(targetPath, { recursive: true });
|
|
175182
175541
|
await downloadDirectory(`${apiUrl}/${item.name}`, targetPath);
|
|
175183
175542
|
} else if (item.type === "file" && item.download_url) {
|
|
175184
175543
|
const content = await fetchFileContent(item.download_url);
|
|
175185
|
-
|
|
175544
|
+
fs57.writeFileSync(targetPath, content, "utf-8");
|
|
175186
175545
|
}
|
|
175187
175546
|
}
|
|
175188
175547
|
}
|
|
175189
175548
|
async function downloadSkillRepo(targetDir) {
|
|
175190
|
-
|
|
175549
|
+
fs57.mkdirSync(targetDir, { recursive: true });
|
|
175191
175550
|
const rootContents = await fetchGitHubContents(SKILL_REPO_API_URL);
|
|
175192
175551
|
for (const item of rootContents) {
|
|
175193
175552
|
if (item.name === ".git" || item.name === ".github") {
|
|
175194
175553
|
continue;
|
|
175195
175554
|
}
|
|
175196
|
-
const targetPath =
|
|
175555
|
+
const targetPath = path58.join(targetDir, item.name);
|
|
175197
175556
|
if (item.type === "dir") {
|
|
175198
|
-
|
|
175557
|
+
fs57.mkdirSync(targetPath, { recursive: true });
|
|
175199
175558
|
await downloadDirectory(`${SKILL_REPO_API_URL}/${item.name}`, targetPath);
|
|
175200
175559
|
} else if (item.type === "file" && item.download_url) {
|
|
175201
175560
|
const content = await fetchFileContent(item.download_url);
|
|
175202
|
-
|
|
175561
|
+
fs57.writeFileSync(targetPath, content, "utf-8");
|
|
175203
175562
|
}
|
|
175204
175563
|
}
|
|
175205
175564
|
}
|
|
175206
175565
|
async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
175207
|
-
const skillDir =
|
|
175208
|
-
if (
|
|
175566
|
+
const skillDir = path58.join(projectDir, SKILL_DIR_NAME);
|
|
175567
|
+
if (fs57.existsSync(path58.join(skillDir, "SKILL.md"))) {
|
|
175209
175568
|
console.log("Claude skill already exists, skipping...");
|
|
175210
175569
|
return true;
|
|
175211
175570
|
}
|
|
@@ -175324,7 +175683,7 @@ var registerInit = (program3) => {
|
|
|
175324
175683
|
}
|
|
175325
175684
|
}
|
|
175326
175685
|
}
|
|
175327
|
-
const projectDir = directory ?
|
|
175686
|
+
const projectDir = directory ? path59.resolve(process.cwd(), directory) : process.cwd();
|
|
175328
175687
|
let tsciHandle = null;
|
|
175329
175688
|
const token = getSessionToken();
|
|
175330
175689
|
if (token) {
|
|
@@ -175335,7 +175694,7 @@ var registerInit = (program3) => {
|
|
|
175335
175694
|
}
|
|
175336
175695
|
} catch {}
|
|
175337
175696
|
}
|
|
175338
|
-
const dirName =
|
|
175697
|
+
const dirName = path59.basename(projectDir);
|
|
175339
175698
|
let defaultPackageName = dirName;
|
|
175340
175699
|
if (tsciHandle) {
|
|
175341
175700
|
defaultPackageName = `@tsci/${tsciHandle}.${dirName}`;
|
|
@@ -175353,8 +175712,8 @@ var registerInit = (program3) => {
|
|
|
175353
175712
|
authorName = account.tscircuit_handle;
|
|
175354
175713
|
}
|
|
175355
175714
|
}
|
|
175356
|
-
|
|
175357
|
-
writeFileIfNotExists(
|
|
175715
|
+
fs58.mkdirSync(projectDir, { recursive: true });
|
|
175716
|
+
writeFileIfNotExists(path59.join(projectDir, "index.circuit.tsx"), `
|
|
175358
175717
|
export default () => (
|
|
175359
175718
|
<board>
|
|
175360
175719
|
<resistor resistance="1k" footprint="0402" name="R1" />
|
|
@@ -175366,7 +175725,7 @@ export default () => (
|
|
|
175366
175725
|
if (saveProjectConfig(null, projectDir)) {
|
|
175367
175726
|
console.log("Created tscircuit.config.json with schema");
|
|
175368
175727
|
}
|
|
175369
|
-
writeFileIfNotExists(
|
|
175728
|
+
writeFileIfNotExists(path59.join(projectDir, ".npmrc"), `
|
|
175370
175729
|
@tsci:registry=https://npm.tscircuit.com
|
|
175371
175730
|
`);
|
|
175372
175731
|
console.log("Generating package.json");
|
|
@@ -175517,14 +175876,14 @@ class KeyStore {
|
|
|
175517
175876
|
}
|
|
175518
175877
|
}
|
|
175519
175878
|
function createKey(key) {
|
|
175520
|
-
let
|
|
175879
|
+
let path60 = null;
|
|
175521
175880
|
let id = null;
|
|
175522
175881
|
let src = null;
|
|
175523
175882
|
let weight = 1;
|
|
175524
175883
|
let getFn = null;
|
|
175525
175884
|
if (isString2(key) || isArray(key)) {
|
|
175526
175885
|
src = key;
|
|
175527
|
-
|
|
175886
|
+
path60 = createKeyPath(key);
|
|
175528
175887
|
id = createKeyId(key);
|
|
175529
175888
|
} else {
|
|
175530
175889
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -175538,11 +175897,11 @@ function createKey(key) {
|
|
|
175538
175897
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
175539
175898
|
}
|
|
175540
175899
|
}
|
|
175541
|
-
|
|
175900
|
+
path60 = createKeyPath(name);
|
|
175542
175901
|
id = createKeyId(name);
|
|
175543
175902
|
getFn = key.getFn;
|
|
175544
175903
|
}
|
|
175545
|
-
return { path:
|
|
175904
|
+
return { path: path60, id, weight, src, getFn };
|
|
175546
175905
|
}
|
|
175547
175906
|
function createKeyPath(key) {
|
|
175548
175907
|
return isArray(key) ? key : key.split(".");
|
|
@@ -175550,34 +175909,34 @@ function createKeyPath(key) {
|
|
|
175550
175909
|
function createKeyId(key) {
|
|
175551
175910
|
return isArray(key) ? key.join(".") : key;
|
|
175552
175911
|
}
|
|
175553
|
-
function get(obj,
|
|
175912
|
+
function get(obj, path60) {
|
|
175554
175913
|
let list = [];
|
|
175555
175914
|
let arr = false;
|
|
175556
|
-
const deepGet = (obj2,
|
|
175915
|
+
const deepGet = (obj2, path61, index) => {
|
|
175557
175916
|
if (!isDefined(obj2)) {
|
|
175558
175917
|
return;
|
|
175559
175918
|
}
|
|
175560
|
-
if (!
|
|
175919
|
+
if (!path61[index]) {
|
|
175561
175920
|
list.push(obj2);
|
|
175562
175921
|
} else {
|
|
175563
|
-
let key =
|
|
175922
|
+
let key = path61[index];
|
|
175564
175923
|
const value = obj2[key];
|
|
175565
175924
|
if (!isDefined(value)) {
|
|
175566
175925
|
return;
|
|
175567
175926
|
}
|
|
175568
|
-
if (index ===
|
|
175927
|
+
if (index === path61.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
|
|
175569
175928
|
list.push(toString(value));
|
|
175570
175929
|
} else if (isArray(value)) {
|
|
175571
175930
|
arr = true;
|
|
175572
175931
|
for (let i3 = 0, len = value.length;i3 < len; i3 += 1) {
|
|
175573
|
-
deepGet(value[i3],
|
|
175932
|
+
deepGet(value[i3], path61, index + 1);
|
|
175574
175933
|
}
|
|
175575
|
-
} else if (
|
|
175576
|
-
deepGet(value,
|
|
175934
|
+
} else if (path61.length) {
|
|
175935
|
+
deepGet(value, path61, index + 1);
|
|
175577
175936
|
}
|
|
175578
175937
|
}
|
|
175579
175938
|
};
|
|
175580
|
-
deepGet(obj, isString2(
|
|
175939
|
+
deepGet(obj, isString2(path60) ? path60.split(".") : path60, 0);
|
|
175581
175940
|
return arr ? list : list[0];
|
|
175582
175941
|
}
|
|
175583
175942
|
var MatchOptions = {
|
|
@@ -176781,8 +177140,8 @@ var registerSearch = (program3) => {
|
|
|
176781
177140
|
}
|
|
176782
177141
|
if (kicadResults.length) {
|
|
176783
177142
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
176784
|
-
kicadResults.forEach((
|
|
176785
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
177143
|
+
kicadResults.forEach((path60, idx) => {
|
|
177144
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path60.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
176786
177145
|
});
|
|
176787
177146
|
}
|
|
176788
177147
|
if (results.packages.length) {
|
|
@@ -176806,22 +177165,22 @@ var registerSearch = (program3) => {
|
|
|
176806
177165
|
};
|
|
176807
177166
|
|
|
176808
177167
|
// lib/shared/setup-github-actions.ts
|
|
176809
|
-
import
|
|
176810
|
-
import
|
|
177168
|
+
import fs59 from "node:fs";
|
|
177169
|
+
import path60 from "node:path";
|
|
176811
177170
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
176812
177171
|
const findGitRoot = (startDir) => {
|
|
176813
|
-
let dir =
|
|
176814
|
-
while (dir !==
|
|
176815
|
-
if (
|
|
177172
|
+
let dir = path60.resolve(startDir);
|
|
177173
|
+
while (dir !== path60.parse(dir).root) {
|
|
177174
|
+
if (fs59.existsSync(path60.join(dir, ".git"))) {
|
|
176816
177175
|
return dir;
|
|
176817
177176
|
}
|
|
176818
|
-
dir =
|
|
177177
|
+
dir = path60.dirname(dir);
|
|
176819
177178
|
}
|
|
176820
177179
|
return null;
|
|
176821
177180
|
};
|
|
176822
177181
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
176823
|
-
const workflowsDir =
|
|
176824
|
-
|
|
177182
|
+
const workflowsDir = path60.join(gitRoot, ".github", "workflows");
|
|
177183
|
+
fs59.mkdirSync(workflowsDir, { recursive: true });
|
|
176825
177184
|
const buildWorkflow = `name: tscircuit Build
|
|
176826
177185
|
|
|
176827
177186
|
on:
|
|
@@ -176860,8 +177219,8 @@ jobs:
|
|
|
176860
177219
|
- run: bun install
|
|
176861
177220
|
- run: bunx tsci snapshot
|
|
176862
177221
|
`;
|
|
176863
|
-
writeFileIfNotExists(
|
|
176864
|
-
writeFileIfNotExists(
|
|
177222
|
+
writeFileIfNotExists(path60.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
177223
|
+
writeFileIfNotExists(path60.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
176865
177224
|
};
|
|
176866
177225
|
|
|
176867
177226
|
// cli/setup/register.ts
|
|
@@ -176973,8 +177332,8 @@ var registerSimulate = (program3) => {
|
|
|
176973
177332
|
};
|
|
176974
177333
|
|
|
176975
177334
|
// lib/shared/snapshot-project.ts
|
|
176976
|
-
import
|
|
176977
|
-
import
|
|
177335
|
+
import fs61 from "node:fs";
|
|
177336
|
+
import path61 from "node:path";
|
|
176978
177337
|
import {
|
|
176979
177338
|
convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
|
|
176980
177339
|
getBestCameraPosition
|
|
@@ -176988,7 +177347,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
176988
177347
|
|
|
176989
177348
|
// lib/shared/compare-images.ts
|
|
176990
177349
|
import looksSame from "looks-same";
|
|
176991
|
-
import
|
|
177350
|
+
import fs60 from "node:fs/promises";
|
|
176992
177351
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
176993
177352
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
176994
177353
|
strict: false,
|
|
@@ -177004,7 +177363,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
177004
177363
|
tolerance: 2
|
|
177005
177364
|
});
|
|
177006
177365
|
} else {
|
|
177007
|
-
await
|
|
177366
|
+
await fs60.writeFile(diffPath, buffer2);
|
|
177008
177367
|
}
|
|
177009
177368
|
}
|
|
177010
177369
|
return { equal: equal2 };
|
|
@@ -177030,7 +177389,7 @@ var snapshotProject = async ({
|
|
|
177030
177389
|
...DEFAULT_IGNORED_PATTERNS,
|
|
177031
177390
|
...ignored.map(normalizeIgnorePattern)
|
|
177032
177391
|
];
|
|
177033
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
177392
|
+
const resolvedPaths = filePaths.map((f2) => path61.resolve(projectDir, f2));
|
|
177034
177393
|
const boardFiles = findBoardFiles({
|
|
177035
177394
|
projectDir,
|
|
177036
177395
|
ignore,
|
|
@@ -177048,13 +177407,13 @@ var snapshotProject = async ({
|
|
|
177048
177407
|
return normalizedPath.endsWith(".circuit.json") || normalizedPath.endsWith("/circuit.json");
|
|
177049
177408
|
};
|
|
177050
177409
|
for (const file of boardFiles) {
|
|
177051
|
-
const relativeFilePath =
|
|
177410
|
+
const relativeFilePath = path61.relative(projectDir, file);
|
|
177052
177411
|
let circuitJson;
|
|
177053
177412
|
let pcbSvg;
|
|
177054
177413
|
let schSvg;
|
|
177055
177414
|
try {
|
|
177056
177415
|
if (isCircuitJsonFile(file)) {
|
|
177057
|
-
const parsed = JSON.parse(
|
|
177416
|
+
const parsed = JSON.parse(fs61.readFileSync(file, "utf-8"));
|
|
177058
177417
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
177059
177418
|
} else {
|
|
177060
177419
|
const completePlatformConfig = getCompletePlatformConfig(platformConfig2);
|
|
@@ -177104,17 +177463,17 @@ var snapshotProject = async ({
|
|
|
177104
177463
|
} catch (error) {
|
|
177105
177464
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
177106
177465
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
177107
|
-
const fileDir =
|
|
177108
|
-
const relativeDir =
|
|
177109
|
-
const snapDir2 = snapshotsDirName ?
|
|
177110
|
-
const base2 =
|
|
177111
|
-
const snap3dPath =
|
|
177112
|
-
const existing3dSnapshot =
|
|
177466
|
+
const fileDir = path61.dirname(file);
|
|
177467
|
+
const relativeDir = path61.relative(projectDir, fileDir);
|
|
177468
|
+
const snapDir2 = snapshotsDirName ? path61.join(projectDir, snapshotsDirName, relativeDir) : path61.join(fileDir, "__snapshots__");
|
|
177469
|
+
const base2 = path61.basename(file).replace(/\.[^.]+$/, "");
|
|
177470
|
+
const snap3dPath = path61.join(snapDir2, `${base2}-3d.snap.png`);
|
|
177471
|
+
const existing3dSnapshot = fs61.existsSync(snap3dPath);
|
|
177113
177472
|
if (existing3dSnapshot) {
|
|
177114
177473
|
onError(kleur_default.red(`
|
|
177115
177474
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
177116
177475
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
177117
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
177476
|
+
`) + kleur_default.red(` Existing snapshot: ${path61.relative(projectDir, snap3dPath)}
|
|
177118
177477
|
`));
|
|
177119
177478
|
return onExit2(1);
|
|
177120
177479
|
} else {
|
|
@@ -177130,9 +177489,9 @@ var snapshotProject = async ({
|
|
|
177130
177489
|
}
|
|
177131
177490
|
}
|
|
177132
177491
|
}
|
|
177133
|
-
const snapDir = snapshotsDirName ?
|
|
177134
|
-
|
|
177135
|
-
const base =
|
|
177492
|
+
const snapDir = snapshotsDirName ? path61.join(projectDir, snapshotsDirName, path61.relative(projectDir, path61.dirname(file))) : path61.join(path61.dirname(file), "__snapshots__");
|
|
177493
|
+
fs61.mkdirSync(snapDir, { recursive: true });
|
|
177494
|
+
const base = path61.basename(file).replace(/\.[^.]+$/, "");
|
|
177136
177495
|
const snapshots = [];
|
|
177137
177496
|
if (pcbOnly || !schematicOnly) {
|
|
177138
177497
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -177150,31 +177509,31 @@ var snapshotProject = async ({
|
|
|
177150
177509
|
for (const snapshot of snapshots) {
|
|
177151
177510
|
const { type } = snapshot;
|
|
177152
177511
|
const is3d = type === "3d";
|
|
177153
|
-
const snapPath =
|
|
177154
|
-
const existing =
|
|
177512
|
+
const snapPath = path61.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
177513
|
+
const existing = fs61.existsSync(snapPath);
|
|
177155
177514
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
177156
177515
|
const newContentForFile = snapshot.content;
|
|
177157
177516
|
if (!existing) {
|
|
177158
|
-
|
|
177159
|
-
console.log("✅", kleur_default.gray(
|
|
177517
|
+
fs61.writeFileSync(snapPath, newContentForFile);
|
|
177518
|
+
console.log("✅", kleur_default.gray(path61.relative(projectDir, snapPath)));
|
|
177160
177519
|
didUpdate = true;
|
|
177161
177520
|
continue;
|
|
177162
177521
|
}
|
|
177163
|
-
const oldContentBuffer =
|
|
177522
|
+
const oldContentBuffer = fs61.readFileSync(snapPath);
|
|
177164
177523
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
177165
177524
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
|
|
177166
177525
|
if (update) {
|
|
177167
177526
|
if (!forceUpdate && equal2) {
|
|
177168
|
-
console.log("✅", kleur_default.gray(
|
|
177527
|
+
console.log("✅", kleur_default.gray(path61.relative(projectDir, snapPath)));
|
|
177169
177528
|
} else {
|
|
177170
|
-
|
|
177171
|
-
console.log("✅", kleur_default.gray(
|
|
177529
|
+
fs61.writeFileSync(snapPath, newContentForFile);
|
|
177530
|
+
console.log("✅", kleur_default.gray(path61.relative(projectDir, snapPath)));
|
|
177172
177531
|
didUpdate = true;
|
|
177173
177532
|
}
|
|
177174
177533
|
} else if (!equal2) {
|
|
177175
177534
|
mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
177176
177535
|
} else {
|
|
177177
|
-
console.log("✅", kleur_default.gray(
|
|
177536
|
+
console.log("✅", kleur_default.gray(path61.relative(projectDir, snapPath)));
|
|
177178
177537
|
}
|
|
177179
177538
|
}
|
|
177180
177539
|
}
|
|
@@ -177214,7 +177573,7 @@ var registerSnapshot = (program3) => {
|
|
|
177214
177573
|
};
|
|
177215
177574
|
|
|
177216
177575
|
// cli/transpile/register.ts
|
|
177217
|
-
import
|
|
177576
|
+
import path62 from "node:path";
|
|
177218
177577
|
var registerTranspile = (program3) => {
|
|
177219
177578
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
177220
177579
|
try {
|
|
@@ -177222,7 +177581,7 @@ var registerTranspile = (program3) => {
|
|
|
177222
177581
|
fileOrDir: file,
|
|
177223
177582
|
includeBoardFiles: false
|
|
177224
177583
|
});
|
|
177225
|
-
const distDir =
|
|
177584
|
+
const distDir = path62.join(projectDir, "dist");
|
|
177226
177585
|
validateMainInDist(projectDir, distDir);
|
|
177227
177586
|
console.log("Transpiling entry file...");
|
|
177228
177587
|
const entryFile = mainEntrypoint || circuitFiles[0];
|