diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index bb0b4530..0aae22d3 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -3,6 +3,9 @@ name: Bun Test on: pull_request: + push: + branches: + - main jobs: test: diff --git a/bun.lockb b/bun.lockb index 2dd6691c..cbce0a00 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/fake-snippets-api/lib/db/seed.ts b/fake-snippets-api/lib/db/seed.ts index dde0da47..a6d86017 100644 --- a/fake-snippets-api/lib/db/seed.ts +++ b/fake-snippets-api/lib/db/seed.ts @@ -36,6 +36,498 @@ export default () => ( updated_at: new Date().toISOString(), snippet_type: "board", description: "A simple board with an A555 Timer component", + circuit_json: [ + { + type: "source_port", + source_port_id: "source_port_0", + name: "pin1", + pin_number: 1, + port_hints: ["pin1", "1"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_1", + name: "pin2", + pin_number: 2, + port_hints: ["pin2", "2"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_2", + name: "pin3", + pin_number: 3, + port_hints: ["pin3", "3"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_3", + name: "pin4", + pin_number: 4, + port_hints: ["pin4", "4"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_4", + name: "pin5", + pin_number: 5, + port_hints: ["pin5", "5"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_5", + name: "pin6", + pin_number: 6, + port_hints: ["pin6", "6"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_6", + name: "pin7", + pin_number: 7, + port_hints: ["pin7", "7"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_7", + name: "pin8", + pin_number: 8, + port_hints: ["pin8", "8"], + source_component_id: "source_component_0", + }, + { + type: "source_component", + source_component_id: "source_component_0", + ftype: "simple_chip", + name: "U1", + supplier_part_numbers: {}, + }, + { + type: "schematic_component", + schematic_component_id: "schematic_component_0", + center: { + x: 0, + y: 0, + }, + rotation: 0, + size: { + width: 1.1, + height: 1, + }, + pin_spacing: 0.2, + port_labels: {}, + source_component_id: "source_component_0", + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_0", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_0", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 1, + true_ccw_index: 0, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_1", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.10000000000000003, + }, + source_port_id: "source_port_1", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 2, + true_ccw_index: 1, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_2", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.09999999999999998, + }, + source_port_id: "source_port_2", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 3, + true_ccw_index: 2, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_3", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_3", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 4, + true_ccw_index: 3, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_4", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_4", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 5, + true_ccw_index: 4, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_5", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.10000000000000003, + }, + source_port_id: "source_port_5", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 6, + true_ccw_index: 5, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_6", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.09999999999999998, + }, + source_port_id: "source_port_6", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 7, + true_ccw_index: 6, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_7", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_7", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 8, + true_ccw_index: 7, + }, + { + type: "pcb_component", + pcb_component_id: "pcb_component_0", + center: { + x: 0, + y: 0, + }, + width: 8.82, + height: 8.82, + layer: "top", + rotation: 0, + source_component_id: "source_component_0", + }, + { + type: "pcb_board", + pcb_board_id: "pcb_board_0", + center: { + x: 0, + y: 0, + }, + thickness: 1.4, + num_layers: 4, + width: 10, + height: 10, + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_0", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_0", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["1"], + x: -3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_1", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_1", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["2"], + x: -3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_2", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_2", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["3"], + x: -3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_3", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_3", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["4"], + x: -3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_4", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_4", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["5"], + x: 3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_5", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_5", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["6"], + x: 3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_6", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_6", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["7"], + x: 3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_7", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_7", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["8"], + x: 3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_silkscreen_path", + pcb_silkscreen_path_id: "pcb_silkscreen_path_0", + pcb_component_id: "pcb_component_0", + layer: "top", + route: [ + { + x: -3.01, + y: -4.61, + }, + { + x: -3.01, + y: 4.61, + }, + { + x: -1.0033333333333332, + y: 4.61, + }, + { + x: -0.9269591309529909, + y: 4.226040956193693, + }, + { + x: -0.7094638037905026, + y: 3.9005361962094978, + }, + { + x: -0.3839590438063067, + y: 3.6830408690470096, + }, + { + x: 6.143644775722556e-17, + y: 3.6066666666666674, + }, + { + x: 0.38395904380630674, + y: 3.6830408690470096, + }, + { + x: 0.7094638037905027, + y: 3.9005361962094978, + }, + { + x: 0.9269591309529909, + y: 4.226040956193693, + }, + { + x: 1.0033333333333332, + y: 4.61, + }, + { + x: 3.01, + y: 4.61, + }, + { + x: 3.01, + y: -4.61, + }, + { + x: -3.01, + y: -4.61, + }, + ], + stroke_width: 0.1, + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_0", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 3.81, + source_port_id: "source_port_0", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_1", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 1.27, + source_port_id: "source_port_1", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_2", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -1.27, + source_port_id: "source_port_2", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_3", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -3.81, + source_port_id: "source_port_3", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_4", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -3.81, + source_port_id: "source_port_4", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_5", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -1.27, + source_port_id: "source_port_5", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_6", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 1.27, + source_port_id: "source_port_6", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_7", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 3.81, + source_port_id: "source_port_7", + }, + { + type: "cad_component", + cad_component_id: "cad_component_0", + position: { + x: 0, + y: 0, + z: 0.7, + }, + rotation: { + x: 0, + y: 0, + z: 0, + }, + pcb_component_id: "pcb_component_0", + source_component_id: "source_component_0", + footprinter_string: "dip8", + }, + ], }) // Define the @tsci/seveibar.a555timer package @@ -74,6 +566,497 @@ exports.A555Timer = A555Timer; updated_at: new Date().toISOString(), snippet_type: "package", description: "A simple package with an A555 Timer component", + circuit_json: [ + { + type: "source_port", + source_port_id: "source_port_0", + name: "pin1", + pin_number: 1, + port_hints: ["pin1", "1"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_1", + name: "pin2", + pin_number: 2, + port_hints: ["pin2", "2"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_2", + name: "pin3", + pin_number: 3, + port_hints: ["pin3", "3"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_3", + name: "pin4", + pin_number: 4, + port_hints: ["pin4", "4"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_4", + name: "pin5", + pin_number: 5, + port_hints: ["pin5", "5"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_5", + name: "pin6", + pin_number: 6, + port_hints: ["pin6", "6"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_6", + name: "pin7", + pin_number: 7, + port_hints: ["pin7", "7"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_7", + name: "pin8", + pin_number: 8, + port_hints: ["pin8", "8"], + source_component_id: "source_component_0", + }, + { + type: "source_component", + source_component_id: "source_component_0", + ftype: "simple_chip", + name: "U1", + }, + { + type: "schematic_component", + schematic_component_id: "schematic_component_0", + center: { + x: 0, + y: 0, + }, + rotation: 0, + size: { + width: 1.1, + height: 1, + }, + pin_spacing: 0.2, + port_labels: {}, + source_component_id: "source_component_0", + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_0", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_0", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 1, + true_ccw_index: 0, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_1", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.10000000000000003, + }, + source_port_id: "source_port_1", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 2, + true_ccw_index: 1, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_2", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.09999999999999998, + }, + source_port_id: "source_port_2", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 3, + true_ccw_index: 2, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_3", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_3", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 4, + true_ccw_index: 3, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_4", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_4", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 5, + true_ccw_index: 4, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_5", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.10000000000000003, + }, + source_port_id: "source_port_5", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 6, + true_ccw_index: 5, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_6", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.09999999999999998, + }, + source_port_id: "source_port_6", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 7, + true_ccw_index: 6, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_7", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_7", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 8, + true_ccw_index: 7, + }, + { + type: "pcb_component", + pcb_component_id: "pcb_component_0", + center: { + x: 0, + y: 0, + }, + width: 8.82, + height: 8.82, + layer: "top", + rotation: 0, + source_component_id: "source_component_0", + }, + { + type: "pcb_board", + pcb_board_id: "pcb_board_0", + center: { + x: 0, + y: 0, + }, + thickness: 1.4, + num_layers: 4, + width: 50, + height: 50, + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_0", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_0", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["1"], + x: -3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_1", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_1", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["2"], + x: -3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_2", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_2", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["3"], + x: -3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_3", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_3", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["4"], + x: -3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_4", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_4", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["5"], + x: 3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_5", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_5", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["6"], + x: 3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_6", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_6", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["7"], + x: 3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_7", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_7", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["8"], + x: 3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_silkscreen_path", + pcb_silkscreen_path_id: "pcb_silkscreen_path_0", + pcb_component_id: "pcb_component_0", + layer: "top", + route: [ + { + x: -3.01, + y: -4.61, + }, + { + x: -3.01, + y: 4.61, + }, + { + x: -1.0033333333333332, + y: 4.61, + }, + { + x: -0.9269591309529909, + y: 4.226040956193693, + }, + { + x: -0.7094638037905026, + y: 3.9005361962094978, + }, + { + x: -0.3839590438063067, + y: 3.6830408690470096, + }, + { + x: 6.143644775722556e-17, + y: 3.6066666666666674, + }, + { + x: 0.38395904380630674, + y: 3.6830408690470096, + }, + { + x: 0.7094638037905027, + y: 3.9005361962094978, + }, + { + x: 0.9269591309529909, + y: 4.226040956193693, + }, + { + x: 1.0033333333333332, + y: 4.61, + }, + { + x: 3.01, + y: 4.61, + }, + { + x: 3.01, + y: -4.61, + }, + { + x: -3.01, + y: -4.61, + }, + ], + stroke_width: 0.1, + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_0", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 3.81, + source_port_id: "source_port_0", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_1", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 1.27, + source_port_id: "source_port_1", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_2", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -1.27, + source_port_id: "source_port_2", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_3", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -3.81, + source_port_id: "source_port_3", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_4", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -3.81, + source_port_id: "source_port_4", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_5", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -1.27, + source_port_id: "source_port_5", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_6", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 1.27, + source_port_id: "source_port_6", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_7", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 3.81, + source_port_id: "source_port_7", + }, + { + type: "cad_component", + cad_component_id: "cad_component_0", + position: { + x: 0, + y: 0, + z: 0.7, + }, + rotation: { + x: 0, + y: 0, + z: 0, + }, + pcb_component_id: "pcb_component_0", + source_component_id: "source_component_0", + footprinter_string: "dip8", + }, + ], }) // Add a snippet that outputs a square waveform using the a555timer @@ -97,6 +1080,497 @@ export const SquareWaveModule = () => ( snippet_type: "package", description: "A simple package that outputs a square waveform using the a555timer", + circuit_json: [ + { + type: "source_port", + source_port_id: "source_port_0", + name: "pin1", + pin_number: 1, + port_hints: ["pin1", "1"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_1", + name: "pin2", + pin_number: 2, + port_hints: ["pin2", "2"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_2", + name: "pin3", + pin_number: 3, + port_hints: ["pin3", "3"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_3", + name: "pin4", + pin_number: 4, + port_hints: ["pin4", "4"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_4", + name: "pin5", + pin_number: 5, + port_hints: ["pin5", "5"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_5", + name: "pin6", + pin_number: 6, + port_hints: ["pin6", "6"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_6", + name: "pin7", + pin_number: 7, + port_hints: ["pin7", "7"], + source_component_id: "source_component_0", + }, + { + type: "source_port", + source_port_id: "source_port_7", + name: "pin8", + pin_number: 8, + port_hints: ["pin8", "8"], + source_component_id: "source_component_0", + }, + { + type: "source_component", + source_component_id: "source_component_0", + ftype: "simple_chip", + name: "U1", + }, + { + type: "schematic_component", + schematic_component_id: "schematic_component_0", + center: { + x: 0, + y: 0, + }, + rotation: 0, + size: { + width: 1.1, + height: 1, + }, + pin_spacing: 0.2, + port_labels: {}, + source_component_id: "source_component_0", + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_0", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_0", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 1, + true_ccw_index: 0, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_1", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: 0.10000000000000003, + }, + source_port_id: "source_port_1", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 2, + true_ccw_index: 1, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_2", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.09999999999999998, + }, + source_port_id: "source_port_2", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 3, + true_ccw_index: 2, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_3", + schematic_component_id: "schematic_component_0", + center: { + x: -0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_3", + facing_direction: "left", + distance_from_component_edge: 0.4, + side_of_component: "left", + pin_number: 4, + true_ccw_index: 3, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_4", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.30000000000000004, + }, + source_port_id: "source_port_4", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 5, + true_ccw_index: 4, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_5", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: -0.10000000000000003, + }, + source_port_id: "source_port_5", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 6, + true_ccw_index: 5, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_6", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.09999999999999998, + }, + source_port_id: "source_port_6", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 7, + true_ccw_index: 6, + }, + { + type: "schematic_port", + schematic_port_id: "schematic_port_7", + schematic_component_id: "schematic_component_0", + center: { + x: 0.9500000000000001, + y: 0.30000000000000004, + }, + source_port_id: "source_port_7", + facing_direction: "right", + distance_from_component_edge: 0.4, + side_of_component: "right", + pin_number: 8, + true_ccw_index: 7, + }, + { + type: "pcb_component", + pcb_component_id: "pcb_component_0", + center: { + x: 0, + y: 0, + }, + width: 8.82, + height: 8.82, + layer: "top", + rotation: 0, + source_component_id: "source_component_0", + }, + { + type: "pcb_board", + pcb_board_id: "pcb_board_0", + center: { + x: 0, + y: 0, + }, + thickness: 1.4, + num_layers: 4, + width: 50, + height: 50, + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_0", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_0", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["1"], + x: -3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_1", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_1", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["2"], + x: -3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_2", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_2", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["3"], + x: -3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_3", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_3", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["4"], + x: -3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_4", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_4", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["5"], + x: 3.81, + y: -3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_5", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_5", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["6"], + x: 3.81, + y: -1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_6", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_6", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["7"], + x: 3.81, + y: 1.27, + layers: ["top", "bottom"], + }, + { + type: "pcb_plated_hole", + pcb_plated_hole_id: "pcb_plated_hole_7", + pcb_component_id: "pcb_component_0", + pcb_port_id: "pcb_port_7", + outer_diameter: 1.2, + hole_diameter: 1, + shape: "circle", + port_hints: ["8"], + x: 3.81, + y: 3.81, + layers: ["top", "bottom"], + }, + { + type: "pcb_silkscreen_path", + pcb_silkscreen_path_id: "pcb_silkscreen_path_0", + pcb_component_id: "pcb_component_0", + layer: "top", + route: [ + { + x: -3.01, + y: -4.61, + }, + { + x: -3.01, + y: 4.61, + }, + { + x: -1.0033333333333332, + y: 4.61, + }, + { + x: -0.9269591309529909, + y: 4.226040956193693, + }, + { + x: -0.7094638037905026, + y: 3.9005361962094978, + }, + { + x: -0.3839590438063067, + y: 3.6830408690470096, + }, + { + x: 6.143644775722556e-17, + y: 3.6066666666666674, + }, + { + x: 0.38395904380630674, + y: 3.6830408690470096, + }, + { + x: 0.7094638037905027, + y: 3.9005361962094978, + }, + { + x: 0.9269591309529909, + y: 4.226040956193693, + }, + { + x: 1.0033333333333332, + y: 4.61, + }, + { + x: 3.01, + y: 4.61, + }, + { + x: 3.01, + y: -4.61, + }, + { + x: -3.01, + y: -4.61, + }, + ], + stroke_width: 0.1, + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_0", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 3.81, + source_port_id: "source_port_0", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_1", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: 1.27, + source_port_id: "source_port_1", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_2", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -1.27, + source_port_id: "source_port_2", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_3", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: -3.81, + y: -3.81, + source_port_id: "source_port_3", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_4", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -3.81, + source_port_id: "source_port_4", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_5", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: -1.27, + source_port_id: "source_port_5", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_6", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 1.27, + source_port_id: "source_port_6", + }, + { + type: "pcb_port", + pcb_port_id: "pcb_port_7", + pcb_component_id: "pcb_component_0", + layers: ["top", "inner1", "inner2", "bottom"], + x: 3.81, + y: 3.81, + source_port_id: "source_port_7", + }, + { + type: "cad_component", + cad_component_id: "cad_component_0", + position: { + x: 0, + y: 0, + z: 0.7, + }, + rotation: { + x: 0, + y: 0, + z: 0, + }, + pcb_component_id: "pcb_component_0", + source_component_id: "source_component_0", + footprinter_string: "dip8", + }, + ], }) db.addOrder({ diff --git a/package.json b/package.json index 099925b7..73108c63 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@radix-ui/react-toggle": "^1.1.0", "@radix-ui/react-toggle-group": "^1.1.0", "@radix-ui/react-tooltip": "^1.1.2", - "@tscircuit/3d-viewer": "^0.0.36", + "@tscircuit/3d-viewer": "^0.0.38", "@tscircuit/footprinter": "^0.0.87", "@tscircuit/layout": "^0.0.29", "@tscircuit/mm": "^0.0.8", @@ -88,7 +88,7 @@ "immer": "^10.1.1", "input-otp": "^1.2.4", "jose": "^5.9.3", - "jscad-electronics": "^0.0.11", + "jscad-electronics": "^0.0.20", "jszip": "^3.10.1", "lucide-react": "^0.445.0", "ms": "^2.1.3", @@ -114,7 +114,7 @@ "@babel/standalone": "^7.25.6", "@biomejs/biome": "^1.9.2", "@playwright/test": "^1.48.0", - "@tscircuit/core": "^0.0.177", + "@tscircuit/core": "^0.0.180", "@tscircuit/prompt-benchmarks": "^0.0.15", "@types/babel__standalone": "^7.1.7", "@types/bun": "^1.1.10", @@ -126,7 +126,7 @@ "@typescript/vfs": "^1.6.0", "@vitejs/plugin-react": "^4.3.1", "autoprefixer": "^10.4.20", - "circuit-to-svg": "^0.0.76", + "circuit-to-svg": "^0.0.78", "globals": "^15.9.0", "postcss": "^8.4.47", "prismjs": "^1.29.0", diff --git a/playwright-tests/preview-page.spec.ts b/playwright-tests/preview-page.spec.ts new file mode 100644 index 00000000..4022c29b --- /dev/null +++ b/playwright-tests/preview-page.spec.ts @@ -0,0 +1,14 @@ +import { expect, test } from "@playwright/test" + +test(`preview-snippet Page`, async ({ page }) => { + await page.goto("http://127.0.0.1:5177/preview?snippet_id=snippet_5&view=pcb") + await page.waitForTimeout(1000) + await expect(page).toHaveScreenshot(`preview-snippet-pcb.png`) + + await page.goto( + "http://127.0.0.1:5177/preview?snippet_id=snippet_5&view=schematic", + ) + // Wait for schematic viewer to load + await page.waitForTimeout(1000) + await expect(page).toHaveScreenshot(`preview-snippet-schematic.png`) +}) diff --git a/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png b/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png new file mode 100644 index 00000000..8798a141 Binary files /dev/null and b/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png differ diff --git a/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png b/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png new file mode 100644 index 00000000..da4d4667 Binary files /dev/null and b/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png differ diff --git a/renovate.json b/renovate.json index 183732e6..f5f8acfa 100644 --- a/renovate.json +++ b/renovate.json @@ -4,7 +4,11 @@ "packageRules": [ { "packagePatterns": ["*"], - "excludePackagePatterns": ["@tscircuit/*", "circuit-to-svg"], + "excludePackagePatterns": [ + "@tscircuit/*", + "circuit-to-svg", + "jscad-electronics" + ], "enabled": false }, { diff --git a/src/App.tsx b/src/App.tsx index 230bafdb..56a12415 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ import { EditorPage } from "./pages/editor" import { LandingPage } from "./pages/landing" import { MyOrdersPage } from "./pages/my-orders" import { NewestPage } from "./pages/newest" +import { PreviewPage } from "./pages/preview" import { QuickstartPage } from "./pages/quickstart" import { SearchPage } from "./pages/search" import { SettingsPage } from "./pages/settings" @@ -31,6 +32,7 @@ function App() { + diff --git a/src/components/CodeAndPreview.tsx b/src/components/CodeAndPreview.tsx index 70de7c46..33ef9bcf 100644 --- a/src/components/CodeAndPreview.tsx +++ b/src/components/CodeAndPreview.tsx @@ -73,6 +73,7 @@ export function CodeAndPreview({ snippet }: Props) { compiledJs, triggerRunTsx, tsxRunTriggerCount, + circuitJsonKey, } = useRunTsx({ code, userImports, @@ -183,6 +184,7 @@ export function CodeAndPreview({ snippet }: Props) { triggerRunTsx={triggerRunTsx} tsxRunTriggerCount={tsxRunTriggerCount} errorMessage={message} + circuitJsonKey={circuitJsonKey} circuitJson={circuitJson} manualEditsFileContent={manualEditsFileContent} onManualEditsFileContentChange={(newManualEditsFileContent) => { diff --git a/src/components/EditorNav.tsx b/src/components/EditorNav.tsx index 85a2d9f5..c380c966 100644 --- a/src/components/EditorNav.tsx +++ b/src/components/EditorNav.tsx @@ -164,7 +164,7 @@ export default function EditorNav({